ยปCore Development>Code coverage>Lib/packaging/compat.py

Python code coverage for Lib/packaging/compat.py

#countcontent
1n/a"""Support for build-time 2to3 conversion."""
2n/a
3n/afrom packaging import logger
4n/a
5n/a
6n/a# XXX Having two classes with the same name is not a good thing.
7n/a# XXX 2to3-related code should move from util to this module
8n/a
9n/atry:
10n/a from packaging.util import Mixin2to3 as _Mixin2to3
11n/a _CONVERT = True
12n/a _KLASS = _Mixin2to3
13n/aexcept ImportError:
14n/a _CONVERT = False
15n/a _KLASS = object
16n/a
17n/a__all__ = ['Mixin2to3']
18n/a
19n/a
20n/aclass Mixin2to3(_KLASS):
21n/a """ The base class which can be used for refactoring. When run under
22n/a Python 3.0, the run_2to3 method provided by Mixin2to3 is overridden.
23n/a When run on Python 2.x, it merely creates a class which overrides run_2to3,
24n/a yet does nothing in particular with it.
25n/a """
26n/a if _CONVERT:
27n/a
28n/a def _run_2to3(self, files=[], doctests=[], fixers=[]):
29n/a """ Takes a list of files and doctests, and performs conversion
30n/a on those.
31n/a - First, the files which contain the code(`files`) are converted.
32n/a - Second, the doctests in `files` are converted.
33n/a - Thirdly, the doctests in `doctests` are converted.
34n/a """
35n/a if fixers:
36n/a self.fixer_names = fixers
37n/a
38n/a if files:
39n/a logger.info('converting Python code and doctests')
40n/a _KLASS.run_2to3(self, files)
41n/a _KLASS.run_2to3(self, files, doctests_only=True)
42n/a
43n/a if doctests:
44n/a logger.info('converting doctests in text files')
45n/a _KLASS.run_2to3(self, doctests, doctests_only=True)
46n/a else:
47n/a # If run on Python 2.x, there is nothing to do.
48n/a
49n/a def _run_2to3(self, files=[], doctests=[], fixers=[]):
50n/a pass