summaryrefslogtreecommitdiff
path: root/Lib/packaging/compat.py
diff options
context:
space:
mode:
authorÉric Araujo <merwok@netwok.org>2012-02-09 21:37:14 +0100
committerÉric Araujo <merwok@netwok.org>2012-02-09 21:37:14 +0100
commit692a49394dd871bf73418f018fd215678dc67e25 (patch)
tree20428602a7158430794f755ad60fa107bb5a4d05 /Lib/packaging/compat.py
parent1a765f5d9d3603b9d2d1415fcc8433c5f5e9e6e1 (diff)
downloadcpython-git-692a49394dd871bf73418f018fd215678dc67e25.tar.gz
Start improving 2to3 code in packaging (#13462).
- Change the fixers used in tests to something not provided by lib2to3 - Test conversion of doctests in text files - Factor out test boilerplate into a common method
Diffstat (limited to 'Lib/packaging/compat.py')
-rw-r--r--Lib/packaging/compat.py19
1 files changed, 9 insertions, 10 deletions
diff --git a/Lib/packaging/compat.py b/Lib/packaging/compat.py
index dcb58f527e..bfce92de66 100644
--- a/Lib/packaging/compat.py
+++ b/Lib/packaging/compat.py
@@ -1,4 +1,4 @@
-"""Compatibility helpers."""
+"""Support for build-time 2to3 conversion."""
from packaging import logger
@@ -25,7 +25,7 @@ class Mixin2to3(_KLASS):
"""
if _CONVERT:
- def _run_2to3(self, files, doctests=[], fixers=[]):
+ def _run_2to3(self, files=[], doctests=[], fixers=[]):
""" Takes a list of files and doctests, and performs conversion
on those.
- First, the files which contain the code(`files`) are converted.
@@ -35,17 +35,16 @@ class Mixin2to3(_KLASS):
if fixers:
self.fixer_names = fixers
- logger.info('converting Python code')
- _KLASS.run_2to3(self, files)
+ if files:
+ logger.info('converting Python code and doctests')
+ _KLASS.run_2to3(self, files)
+ _KLASS.run_2to3(self, files, doctests_only=True)
- logger.info('converting doctests in Python files')
- _KLASS.run_2to3(self, files, doctests_only=True)
-
- if doctests != []:
- logger.info('converting doctest in text files')
+ if doctests:
+ logger.info('converting doctests in text files')
_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=[]):
+ def _run_2to3(self, files=[], doctests=[], fixers=[]):
pass