Path: blob/master/ invest-robot-contest_TinkoffBotTwitch-main/venv/lib/python3.8/site-packages/setuptools/lib2to3_ex.py
7763 views
"""1Customized Mixin2to3 support:23- adds support for converting doctests456This module raises an ImportError on Python 2.7"""89import warnings10from distutils.util import Mixin2to3 as _Mixin2to311from distutils import log12from lib2to3.refactor import RefactoringTool, get_fixers_from_package1314import setuptools15from ._deprecation_warning import SetuptoolsDeprecationWarning161718class DistutilsRefactoringTool(RefactoringTool):19def log_error(self, msg, *args, **kw):20log.error(msg, *args)2122def log_message(self, msg, *args):23log.info(msg, *args)2425def log_debug(self, msg, *args):26log.debug(msg, *args)272829class Mixin2to3(_Mixin2to3):30def run_2to3(self, files, doctests=False):31# See of the distribution option has been set, otherwise check the32# setuptools default.33if self.distribution.use_2to3 is not True:34return35if not files:36return3738warnings.warn(39"2to3 support is deprecated. If the project still "40"requires Python 2 support, please migrate to "41"a single-codebase solution or employ an "42"independent conversion process.",43SetuptoolsDeprecationWarning)44log.info("Fixing " + " ".join(files))45self.__build_fixer_names()46self.__exclude_fixers()47if doctests:48if setuptools.run_2to3_on_doctests:49r = DistutilsRefactoringTool(self.fixer_names)50r.refactor(files, write=True, doctests_only=True)51else:52_Mixin2to3.run_2to3(self, files)5354def __build_fixer_names(self):55if self.fixer_names:56return57self.fixer_names = []58for p in setuptools.lib2to3_fixer_packages:59self.fixer_names.extend(get_fixers_from_package(p))60if self.distribution.use_2to3_fixers is not None:61for p in self.distribution.use_2to3_fixers:62self.fixer_names.extend(get_fixers_from_package(p))6364def __exclude_fixers(self):65excluded_fixers = getattr(self, 'exclude_fixers', [])66if self.distribution.use_2to3_exclude_fixers is not None:67excluded_fixers.extend(self.distribution.use_2to3_exclude_fixers)68for fixer_name in excluded_fixers:69if fixer_name in self.fixer_names:70self.fixer_names.remove(fixer_name)717273