Skip to content

Commit

Permalink
Undefine the __str__ method
Browse files Browse the repository at this point in the history
I haven't yet decided what a Simple Inkscape Scripting object should
look like as a string so for now it produces the same output as
repr(obj).
  • Loading branch information
spakin committed Jan 10, 2024
1 parent 3beff7c commit c7160e3
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions simpinkscr/simple_inkscape_scripting.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,18 @@ def _python_to_svg_str(val):
else:
# Common case
return ' '.join([_python_to_svg_str(v) for v in val])
try:
# Simple Inkscape Scripting objects are converted to a string of
# the form "url(#id)".
return val.get_inkex_object().get_id(as_url=2)
except AttributeError:
pass
try:
# inkex objects also are converted to a string of the form
# "url(#id)".
return val.get_id(as_url=2)
except AttributeError:
pass
return str(val) # Everything else is converted to a string as usual.


Expand Down Expand Up @@ -438,12 +450,6 @@ def __repr__(self):
bbox.center,
iobj.get_id(1))

def __str__(self):
'''Return the object as a string of the form "url(#id)". This
enables the object to be used as a value in style key=value
arguments such as shape_inside.'''
return self._inkscape_obj.get_id(as_url=2)

def __eq__(self, other):
'''Two SimpleObjects are equal if they encapsulate the same
inkex object.'''
Expand Down

0 comments on commit c7160e3

Please sign in to comment.