Skip to content

Commit

Permalink
0.6.8 - Element builder-pattern improvement
Browse files Browse the repository at this point in the history
  • Loading branch information
vkottler committed Jul 7, 2024
1 parent 241e8fc commit de6b3b1
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 14 deletions.
13 changes: 9 additions & 4 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ on:
env:
TWINE_PASSWORD: ${{secrets.TWINE_PASSWORD}}
GITHUB_API_TOKEN: ${{secrets.API_TOKEN}}
CODECOV_TOKEN: ${{secrets.CODECOV_TOKEN}}

jobs:
build:
Expand Down Expand Up @@ -49,29 +50,33 @@ jobs:

- run: mk docs
if: |
matrix.python-version == '3.11'
matrix.python-version == '3.12'
&& matrix.system == 'ubuntu-latest'
- run: mk python-test
env:
PY_TEST_EXTRA_ARGS: --cov-report=xml

- uses: codecov/[email protected]
with:
fail_ci_if_error: true
verbose: true
token: ${{secrets.CODECOV_TOKEN}}

- run: mk pypi-upload-ci
env:
TWINE_USERNAME: __token__
if: |
matrix.python-version == '3.11'
matrix.python-version == '3.12'
&& matrix.system == 'ubuntu-latest'
&& env.TWINE_PASSWORD != ''
&& github.ref_name == 'master'
- run: |
mk python-release owner=vkottler \
repo=svgen version=0.6.7
repo=svgen version=0.6.8
if: |
matrix.python-version == '3.11'
matrix.python-version == '3.12'
&& matrix.system == 'ubuntu-latest'
&& env.GITHUB_API_TOKEN != ''
&& github.ref_name == 'master'
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
=====================================
generator=datazen
version=3.1.4
hash=ab870ab2cbc0c4a3a758b13fcfd9e9da
hash=81a7bf82ba5e1d93e03c2f2677035fae
=====================================
-->

# svgen ([0.6.7](https://pypi.org/project/svgen/))
# svgen ([0.6.8](https://pypi.org/project/svgen/))

[![python](https://img.shields.io/pypi/pyversions/svgen.svg)](https://pypi.org/project/svgen/)
![Build Status](https://github.com/vkottler/svgen/workflows/Python%20Package/badge.svg)
Expand Down
2 changes: 1 addition & 1 deletion local/variables/package.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
major: 0
minor: 6
patch: 7
patch: 8
entry: svgen
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta:__legacy__"

[project]
name = "svgen"
version = "0.6.7"
version = "0.6.8"
description = "A tool for working with scalable vector graphics."
readme = "README.md"
requires-python = ">=3.10"
Expand Down
4 changes: 2 additions & 2 deletions svgen/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# =====================================
# generator=datazen
# version=3.1.4
# hash=e14bbe2a7ffe20d555120553fdaf0d0c
# hash=d5836c072a305ff3cc492ddda24e295b
# =====================================

"""
Expand All @@ -10,4 +10,4 @@

DESCRIPTION = "A tool for working with scalable vector graphics."
PKG_NAME = "svgen"
VERSION = "0.6.7"
VERSION = "0.6.8"
9 changes: 6 additions & 3 deletions svgen/element/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# built-in
from io import StringIO
import os
from typing import Dict, List, TextIO, cast
from typing import Dict, List, TextIO, TypeVar, cast
from xml.etree import ElementTree as et

# internal
Expand All @@ -18,6 +18,7 @@
from svgen.attribute.style import Style

INDENT: int = 2
T = TypeVar("T", bound="Element")


class Element:
Expand Down Expand Up @@ -60,7 +61,7 @@ def __init__(

self.children: List[Element] = children

def add_class(self, *data: str) -> None:
def add_class(self: T, *data: str) -> T:
"""Add a class string."""

raw = self["class"]
Expand All @@ -69,6 +70,8 @@ def add_class(self, *data: str) -> None:
classes.add(item)
self["class"] = " ".join(classes)

return self

def __setitem__(self, tag: str, value: AttributeValue) -> None:
"""Allow adding attributes dict-set style."""
self.add_attribute(SimpleAttribute(tag, value), strict=False)
Expand Down Expand Up @@ -102,7 +105,7 @@ def style(self) -> Style:
self.add_attribute(Style())
return cast(Style, self.attributes["style"])

def add_attribute(self, attr: Attribute, strict: bool = True) -> "Element":
def add_attribute(self: T, attr: Attribute, strict: bool = True) -> T:
"""Add an attribute to this element."""

assert not strict or (
Expand Down

0 comments on commit de6b3b1

Please sign in to comment.