Closed GoogleCodeExporter closed 9 years ago
This indicates that you are running Python 2.4.x or earlier as support for that
particular structure was added in Python 2.5 as part of PEP 308. I'll go ahead
and undo that construct along the lines of your suggestion. Likewise for where
it appears in eggbot_maze.py. However, please do note that it is/was our
intent to support only Python 2.5 and later. It's possible that you may
encounter other, less easily dealt with issues if you are indeed running a
version of Python prior to 2.5.
Original comment by newman.d...@gmail.com
on 18 Oct 2010 at 1:34
BTW, thanks much for reporting this. It is truly appreciated when folks report
problems. Even more appreciated when they've diagnosed the issue and suggested
a working fix. I've already checked in a correction for eggbot_maze.py. Won't
check in the change for eggbot.py until later today as I need to test some
other things beforehand. HOWEVER, the change in eggbot.py will come along with
another significant change: pen centering for "start with pen centered" will
now take the center of the document page as being the point on the canvas (egg)
that the pen is centered at. That means that rather than being the line y=500
in your document, it will be the (x,y) poinrt (w/2, h/2) where w is your
document's width and h its height. Usually w=3200 and h=800 or 1000. You can
see the dimensions under FIle > Document Properties in Inkscape.
Original comment by newman.d...@gmail.com
on 18 Oct 2010 at 1:50
@unrepentantgeek,
From the python docs (http://docs.python.org/using/mac.html), "Mac OS X 10.5 comes with Python 2.5.1 pre-installed by Apple."
Would it be possible for you to say a little bit about your configuration? Did
you manually install Python, or perhaps use MacPorts or something like that?
(Thanks--Just curious!)
Original comment by windell@oskay.net
on 18 Oct 2010 at 5:26
Here's the diffs for the change I will check in (Revision 150). Change is
essentially the same
as that put forth by unrepentantgeek. I've attached a SVG file I used to test
the changes to
ensure that they work (albeit on my system with Python 2.6.4.) Would be nice
if someone
could verify things on OS X 10.5 (Leopard).
--- eggbot.py (revision 149)
+++ eggbot.py (working copy)
@@ -737,7 +737,15 @@
else:
pa = pl.split()
- d = "".join( ["M " + pa[i] if i == 0 else " L " + pa[i] for i in range(
0, len( pa ) )] )
+ if not len( pa ):
+ pass
+ # Issue 29: pre 2.5.? versions of Python do not have
+ # "statement-1 if expression-1 else statement-2"
+ # which came out of PEP 308, Conditional Expressions
+ #d = "".join( ["M " + pa[i] if i == 0 else " L " + pa[i] for i in range(
0, len( pa ) )] )
+ d = "M " + pa[0]
+ for i in range( 1, len( pa ) ):
+ d += " L " + pa[i]
newpath = inkex.etree.Element( inkex.addNS( 'path', 'svg' ) )
newpath.set( 'd', d );
s = node.get( 'style' )
@@ -780,7 +788,15 @@
else:
pa = pl.split()
- d = "".join( ["M " + pa[i] if i == 0 else " L " + pa[i] for i in range(
0, len( pa ) )] )
+ if not len( pa ):
+ pass
+ # Issue 29: pre 2.5.? versions of Python do not have
+ # "statement-1 if expression-1 else statement-2"
+ # which came out of PEP 308, Conditional Expressions
+ #d = "".join( ["M " + pa[i] if i == 0 else " L " + pa[i] for i in range(
0, len( pa ) )] )
+ d = "M " + pa[0]
+ for i in range( 1, len( pa ) ):
+ d += " L " + pa[i]
d += " Z"
newpath = inkex.etree.Element( inkex.addNS( 'path', 'svg' ) )
newpath.set( 'd', d );
Original comment by newman.d...@gmail.com
on 18 Oct 2010 at 7:21
Attachments:
My bad: the SVN checkin is Revision 151
Original comment by newman.d...@gmail.com
on 18 Oct 2010 at 7:24
Yes, Mac OS 10.5 does come with 2.5.1:
$ python
Python 2.5.1 (r251:54863, Jun 17 2009, 20:37:34)
[GCC 4.0.1 (Apple Inc. build 5465)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>
If I'm reading PEP308 right, it looks like it was added to Python just after
the Apple build (54863).
I'm happy to help out. It's much more fun to fix the code than to sit there
sadly looking at a bot I can't use! :)
Original comment by unrepent...@gmail.com
on 18 Oct 2010 at 7:38
You can download the latest eggbot.py (and eggbot.inx for good measure) from
http://code.google.com/p/eggbotcode/source/browse/#svn/trunk/inkscape_driver
and pop them into /Applications/Inkscape.app/Contents/Resources/extensions/ and
give them a try. While you don't need to restart Inkscape to pick up new
extension .py code, you do need to restart it to re-ingest an updated .inx
file. Of course, with SVN you can check out the entire source tree. (I believe
you can use Mercurial as well.)
As an aside, it's also possible for Inkscape to be using some other Python on
your system then the one you get from a terminal shell. The debug.py from
entry #50 and the debug.inx from entry #45 of
https://bugs.launchpad.net/inkscape/+bug/482993
when placed in ~/.config/inkscape/extensions/ gives you an extension named
"debug" which will dump some info on which Python is really being used. I
mention this because even though I see
% python
Python 2.6.4 (r264:75821M, Oct 27 2009, 19:48:32)
[GCC 4.0.1 (Apple Inc. build 5493)] on darwin
at the command line, when I run that little debug utility, I see that Inkscape
is using a 2.5.4 version of Python built more recently than the 2.6.4 reported
above. All kind of confusing....
Default Encoding: ascii
----------------------------------------
Filesystem Encoding: utf-8
----------------------------------------
Platform: darwin
----------------------------------------
Python version: 2.5.4
Python version:
2.5.4 (r254:67916, Feb 11 2010, 00:50:55)
[GCC 4.2.1 (Apple Inc. build 5646)]
----------------------------------------
Python executable:
/System/Library/Frameworks/Python.framework/Versions/2.5/bin/python
Python exec_prefix:
/System/Library/Frameworks/Python.framework/Versions/2.5
Python prefix:
/System/Library/Frameworks/Python.framework/Versions/2.5
Original comment by newman.d...@gmail.com
on 18 Oct 2010 at 8:17
Original issue reported on code.google.com by
unrepent...@gmail.com
on 18 Oct 2010 at 6:28Attachments: