Commits

DasIch  committed c950511

Rename __unicode__ to __str__

  • Participants
  • Parent commits d2829e6

Comments (0)

Files changed (3)

File custom_fixers/__init__.py

Empty file added.

File custom_fixers/fix_alt_unicode.py

+from lib2to3.fixer_base import BaseFix
+from lib2to3.fixer_util import Name
+
+class FixAltUnicode(BaseFix):
+    PATTERN = """
+    func=funcdef< 'def' name='__unicode__'
+                  parameters< '(' NAME ')' > any+ >
+    """
+
+    def transform(self, node, results):
+        name = results['name']
+        name.replace(Name('__str__', prefix=name.prefix))
     install_requires=requires,
     cmdclass=cmdclass,
     use_2to3=True,
+    use_2to3_fixers=['custom_fixers'],
 )