Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(536)

Side by Side Diff: recipe_engine/third_party/setuptools/lib2to3_ex.py

Issue 1344583003: Recipe package system. (Closed) Base URL: git@github.com:luci/recipes-py.git@master
Patch Set: Recompiled proto Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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)
OLDNEW
« no previous file with comments | « recipe_engine/third_party/setuptools/gui-arm-32.exe ('k') | recipe_engine/third_party/setuptools/msvc9_support.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698