From regebro at gmail.com Tue Apr 7 23:59:10 2009 From: regebro at gmail.com (Lennart Regebro) Date: Tue, 7 Apr 2009 23:59:10 +0200 Subject: [Python-porting] 2to3 pattern matching help needed. Message-ID: <319e029f0904071459i18cc2db8wdb3507db5d064a70@mail.gmail.com> Help! I need a pattern to match the following code: @implementor(IFoo) class C(object): implements(IFoo) classProvides(IFooFactory find_pattern claims that this code should match: "decorated< decorator< '@' 'implementer' '(' 'IFoo' ')' '\n' > classdef< 'class' 'C' '(' 'object' ')' ':' suite< '\n' ' ' simple_stmt< power< 'implements' trailer< '(' 'IFoo' ')' > > '\n' > simple_stmt< power< 'classProvides' trailer< '(' 'IFooFactory' ')' > > '\n' > '' > > >" It does not match. I already have the following similar pattern: "classdef< 'class' any* ':' suite< any* simple_stmt< power< statement=(%s) trailer < '(' interface=any ')' > any* > any* > any* > >" which matches the following code: class C(object): implements(IFoo) classProvides(IFooFactory I.e, the same code but without the decorator. But I also need to match even of the class has decorators, as in the beginning example. If the decorator matching code is the same or a separate that the one I have, that doesn't handle decorators, doesn't matter. -- Lennart Regebro: Pythonista, Barista, Notsotrista. http://regebro.wordpress.com/ +33 661 58 14 64 From benjamin at python.org Wed Apr 8 01:24:44 2009 From: benjamin at python.org (Benjamin Peterson) Date: Tue, 7 Apr 2009 18:24:44 -0500 Subject: [Python-porting] 2to3 pattern matching help needed. In-Reply-To: <319e029f0904071459i18cc2db8wdb3507db5d064a70@mail.gmail.com> References: <319e029f0904071459i18cc2db8wdb3507db5d064a70@mail.gmail.com> Message-ID: <1afaf6160904071624i636249bdwc5981c579355c349@mail.gmail.com> 2009/4/7 Lennart Regebro : > Help! I need a pattern to match the following code: > > @implementor(IFoo) > class C(object): > ? ?implements(IFoo) > ? ?classProvides(IFooFactory > > find_pattern claims that this code should match: > > "decorated< decorator< '@' 'implementer' '(' 'IFoo' ')' '\n' > > classdef< 'class' 'C' '(' 'object' ')' ':' suite< '\n' ' ? ?' > simple_stmt< power< 'implements' trailer< '(' 'IFoo' ')' > > '\n' > > simple_stmt< power< 'classProvides' trailer< '(' 'IFooFactory' ')' > > > '\n' > '' > > >" > > It does not match. 2to3 has a hard time working with more than a single statements and lines of code especially classes. You can't use the pattern matcher for everything, unfortunately. This pattern matches a class with the decorator you want: decorated< decorator< '@' 'implementor' '(' 'IFoo' ')' any > class=classdef< any* > > Once you that matches, I suggest you traverse the classdef node programmatically to find simple_stmts containing the lines you're interested in. This is similar to what lib2to3/fixes/fix_metaclass.py does. -- Regards, Benjamin From regebro at gmail.com Wed Apr 8 08:50:58 2009 From: regebro at gmail.com (Lennart Regebro) Date: Wed, 8 Apr 2009 08:50:58 +0200 Subject: [Python-porting] 2to3 pattern matching help needed. In-Reply-To: <1afaf6160904071624i636249bdwc5981c579355c349@mail.gmail.com> References: <319e029f0904071459i18cc2db8wdb3507db5d064a70@mail.gmail.com> <1afaf6160904071624i636249bdwc5981c579355c349@mail.gmail.com> Message-ID: <319e029f0904072350r4126551dif5477805ff76968d@mail.gmail.com> On Wed, Apr 8, 2009 at 01:24, Benjamin Peterson wrote: > 2009/4/7 Lennart Regebro : >> Help! I need a pattern to match the following code: >> >> @implementor(IFoo) >> class C(object): >> ? ?implements(IFoo) >> ? ?classProvides(IFooFactory >> >> find_pattern claims that this code should match: >> >> "decorated< decorator< '@' 'implementer' '(' 'IFoo' ')' '\n' > >> classdef< 'class' 'C' '(' 'object' ')' ':' suite< '\n' ' ? ?' >> simple_stmt< power< 'implements' trailer< '(' 'IFoo' ')' > > '\n' > >> simple_stmt< power< 'classProvides' trailer< '(' 'IFooFactory' ')' > > >> '\n' > '' > > >" >> >> It does not match. > > 2to3 has a hard time working with more than a single statements and > lines of code especially classes. You can't use the pattern matcher > for everything, unfortunately. This pattern matches a class with the > decorator you want: > > decorated< decorator< '@' 'implementor' '(' 'IFoo' ')' any > > class=classdef< any* > > > > Once you that matches, I suggest you traverse the classdef node > programmatically to find simple_stmts containing the lines you're > interested in. This is similar to what lib2to3/fixes/fix_metaclass.py > does. Well, that didn't help, but it made me realize I was barking up the wrong three. The problem was that I created a new node tree that wasn't what it would have looked like like if it had been parsed from source (although it would generate valid code when made into a str). I fixed that, and did some other changes, and I got past this obstacle too. Tricky stuff this. -- Lennart Regebro: Pythonista, Barista, Notsotrista. http://regebro.wordpress.com/ +33 661 58 14 64 From usedtire at archlinux.us Tue Apr 14 18:35:53 2009 From: usedtire at archlinux.us (member usedtire) Date: Tue, 14 Apr 2009 12:35:53 -0400 Subject: [Python-porting] pynids Message-ID: Has anyone ported pynids to python3? It appears that it hasn't even been ported to 2.6 from 2.4. I don't really want to downgrade, so I may have to try and work around it. Thanks Jesse -------------- next part -------------- An HTML attachment was scrubbed... URL: From g.roehrbein at gmx.de Wed Apr 29 01:00:06 2009 From: g.roehrbein at gmx.de (=?ISO-8859-1?Q?=22Gilbert_R=2E_R=F6hrbein=22?=) Date: Wed, 29 Apr 2009 01:00:06 +0200 Subject: [Python-porting] PyODE in Python 3 Message-ID: <49F78A76.5080308@gmx.de> Hi again, at http://gitorious.hq.c3d2.de/projects/py3ode/repos/mainline I placed my Cython/Python 3 port of PyODE. The change from the patch I submitted at the pyode-users list is, that Mass.__getattr__, __setattr___ and all the PyDocs are now explicitly UTF encoded (cause I didn't found a option in Cython for implicit UTF encoding). Gilbert, who is sry for being to lazy for importing the CVS log