Skip to content

Commit

Permalink
Define __repr__ on SimpleMetadata
Browse files Browse the repository at this point in the history
  • Loading branch information
spakin committed Jan 11, 2024
1 parent a841f6d commit 00d7f50
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions simpinkscr/simple_inkscape_scripting.py
Original file line number Diff line number Diff line change
Expand Up @@ -2149,7 +2149,7 @@ class RectangularForeignObject(inkex.ForeignObject,
pass


class SimpleMetadata():
class SimpleMetadata(GenericReprMixin):
'Provide a simple interface to document metadata.'

def __init__(self):
Expand Down Expand Up @@ -2329,12 +2329,19 @@ def __init__(self):
}
self._licenses['Open Font License'] = self._licenses['OFL']

def get_inkex_object(self):
'''Return the SimpleMetadata's underlying inkex object.
Regrettably, this exhibits the side effect of creating a
<metadata> tag if one does not already exist (tested with
Inkscape 1.3.2.'''
global _simple_top
return _simple_top.svg_root.metadata

def _search_hierarchy(self, *args):
'''Search an XML hierarchy given tuples of (namespace, tag).
<rdf:RDF> is the implicit first element of the hierarchy. This
method returns the final node.'''
global _simple_top
elt = _simple_top.svg_root.metadata
elt = self.get_inkex_object()
for ns_tag in [(self.rdf, 'RDF')] + list(args):
child = elt.find('./{%s}%s' % ns_tag)
if child is None:
Expand All @@ -2346,8 +2353,7 @@ def _create_hierarchy(self, *args):
'''Create an XML hierarchy given tuples of (namespace, tag).
<rdf:RDF> is the implicit first element of the hierarchy. This
method returns the final node.'''
global _simple_top
elt = _simple_top.svg_root.metadata
elt = self.get_inkex_object()
for ns_tag in [(self.rdf, 'RDF')] + list(args):
child = elt.find('./{%s}%s' % ns_tag)
if child is None:
Expand Down

0 comments on commit 00d7f50

Please sign in to comment.