From 39f8faa1b5c7d28361c43f8d5bbcaf7a0d9d924a Mon Sep 17 00:00:00 2001 From: Vaughn Kottler Date: Sat, 9 Mar 2024 22:39:53 -0600 Subject: [PATCH] 0.5.3 - Boolean attribute interface --- .github/workflows/python-package.yml | 2 +- README.md | 6 +++--- local/variables/package.yaml | 2 +- pyproject.toml | 2 +- setup.py | 2 +- svgen/__init__.py | 6 +++--- svgen/__main__.py | 2 +- svgen/element/__init__.py | 6 +++++- svgen/entry.py | 2 +- tasks/conf.py | 2 +- tests/element/test_element.py | 11 ++++++++++- 11 files changed, 28 insertions(+), 15 deletions(-) diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index b0e0597..e28da09 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -69,7 +69,7 @@ jobs: - run: | mk python-release owner=vkottler \ - repo=svgen version=0.5.2 + repo=svgen version=0.5.3 if: | matrix.python-version == '3.11' && matrix.system == 'ubuntu-latest' diff --git a/README.md b/README.md index 6197aef..b506e3f 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,12 @@ -# svgen ([0.5.2](https://pypi.org/project/svgen/)) +# svgen ([0.5.3](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) diff --git a/local/variables/package.yaml b/local/variables/package.yaml index 9b2e858..83c4c1e 100644 --- a/local/variables/package.yaml +++ b/local/variables/package.yaml @@ -1,5 +1,5 @@ --- major: 0 minor: 5 -patch: 2 +patch: 3 entry: svgen diff --git a/pyproject.toml b/pyproject.toml index 3f98965..1520cbc 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta:__legacy__" [project] name = "svgen" -version = "0.5.2" +version = "0.5.3" description = "A tool for working with scalable vector graphics." readme = "README.md" requires-python = ">=3.10" diff --git a/setup.py b/setup.py index c4ac937..9491fbf 100644 --- a/setup.py +++ b/setup.py @@ -1,6 +1,6 @@ # ===================================== # generator=datazen -# version=3.1.4 +# version=3.1.2 # hash=fc5241a8b8252685d9df5e59db1c172d # ===================================== diff --git a/svgen/__init__.py b/svgen/__init__.py index abeca40..1868137 100644 --- a/svgen/__init__.py +++ b/svgen/__init__.py @@ -1,7 +1,7 @@ # ===================================== # generator=datazen -# version=3.1.4 -# hash=0c02073ce759241f1378eda1222df9d7 +# version=3.1.2 +# hash=cb33bfd093e4521eba5674ccf0fd0a5f # ===================================== """ @@ -10,4 +10,4 @@ DESCRIPTION = "A tool for working with scalable vector graphics." PKG_NAME = "svgen" -VERSION = "0.5.2" +VERSION = "0.5.3" diff --git a/svgen/__main__.py b/svgen/__main__.py index e3719a7..e3e2c45 100644 --- a/svgen/__main__.py +++ b/svgen/__main__.py @@ -1,6 +1,6 @@ # ===================================== # generator=datazen -# version=3.1.4 +# version=3.1.2 # hash=d7721d3e4e7fae6161d538f1104cee4b # ===================================== """ diff --git a/svgen/element/__init__.py b/svgen/element/__init__.py index 7bc013b..209b4e3 100644 --- a/svgen/element/__init__.py +++ b/svgen/element/__init__.py @@ -45,6 +45,8 @@ def __init__( self.text = text self.attributes: Dict[str, Attribute] = {} + self.booleans: set[str] = set() + for attr in attrib + attributes(extra): self.add_attribute(attr) @@ -121,7 +123,9 @@ def encode( if newlines: output.write(indent_str) - attr_strs = [x.encode(quote) for x in self.attributes.values()] + attr_strs = [x.encode(quote) for x in self.attributes.values()] + list( + self.booleans + ) attrs = " ".join(x for x in attr_strs if x) output.write(f"<{self.tag}") if attrs: diff --git a/svgen/entry.py b/svgen/entry.py index b87c0ab..a9b33d2 100644 --- a/svgen/entry.py +++ b/svgen/entry.py @@ -1,6 +1,6 @@ # ===================================== # generator=datazen -# version=3.1.4 +# version=3.1.2 # hash=8374925c88a1f9c88881c5f279be02eb # ===================================== diff --git a/tasks/conf.py b/tasks/conf.py index 0aebbed..cbc5044 100644 --- a/tasks/conf.py +++ b/tasks/conf.py @@ -1,6 +1,6 @@ # ===================================== # generator=datazen -# version=3.1.4 +# version=3.1.2 # hash=7d378a1752611508007a77d4ca39a5af # ===================================== """ diff --git a/tests/element/test_element.py b/tests/element/test_element.py index 1844335..8cf99db 100644 --- a/tests/element/test_element.py +++ b/tests/element/test_element.py @@ -52,8 +52,17 @@ def test_element_xml(): """Test that we can get XML elements from elements in this package.""" elem = Svg(ViewBox.decode("viewBox", "0 0 100 100")) - elem.children.append(Element("rect")) + + rect = Element("rect") + elem.children.append(rect) + assert et.tostring(elem.xml, encoding="unicode") == ( '' "" ) + + rect.booleans.add("hidden") + rect.text = "Hello, world!" + assert ( + rect.encode_str(newlines=False) == "" + )