summaryrefslogtreecommitdiff
path: root/distutils2
diff options
context:
space:
mode:
author?ric Araujo <merwok@netwok.org>2010-11-26 03:32:24 +0100
committer?ric Araujo <merwok@netwok.org>2010-11-26 03:32:24 +0100
commit0b8a17e1a5dceb6d416eeae098627832561798a1 (patch)
treed79540d2bfd957b067ac3a8462725bff2c20a96c /distutils2
parentbef83afc930818948b54d441d7191d9d8d813c3e (diff)
downloaddisutils2-0b8a17e1a5dceb6d416eeae098627832561798a1.tar.gz
Small code cleanup
Diffstat (limited to 'distutils2')
-rw-r--r--distutils2/__init__.py5
-rw-r--r--distutils2/compat.py19
-rw-r--r--distutils2/util.py6
3 files changed, 9 insertions, 21 deletions
diff --git a/distutils2/__init__.py b/distutils2/__init__.py
index 98d7939..0b096a0 100644
--- a/distutils2/__init__.py
+++ b/distutils2/__init__.py
@@ -13,8 +13,3 @@ __all__ = ['__version__', 'logger']
__version__ = "1.0a3"
logger = getLogger('distutils2')
-
-# when set to True, converts doctests by default too
-run_2to3_on_doctests = True
-# Standard package names for fixer packages
-lib2to3_fixer_packages = ['lib2to3.fixes']
diff --git a/distutils2/compat.py b/distutils2/compat.py
index 86c733a..991b8b6 100644
--- a/distutils2/compat.py
+++ b/distutils2/compat.py
@@ -7,10 +7,13 @@ support distutils2 across versions(2.x and 3.x)
import logging
+# XXX Having two classes with the same name is not a good thing.
+# XXX 2to3-related code should move from util to this module
+
+# TODO Move common code here: PY3 (bool indicating if we're on 3.x), any, etc.
+
try:
from distutils2.util import Mixin2to3 as _Mixin2to3
- from distutils2 import run_2to3_on_doctests
- from lib2to3.refactor import get_fixers_from_package
_CONVERT = True
_KLASS = _Mixin2to3
except ImportError:
@@ -20,6 +23,7 @@ except ImportError:
# marking public APIs
__all__ = ['Mixin2to3']
+
class Mixin2to3(_KLASS):
""" The base class which can be used for refactoring. When run under
Python 3.0, the run_2to3 method provided by Mixin2to3 is overridden.
@@ -46,19 +50,10 @@ class Mixin2to3(_KLASS):
logging.info("Converting doctests with '.py' files")
_KLASS.run_2to3(self, files, doctests_only=True)
- # If the following conditions are met, then convert:-
- # 1. User has specified the 'convert_2to3_doctests' option. So, we
- # can expect that the list 'doctests' is not empty.
- # 2. The default is allow distutils2 to allow conversion of text files
- # containing doctests. It is set as
- # distutils2.run_2to3_on_doctests
-
- if doctests != [] and run_2to3_on_doctests:
+ if doctests != []:
logging.info("Converting text files which contain doctests")
_KLASS.run_2to3(self, doctests, doctests_only=True)
else:
# If run on Python 2.x, there is nothing to do.
def _run_2to3(self, files, doctests=[], fixers=[]):
pass
-
-
diff --git a/distutils2/util.py b/distutils2/util.py
index 473d6b6..da12875 100644
--- a/distutils2/util.py
+++ b/distutils2/util.py
@@ -1101,10 +1101,8 @@ def run_2to3(files, doctests_only=False, fixer_names=None, options=None,
for fixername in fixer_names:
fixers.extend([fixer for fixer in get_fixers_from_package(fixername)])
r = RefactoringTool(fixers, options=options)
- if doctests_only:
- r.refactor(files, doctests_only=True, write=True)
- else:
- r.refactor(files, write=True)
+ r.refactor(files, write=True, doctests_only=doctests_only)
+
class Mixin2to3:
""" Wrapper class for commands that run 2to3.