Mercurial > repos > bcclaywell > argo_navis
comparison venv/lib/python2.7/site-packages/setuptools/lib2to3_ex.py @ 0:d67268158946 draft
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
author | bcclaywell |
---|---|
date | Mon, 12 Oct 2015 17:43:33 -0400 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:d67268158946 |
---|---|
1 """ | |
2 Customized Mixin2to3 support: | |
3 | |
4 - adds support for converting doctests | |
5 | |
6 | |
7 This module raises an ImportError on Python 2. | |
8 """ | |
9 | |
10 from distutils.util import Mixin2to3 as _Mixin2to3 | |
11 from distutils import log | |
12 from lib2to3.refactor import RefactoringTool, get_fixers_from_package | |
13 import setuptools | |
14 | |
15 class DistutilsRefactoringTool(RefactoringTool): | |
16 def log_error(self, msg, *args, **kw): | |
17 log.error(msg, *args) | |
18 | |
19 def log_message(self, msg, *args): | |
20 log.info(msg, *args) | |
21 | |
22 def log_debug(self, msg, *args): | |
23 log.debug(msg, *args) | |
24 | |
25 class Mixin2to3(_Mixin2to3): | |
26 def run_2to3(self, files, doctests = False): | |
27 # See of the distribution option has been set, otherwise check the | |
28 # setuptools default. | |
29 if self.distribution.use_2to3 is not True: | |
30 return | |
31 if not files: | |
32 return | |
33 log.info("Fixing "+" ".join(files)) | |
34 self.__build_fixer_names() | |
35 self.__exclude_fixers() | |
36 if doctests: | |
37 if setuptools.run_2to3_on_doctests: | |
38 r = DistutilsRefactoringTool(self.fixer_names) | |
39 r.refactor(files, write=True, doctests_only=True) | |
40 else: | |
41 _Mixin2to3.run_2to3(self, files) | |
42 | |
43 def __build_fixer_names(self): | |
44 if self.fixer_names: return | |
45 self.fixer_names = [] | |
46 for p in setuptools.lib2to3_fixer_packages: | |
47 self.fixer_names.extend(get_fixers_from_package(p)) | |
48 if self.distribution.use_2to3_fixers is not None: | |
49 for p in self.distribution.use_2to3_fixers: | |
50 self.fixer_names.extend(get_fixers_from_package(p)) | |
51 | |
52 def __exclude_fixers(self): | |
53 excluded_fixers = getattr(self, 'exclude_fixers', []) | |
54 if self.distribution.use_2to3_exclude_fixers is not None: | |
55 excluded_fixers.extend(self.distribution.use_2to3_exclude_fixers) | |
56 for fixer_name in excluded_fixers: | |
57 if fixer_name in self.fixer_names: | |
58 self.fixer_names.remove(fixer_name) |