Skip to content

Commit

Permalink
0.5.3 - Boolean attribute interface
Browse files Browse the repository at this point in the history
  • Loading branch information
vkottler committed Mar 10, 2024
1 parent 9860998 commit 39f8faa
Show file tree
Hide file tree
Showing 11 changed files with 28 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<!--
=====================================
generator=datazen
version=3.1.4
hash=84ae4e3de22e8f60277833f9edbfd9a6
version=3.1.2
hash=ff3e2b2ac281d20f82c48829ab054ff6
=====================================
-->

# 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)
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: 5
patch: 2
patch: 3
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.5.2"
version = "0.5.3"
description = "A tool for working with scalable vector graphics."
readme = "README.md"
requires-python = ">=3.10"
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# =====================================
# generator=datazen
# version=3.1.4
# version=3.1.2
# hash=fc5241a8b8252685d9df5e59db1c172d
# =====================================

Expand Down
6 changes: 3 additions & 3 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=0c02073ce759241f1378eda1222df9d7
# version=3.1.2
# hash=cb33bfd093e4521eba5674ccf0fd0a5f
# =====================================

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

DESCRIPTION = "A tool for working with scalable vector graphics."
PKG_NAME = "svgen"
VERSION = "0.5.2"
VERSION = "0.5.3"
2 changes: 1 addition & 1 deletion svgen/__main__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# =====================================
# generator=datazen
# version=3.1.4
# version=3.1.2
# hash=d7721d3e4e7fae6161d538f1104cee4b
# =====================================
"""
Expand Down
6 changes: 5 additions & 1 deletion svgen/element/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion svgen/entry.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# =====================================
# generator=datazen
# version=3.1.4
# version=3.1.2
# hash=8374925c88a1f9c88881c5f279be02eb
# =====================================

Expand Down
2 changes: 1 addition & 1 deletion tasks/conf.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# =====================================
# generator=datazen
# version=3.1.4
# version=3.1.2
# hash=7d378a1752611508007a77d4ca39a5af
# =====================================
"""
Expand Down
11 changes: 10 additions & 1 deletion tests/element/test_element.py
Original file line number Diff line number Diff line change
Expand Up @@ -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") == (
'<svg viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg">'
"<rect /></svg>"
)

rect.booleans.add("hidden")
rect.text = "Hello, world!"
assert (
rect.encode_str(newlines=False) == "<rect hidden>Hello, world!</rect>"
)

0 comments on commit 39f8faa

Please sign in to comment.