コード例 #1
0
    def handle(self, use_yapf=False, **opts):

        argv = sys.argv

        from autoflake import main

        sys.argv = tuple(
            self._module_args('--in-place', '--remove-duplicate-keys',
                              '--expand-star-import',
                              '--remove-all-unused-imports', '--recursive'))

        main()

        from isort.main import main

        sys.argv = list(
            self._module_args(
                '-rc', '--multi-line', '5', '-a',
                "from __future__ import absolute_import, print_function, unicode_literals"
            ))

        main()

        if use_yapf:

            import yapf

            sys.argv = list(
                self._module_args('--in-place', '--recursive', '--parallel'))

            yapf.run_main()

            sys.argv = argv
コード例 #2
0
ファイル: main_test.py プロジェクト: wushiyuan/yapf
 def testShouldHandleYapfError(self):
   """run_main should handle YapfError and sys.exit(1)"""
   expected_message = 'yapf: Input filenames did not match any python files\n'
   sys.argv = ['yapf', 'foo.c']
   with captured_output() as (out, err):
     with self.assertRaises(SystemExit):
       yapf.run_main()
     self.assertEqual(out.getvalue(), '')
     self.assertEqual(err.getvalue(), expected_message)
コード例 #3
0
ファイル: main_test.py プロジェクト: BearBBQ/yapf
 def testShouldHandleYapfError(self):
   """run_main should handle YapfError and sys.exit(1)"""
   expected_message = 'yapf: Input filenames did not match any python files\n'
   sys.argv = ['yapf', 'foo.c']
   with captured_output() as (out, err):
     with self.assertRaises(SystemExit):
       yapf.run_main()
     self.assertEqual(out.getvalue(), '')
     self.assertEqual(err.getvalue(), expected_message)
コード例 #4
0
#!/usr/bin/env vpython

# Copyright 2019 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

# [VPYTHON:BEGIN]
# wheel: <
#   # Required for parallelism in python 2.
#   name: "infra/python/wheels/futures-py2_py3"
#   version: "version:3.1.1"
# >
# wheel: <
#   name: "infra/python/wheels/yapf-py2_py3"
#   version: "version:0.27.0"
# >
# [VPYTHON:END]

# -*- coding: utf-8 -*-
import sys

from yapf import run_main

if __name__ == '__main__':
    sys.exit(run_main())
コード例 #5
0
# Copyright 2015-2017 Google Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import yapf

yapf.run_main()
コード例 #6
0
ファイル: yapf_script.py プロジェクト: RussTedrake/htmlbook
# Copyright 2020 Massachusetts Institute of Technology.
# Licensed under the BSD 3-Clause License. See LICENSE.TXT for details.

import re
import sys

from yapf import run_main

if __name__ == "__main__":
    sys.argv[0] = re.sub(r"_script\.py$", "", sys.argv[0])
    run_main()