當前位置: 首頁>>代碼示例>>Python>>正文


Python autopep8.parse_args方法代碼示例

本文整理匯總了Python中autopep8.parse_args方法的典型用法代碼示例。如果您正苦於以下問題:Python autopep8.parse_args方法的具體用法?Python autopep8.parse_args怎麽用?Python autopep8.parse_args使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在autopep8的用法示例。


在下文中一共展示了autopep8.parse_args方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: prg2py_after_preproc

# 需要導入模塊: import autopep8 [as 別名]
# 或者: from autopep8 import parse_args [as 別名]
def prg2py_after_preproc(data, parser_start, input_filename):
    input_stream = antlr4.InputStream(data)
    lexer = VisualFoxpro9Lexer(input_stream)
    stream = antlr4.CommonTokenStream(lexer)
    parser = VisualFoxpro9Parser(stream)
    tree = run_parser(stream, parser, parser_start)
    TreeCleanVisitor().visit(tree)
    output_tree = PythonConvertVisitor(input_filename).visit(tree)
    if not isinstance(output_tree, list):
        return output_tree
    output = add_indents(output_tree, 0)
    options = autopep8.parse_args(['--max-line-length', '100000', '-'])
    output = autopep8.fix_code(output, options)
    tokens = list(tokenize.generate_tokens(io.StringIO(output).readline))
    for i, token in enumerate(tokens):
        token = list(token)
        if token[0] == tokenize.STRING and token[1].startswith('u'):
            token[1] = token[1][1:]
        tokens[i] = tuple(token)
    return tokenize.untokenize(tokens) 
開發者ID:mwisslead,項目名稱:vfp2py,代碼行數:22,代碼來源:vfp2py.py

示例2: autopep8

# 需要導入模塊: import autopep8 [as 別名]
# 或者: from autopep8 import parse_args [as 別名]
def autopep8(args):
    """Format code according to PEP8
    """
    try:
        import autopep8
    except:
        error('autopep8 not found! Run "paver install_devtools".')
        sys.exit(1)

    if any(x not in args for x in ['-i', '--in-place']):
        args.append('-i')

    args.append('--ignore=E261,E265,E402,E501')
    args.insert(0, 'dummy')

    cmd_args = autopep8.parse_args(args)

    excludes = ('ext-lib', 'ext-src')
    for p in options.plugin.source_dir.walk():
        if any(exclude in p for exclude in excludes):
            continue

        if p.fnmatch('*.py'):
            autopep8.fix_file(p, options=cmd_args) 
開發者ID:planetfederal,項目名稱:qgis-geoserver-plugin,代碼行數:26,代碼來源:pavement.py

示例3: test_autopep8_args

# 需要導入模塊: import autopep8 [as 別名]
# 或者: from autopep8 import parse_args [as 別名]
def test_autopep8_args(self):
        import autopep8

        args = ['hello.py']
        us = parse_args(args)
        them = autopep8.parse_args(args)

        self.assertEqual(us.select, them.select)
        self.assertEqual(us.ignore, them.ignore)

        args = ['hello.py', '--select=E1,W1', '--ignore=W601',
                '--max-line-length', '120']
        us = parse_args(args)
        them = autopep8.parse_args(args)
        self.assertEqual(us.select, them.select)
        self.assertEqual(us.ignore, them.ignore)
        self.assertEqual(us.max_line_length, them.max_line_length)

        args = ['hello.py', '--aggressive', '-v']
        us = parse_args(args)
        them = autopep8.parse_args(args)
        self.assertEqual(us.aggressive, them.aggressive) 
開發者ID:hayd,項目名稱:pep8radius,代碼行數:24,代碼來源:test_main.py

示例4: gen

# 需要導入模塊: import autopep8 [as 別名]
# 或者: from autopep8 import parse_args [as 別名]
def gen(path,
        method=None,
        query_params=None,
        data=None,
        content_type=None):
    # generates python code representing a call via django client.
    # useful for use in testing
    method = method.lower()
    t = jinja2.Template(template)
    if method == 'get':
        r = t.render(path=path,
                     data=query_params,
                     lower_case_method=method,
                     content_type=content_type)
    else:
        if query_params:
            query_params = _encode_query_params(query_params)
            path += query_params
        if is_str_typ(data):
            data = "'%s'" % data
        r = t.render(path=path,
                     data=data,
                     lower_case_method=method,
                     query_params=query_params,
                     content_type=content_type)
    return autopep8.fix_code(
        r, options=autopep8.parse_args(['--aggressive', ''])
    ) 
開發者ID:jazzband,項目名稱:django-silk,代碼行數:30,代碼來源:django_test_client.py

示例5: test_no_config

# 需要導入模塊: import autopep8 [as 別名]
# 或者: from autopep8 import parse_args [as 別名]
def test_no_config(self):
        args_before = parse_args(apply_config=False, root=TEMP_DIR)
        self.assertNotIn('E999', args_before.ignore) 
開發者ID:hayd,項目名稱:pep8radius,代碼行數:5,代碼來源:test_main.py

示例6: test_global_config

# 需要導入模塊: import autopep8 [as 別名]
# 或者: from autopep8 import parse_args [as 別名]
def test_global_config(self):
        with open(GLOBAL_CONFIG, mode='w') as f:
            f.write("[pep8]\nignore=E999")
        args_after = parse_args(['--global-config=%s' % GLOBAL_CONFIG],
                                apply_config=True, root=TEMP_DIR)
        self.assertIn('E999', args_after.ignore)
        args_after = parse_args(['--global-config=False'],
                                apply_config=True, root=TEMP_DIR)
        self.assertNotIn('E999', args_after.ignore) 
開發者ID:hayd,項目名稱:pep8radius,代碼行數:11,代碼來源:test_main.py

示例7: test_local_config

# 需要導入模塊: import autopep8 [as 別名]
# 或者: from autopep8 import parse_args [as 別名]
def test_local_config(self):
        with open(LOCAL_CONFIG, mode='w') as f:
            f.write("[pep8]\nignore=E999")
        args_after = parse_args([''],
                                apply_config=True, root=TEMP_DIR)
        self.assertIn('E999', args_after.ignore)
        args_after = parse_args(['--ignore-local-config'],
                                apply_config=True, root=TEMP_DIR)
        self.assertNotIn('E999', args_after.ignore) 
開發者ID:hayd,項目名稱:pep8radius,代碼行數:11,代碼來源:test_main.py

示例8: test_local_and_global_config

# 需要導入模塊: import autopep8 [as 別名]
# 或者: from autopep8 import parse_args [as 別名]
def test_local_and_global_config(self):
        with open(GLOBAL_CONFIG, mode='w') as f:
            f.write("[pep8]\nindent-size=2")
        with open(LOCAL_CONFIG, mode='w') as f:
            f.write("[pep8]\nindent-size=3")
        args_after = parse_args(['--global-config=%s' % GLOBAL_CONFIG],
                                apply_config=True, root=TEMP_DIR)
        self.assertEqual(3, args_after.indent_size)
        args_after = parse_args(['--global-config=%s' % GLOBAL_CONFIG,
                                 '--ignore-local-config'],
                                apply_config=True, root=TEMP_DIR)
        self.assertEqual(2, args_after.indent_size) 
開發者ID:hayd,項目名稱:pep8radius,代碼行數:14,代碼來源:test_main.py

示例9: test_pep8

# 需要導入模塊: import autopep8 [as 別名]
# 或者: from autopep8 import parse_args [as 別名]
def test_pep8(self):
        # verify all files are nicely styled
        python_filepaths = get_python_filepaths()
        style_guide = get_style_guide()
        fake_stdout = io.StringIO()
        with patch('sys.stdout', fake_stdout):
            report = style_guide.check_files(python_filepaths)

        # if flake8 didnt' report anything, we're done
        if report.total_errors == 0:
            return

        # grab on which files we have issues
        flake8_issues = fake_stdout.getvalue().split('\n')
        broken_filepaths = {item.split(':')[0] for item in flake8_issues if item}

        # give hints to the developer on how files' style could be improved
        options = autopep8.parse_args([''])
        options.aggressive = 1
        options.diff = True
        options.max_line_length = 99

        issues = []
        for filepath in broken_filepaths:
            diff = autopep8.fix_file(filepath, options=options)
            if diff:
                issues.append(diff)

        report = ["Please fix files as suggested by autopep8:"] + issues
        report += ["\n-- Original flake8 reports:"] + flake8_issues
        self.fail("\n".join(report)) 
開發者ID:canonical,項目名稱:operator,代碼行數:33,代碼來源:test_infra.py


注:本文中的autopep8.parse_args方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。