當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。