Skip to content
This repository has been archived by the owner. It is now read-only.
2to3 fixers for Zope
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.


Type Name Latest commit message Commit time
Failed to load latest commit information.


.. caution:: 

    This repository has been archived. If you want to work on it please open a ticket in requesting its unarchival.


Fixers for Zope Component Architecture and the frameworks built with it.

Currently, there is only one fixer, fix_implements. This fixer will change
all uses of implements(IFoo) in a class body to the class decorator
@implementer(IFoo), which is the most likely Python 3 syntax for
zope.interfaces implements statements.


Typically you will use zope.fixers together with Distribute's 2to3 support.
This is done by adding zope.fixers to some parameters in setup():

    >>> setup(
    ...     install_requires = ['zope.fixers'],
    ...     use_2to3 = True,
    ...     use_2to3_fixers = ['zope.fixers'],
    ... )

For an example usage of a complex case, look at:

That supports both distutils, setuptools and distribute, all versions
of python from 2.4 to 3.1, and has an optional C-extension, so don't worry if
it's overwhelming. For simple projects all you need is to use Distribute and
add the above three lines to the Distribute has more documentation
on how to use it to support Python 3 porting.

If you don't want to use Distribute things get a bit more complex, as you have
to make the list of fixers yourself and call lib2to3 with that:

    >>> from lib2to3.refactor import RefactoringTool, get_fixers_from_package
    >>> fixers = get_fixers_from_package('lib2to3.fixes') + \
    ...          get_fixers_from_package('zope.fixers')

And the run the fixing with the fixers:

    >>> tool = RefactoringTool(fixers)
    >>> tool.refactor(files, write=True)

Fixer Script

The package also provides a console script called `zope-2to3` that has the
same arguments as `2to3` but applies the fixers defined in this package.
You can’t perform that action at this time.