当前位置: 首页>>代码示例>>Python>>正文


Python refactor.get_fixers_from_package方法代码示例

本文整理汇总了Python中lib2to3.refactor.get_fixers_from_package方法的典型用法代码示例。如果您正苦于以下问题:Python refactor.get_fixers_from_package方法的具体用法?Python refactor.get_fixers_from_package怎么用?Python refactor.get_fixers_from_package使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在lib2to3.refactor的用法示例。


在下文中一共展示了refactor.get_fixers_from_package方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_fixer_loading_helpers

# 需要导入模块: from lib2to3 import refactor [as 别名]
# 或者: from lib2to3.refactor import get_fixers_from_package [as 别名]
def test_fixer_loading_helpers(self):
        contents = ["explicit", "first", "last", "parrot", "preorder"]
        non_prefixed = refactor.get_all_fix_names("myfixes")
        prefixed = refactor.get_all_fix_names("myfixes", False)
        full_names = refactor.get_fixers_from_package("myfixes")
        self.assertEqual(prefixed, ["fix_" + name for name in contents])
        self.assertEqual(non_prefixed, contents)
        self.assertEqual(full_names,
                         ["myfixes.fix_" + name for name in contents]) 
开发者ID:remg427,项目名称:misp42splunk,代码行数:11,代码来源:test_refactor.py

示例2: test_crlf_newlines

# 需要导入模块: from lib2to3 import refactor [as 别名]
# 或者: from lib2to3.refactor import get_fixers_from_package [as 别名]
def test_crlf_newlines(self):
        old_sep = os.linesep
        os.linesep = "\r\n"
        try:
            fn = os.path.join(TEST_DATA_DIR, "crlf.py")
            fixes = refactor.get_fixers_from_package("lib2to3.fixes")
            self.check_file_refactoring(fn, fixes)
        finally:
            os.linesep = old_sep 
开发者ID:remg427,项目名称:misp42splunk,代码行数:11,代码来源:test_refactor.py

示例3: get_refactorer

# 需要导入模块: from lib2to3 import refactor [as 别名]
# 或者: from lib2to3.refactor import get_fixers_from_package [as 别名]
def get_refactorer(fixer_pkg="lib2to3", fixers=None, options=None):
    """
    A convenience function for creating a RefactoringTool for tests.

    fixers is a list of fixers for the RefactoringTool to use. By default
    "lib2to3.fixes.*" is used. options is an optional dictionary of options to
    be passed to the RefactoringTool.
    """
    if fixers is not None:
        fixers = [fixer_pkg + ".fixes.fix_" + fix for fix in fixers]
    else:
        fixers = refactor.get_fixers_from_package(fixer_pkg + ".fixes")
    options = options or {}
    return refactor.RefactoringTool(fixers, options, explicit=True) 
开发者ID:remg427,项目名称:misp42splunk,代码行数:16,代码来源:support.py

示例4: __build_fixer_names

# 需要导入模块: from lib2to3 import refactor [as 别名]
# 或者: from lib2to3.refactor import get_fixers_from_package [as 别名]
def __build_fixer_names(self):
        if self.fixer_names: return
        self.fixer_names = []
        for p in setuptools.lib2to3_fixer_packages:
            self.fixer_names.extend(get_fixers_from_package(p))
        if self.distribution.use_2to3_fixers is not None:
            for p in self.distribution.use_2to3_fixers:
                self.fixer_names.extend(get_fixers_from_package(p)) 
开发者ID:jpush,项目名称:jbox,代码行数:10,代码来源:lib2to3_ex.py

示例5: __build_fixer_names

# 需要导入模块: from lib2to3 import refactor [as 别名]
# 或者: from lib2to3.refactor import get_fixers_from_package [as 别名]
def __build_fixer_names(self):
        if self.fixer_names:
            return
        self.fixer_names = []
        for p in setuptools.lib2to3_fixer_packages:
            self.fixer_names.extend(get_fixers_from_package(p))
        if self.distribution.use_2to3_fixers is not None:
            for p in self.distribution.use_2to3_fixers:
                self.fixer_names.extend(get_fixers_from_package(p)) 
开发者ID:sofia-netsurv,项目名称:python-netsurv,代码行数:11,代码来源:lib2to3_ex.py

示例6: convert_with_2to3

# 需要导入模块: from lib2to3 import refactor [as 别名]
# 或者: from lib2to3.refactor import get_fixers_from_package [as 别名]
def convert_with_2to3(filepath: str) -> str:
    from lib2to3.refactor import RefactoringTool, get_fixers_from_package
    from lib2to3.pgen2.parse import ParseError
    fixers = get_fixers_from_package('lib2to3.fixes')
    refactoring_tool = RefactoringTool(fixers)
    source = refactoring_tool._read_python_source(filepath)[0]
    try:
        tree = refactoring_tool.refactor_string(source, 'conf.py')
    except ParseError as err:
        # do not propagate lib2to3 exceptions
        lineno, offset = err.context[1]
        # try to match ParseError details with SyntaxError details
        raise SyntaxError(err.msg, (filepath, lineno, offset, err.value))
    return str(tree) 
开发者ID:sphinx-doc,项目名称:sphinx-intl,代码行数:16,代码来源:pycompat.py


注:本文中的lib2to3.refactor.get_fixers_from_package方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。