From c7160e3226bfe946d9333a8567101abe324ca582 Mon Sep 17 00:00:00 2001 From: Scott Pakin Date: Tue, 9 Jan 2024 22:56:00 -0700 Subject: [PATCH] Undefine the __str__ method 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). --- simpinkscr/simple_inkscape_scripting.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/simpinkscr/simple_inkscape_scripting.py b/simpinkscr/simple_inkscape_scripting.py index ddb85d2..55d0ca9 100644 --- a/simpinkscr/simple_inkscape_scripting.py +++ b/simpinkscr/simple_inkscape_scripting.py @@ -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. @@ -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.'''