Hello I am starting the backport of Packaging into a standalone version named Distutils2 -- this is very important to speed up the development of packaging itself since it'll give of more feedback from 2.x projects To do this I need to create a script that does a mass renaming of 'packaging' into 'distutils2', then I can start to play with 3to2 and ...3.xto3.x :) . I tried to script rope but the py3k version seem not compatible with our current AST -- and it's a bit overkill for this task I guess. Before I start to write my own refactoring tool, I was wondering if anyone here had some experience in this, and could give me some hints. Thanks Tarek -- Tarek Ziadé | http://ziade.org
On Tue, 21 Jun 2011 13:42:05 +0200, =?ISO-8859-1?Q?Tarek_Ziad=E9?= <ziade.tarek@gmail.com> wrote:
Before I start to write my own refactoring tool, I was wondering if anyone here had some experience in this, and could give me some hints.
Coul you could just write a 3to2 fixer? I don't know how hard it is to run just a selected set of fixers (so that you could use it to generate python3 code), but it seems to me that renaming modules is something that 3to2 (and 2to3, of course) should be good at. -- R. David Murray http://www.bitdance.com
On Tue, Jun 21, 2011 at 2:44 PM, Nick Coghlan <ncoghlan@gmail.com> wrote:
2to3 or Brett's mnfy are likely to be reasonable starting points.
Will look at mnfy, thanks -- Tarek Ziadé | http://ziade.org
On Tue, Jun 21, 2011 at 3:12 PM, R. David Murray <rdmurray@bitdance.com> wrote:
On Tue, 21 Jun 2011 13:42:05 +0200, =?ISO-8859-1?Q?Tarek_Ziad=E9?= <ziade.tarek@gmail.com> wrote:
Before I start to write my own refactoring tool, I was wondering if anyone here had some experience in this, and could give me some hints.
Coul you could just write a 3to2 fixer? I don't know how hard it is to run just a selected set of fixers (so that you could use it to generate python3 code), but it seems to me that renaming modules is something that 3to2 (and 2to3, of course) should be good at.
The one thing rope is good at is to find where a given variable name is used, and rename all occurrences recursively. So basically, when you rename an import, it renames all the code that uses it. I don't really know how 2to3/3to2 work but I assumed that it does not do this, but simply give you a hook for every visited node. IOW that looking for dependencies is to be done Cheers Tarek
-- R. David Murray http://www.bitdance.com
-- Tarek Ziadé | http://ziade.org
On Tue, Jun 21, 2011 at 9:27 AM, Tarek Ziadé <ziade.tarek@gmail.com> wrote:
On Tue, Jun 21, 2011 at 3:12 PM, R. David Murray <rdmurray@bitdance.com> wrote:
On Tue, 21 Jun 2011 13:42:05 +0200, =?ISO-8859-1?Q?Tarek_Ziad=E9?= < ziade.tarek@gmail.com> wrote:
Before I start to write my own refactoring tool, I was wondering if anyone here had some experience in this, and could give me some hints.
Coul you could just write a 3to2 fixer? I don't know how hard it is to run just a selected set of fixers (so that you could use it to generate python3 code), but it seems to me that renaming modules is something that 3to2 (and 2to3, of course) should be good at.
The one thing rope is good at is to find where a given variable name is used, and rename all occurrences recursively. So basically, when you rename an import, it renames all the code that uses it.
I don't really know how 2to3/3to2 work but I assumed that it does not do this, but simply give you a hook for every visited node. IOW that looking for dependencies is to be done
Cheers Tarek
-- R. David Murray http://www.bitdance.com
-- Tarek Ziadé | http://ziade.org
Yes, 2to3/3to2 does not do anything fancy like that. The tools are purely concerned with syntax, whereas renaming imports is semantic. The good news is that this line: import packaging as _myPackaging can be replaced by: import distutils2 as _myPackaging and code that uses _myPackaging will work. I've attached a fixer that can go into your lib3to2/fixes folder. You should also edit fix_imports.py and add the line: "packaging" : "distutils2", to the MAPPING dictionary near the top, then you can run 3to2 like this: 3to2 -fpackaging -fimports files_to_fix.py (-w option to write changes to the files modified) Hope this helps, --Joe Amenta
On Tue, Jun 21, 2011 at 3:37 PM, Joe Amenta <amentajo@msu.edu> wrote: ...
Yes, 2to3/3to2 does not do anything fancy like that. The tools are purely concerned with syntax, whereas renaming imports is semantic. The good news is that this line: import packaging as _myPackaging can be replaced by: import distutils2 as _myPackaging and code that uses _myPackaging will work. I've attached a fixer that can go into your lib3to2/fixes folder. You should also edit fix_imports.py and add the line: "packaging" : "distutils2", to the MAPPING dictionary near the top, then you can run 3to2 like this: 3to2 -fpackaging -fimports files_to_fix.py (-w option to write changes to the files modified) Hope this helps,
It does, thanks a lot ! Cheers Tarek -- Tarek Ziadé | http://ziade.org
participants (4)
-
Joe Amenta
-
Nick Coghlan
-
R. David Murray
-
Tarek Ziadé