Skip to content

Commit

Permalink
no addNS
Browse files Browse the repository at this point in the history
  • Loading branch information
kaalleen committed Sep 7, 2022
1 parent d46335d commit 5f60c3f
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 30 deletions.
16 changes: 5 additions & 11 deletions bingo/bingo.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,9 @@
from random import shuffle

from inkex import (NSS, Boolean, GenerateExtension, Group, Line, TextElement,
Transform, Tspan, addNS, colors, errormsg)
Transform, Tspan, colors, errormsg)
from inkex.localization import inkex_gettext as _

INKSCAPE_LABEL = addNS('label', 'inkscape')
XLINK_HREF = addNS('href', 'xlink')


class BingoCardCreator(GenerateExtension):
"""Outputs bingo cards as a svg fragment"""
Expand All @@ -55,7 +52,7 @@ def __init__(self, *args, **kwargs):
self.num_color = colors.Color('#000000')
self.render_grid = False
self.stroke_width = 1
self.free_spaces = ''
self.free_spaces = None

def container_transform(self):
return Transform(translate=(0, 0))
Expand Down Expand Up @@ -95,7 +92,6 @@ def generate(self):
self.num_color = self.options.num_color
self.render_grid = self.options.render_grid
self.stroke_width = self.options.stroke_width
self.free_spaces = None
# if num_range is smaller than the rows, reduce rows to num_range
if self.num_range < self.rows:
self.rows = self.num_range
Expand Down Expand Up @@ -139,7 +135,6 @@ def generate(self):
grid_group = self._render_grid()

transform = self._get_transform(bingo_field, bingo_clone, bingo_group_transform)

number_group.set('transform', transform)
if grid_group is not None:
grid_group.set('transform', transform)
Expand Down Expand Up @@ -167,7 +162,7 @@ def _load_area_params(self, bingo_field):
if self.card_header == "none":
self.card_header = ""
except (TypeError, ValueError, colors.ColorError):
label = bingo_field.get(INKSCAPE_LABEL, '')
label = bingo_field.label
el_id = bingo_field.get('id')
errormsg(_(f'Please verify bingo attributes for {label}: {el_id}'))

Expand Down Expand Up @@ -209,9 +204,8 @@ def _set_layer_label(self, layer):
def _get_clone_origin(self, clone):
# returns the origin of the clone and transform information for grouped clones
bingo_group_transform = None
source_id = clone.get(XLINK_HREF)[1:]
xpath = f'.//*[@id="{source_id}"]'
bingo_field = self.document.xpath(xpath)[0]
bingo_field = clone.href
source_id = bingo_field.get_id()
if bingo_field.tag_name == "g":
xpath = ".//svg:rect[starts-with(@id,'bingo-area')]"
bingo_field = bingo_field.xpath(xpath)
Expand Down
39 changes: 20 additions & 19 deletions resources/grouped_clone_template.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 5f60c3f

Please sign in to comment.