[code-quality] RedBaron, a bottom-up refactoring lib/tool for python

Eduardo Schettino schettino72 at gmail.com
Mon Nov 17 10:58:02 CET 2014


Hi guys,

I also have done some work in this area [1].
Well, I didnt get into reactoring yet...
Anyway, I thought you might be interested.

My approach was to convert python code to XML (and back to python)
This allow any generic XML tool to be used to manipulate the XML-code,
and then convert back to python without the need to create specific tools.

The implementation uses python's AST tree and the tokenize module
to retrieve information that is thrown away by the AST.
This way I didnt need to implement my own python parser.
It ended up being much more work than I expected but I still believe thats
better
than maitaining another parser.

[1] http://pythonhosted.org/pyRegurgitator/#py2xml-experimental

https://github.com/schettino72/pyRegurgitator

cheers,
   Eduardo


On Mon, Nov 17, 2014 at 5:01 PM, Sylvain Thénault <
sylvain.thenault at logilab.fr> wrote:

> On 15 novembre 16:49, Dave Halter wrote:
> > Hi Laurent
>
> Hi Laurent, David,
>
> > Great to see somebody finally tackling refactoring.
>
> indeed!
>
> > I'm answering, because I think we're working on the same issue. But we
> have
> > finished two different parts: You have finished a refactoring
> > implementation and I have finished the static analysis part. I'm the
> author
> > of Jedi. https://github.com/davidhalter/jedi/
>
> Could I ask what do you mean by static analysis in the context of a
> completion
> library?
>
> > I'm currently working on the integration of the lib2to3 parser into Jedi.
> > This would make refactoring really easy (I'm about 50% done with the
> > parser). It's also well tested and offers a few other advantages.
> >
> > In a perfect world, we could now combine our projects :-) I will look in
> > detail at Red Baron on Monday.
>
> David, we've been talking about this during the latest EuroPython, and I've
> talked with Laurent yesterday at the Capitole du Libre in Toulouse: IMO we
> could
> start by extracting from lib2to3 "the" parser that could be used by every
> tools
> like ours (refactoring, completion, static analysis...). It would be:
> * loss-less (comments, indents...)
> * accurate (eg from/to line numbers)
> * fast
> * version agnostic within a reasonable frame (eg 2.7 -> 3.4?)
>
> I guess almost every one on this list would be interested in such a
> parser, even
> if most would have to do a second pass on the generated tree to get more
> "business oriented" tree for their own project. Whatever, we (pylint guys)
> would
> be greatly interested.
>
> --
> Sylvain Thénault, LOGILAB, Paris (01.45.32.03.12) - Toulouse
> (05.62.17.16.42)
> Formations Python, Debian, Méth. Agiles: http://www.logilab.fr/formations
> Développement logiciel sur mesure:       http://www.logilab.fr/services
> CubicWeb, the semantic web framework:    http://www.cubicweb.org
> _______________________________________________
> code-quality mailing list
> code-quality at python.org
> https://mail.python.org/mailman/listinfo/code-quality
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/code-quality/attachments/20141117/428a7e7c/attachment.html>


More information about the code-quality mailing list