• Home
  • Raw
  • Download

Lines Matching +full:- +full:- +full:porcelain

2 # -*- coding: utf-8 -*-
5 # Use of this source code is governed by a BSD-style license that can be
27 env: t.Dict[str, str] = None) -> t.Tuple[int, str]:
40 return exit_code, stdout.decode('utf-8', 'replace')
43 def has_executable_on_path(exe: str) -> bool:
48 def escape_command(command: t.Iterable[str]) -> str:
49 """Returns a human-readable and copy-pastable shell command.
56 def remove_deleted_files(files: t.Iterable[str]) -> t.List[str]:
60 def is_file_executable(file_path: str) -> bool:
65 # toolchain-utils/. Add that to PYTHONPATH to ensure that things like `cros
67 def env_with_pythonpath(toolchain_utils_root: str) -> t.Dict[str, str]:
79 # - never write to stdout/stderr or read from stdin directly
80 # - return either a CheckResult, or a list of [(subcheck_name, CheckResult)]
81 # - ideally use thread_pool to check things concurrently
82 # - though it's important to note that these *also* live on the threadpool
98 task: multiprocessing.pool.ApplyResult) -> CheckResult:
115 python_files: t.Iterable[str]) -> CheckResult:
117 command = ['yapf', '-d'] + python_files
130 bad_file_re = re.compile(r'^--- (.*)\s+\(original\)\s*$')
150 autofix = ['yapf', '-i'] + bad_files
158 def check_python_file_headers(python_files: t.Iterable[str]) -> CheckResult:
165 with open(python_file, encoding='utf-8') as f:
180 autofix.append(['sed', '-i', '1i#!/usr/bin/env python3'] + add_hashbang)
185 autofix.append(['sed', '-i', '1d'] + remove_hashbang)
202 files: t.Iterable[str]) -> CheckResult:
231 def find_chromeos_root_directory() -> t.Optional[str]:
237 files: t.Iterable[str]) -> t.Union[t.List[CheckResult], CheckResult]:
245 def try_run_cros_lint(cros_binary: str) -> t.Optional[CheckResult]:
247 [cros_binary, 'lint', '--py3', '--'] + files,
274 def check_result_from_command(command: t.List[str]) -> CheckResult:
286 def run_pylint() -> CheckResult:
295 def run_golint() -> CheckResult:
297 return check_result_from_command(['golint', '-set_exit_status'] +
353 command = [gofmt, '-l'] + go_files
373 autofix = [gofmt, '-w'] + broken_files
384 files: t.List[str]) -> CheckResult:
387 [os.path.join(toolchain_utils_root, 'run_tests_for.py'), '--'] + files,
396 def detect_toolchain_utils_root() -> str:
402 start_time: datetime.datetime) -> t.Tuple[bool, t.List[t.List[str]]]:
403 """Prints human-readable output for the given check_results."""
406 def indent_block(text: str) -> str:
437 time_taken = datetime.datetime.now() - start_time
451 toolchain_utils_root: str) -> None:
456 exit_code, output = run_command_unchecked(['git', 'status', '--porcelain'],
459 print("Autofix aborted: couldn't get toolchain-utils git status.")
485 def find_repo_root(base_dir: str) -> t.Optional[str]:
494 def is_in_chroot() -> bool:
498 def maybe_reexec_inside_chroot(autofix: bool, files: t.List[str]) -> None:
508 print('Standalone toolchain-utils checkout detected; cannot enter '
523 # We'll be changing ${PWD}, so make everything relative to toolchain-utils,
524 # which resides at a well-known place inside of the chroot.
525 chroot_toolchain_utils = '/mnt/host/source/src/third_party/toolchain-utils'
527 def rebase_path(path: str) -> str:
533 '--enter',
534 '--',
539 args.append('--no_autofix')
554 def ensure_scipy_installed() -> None:
557 subprocess.check_call(['sudo', 'emerge', 'dev-python/pip'])
560 ['python3', '-c', 'import scipy'],
566 subprocess.check_call(['pip', 'install', '--user', 'scipy'])
569 def main(argv: t.List[str]) -> int:
572 '--no_autofix',
577 '--no_enter_chroot',
580 help="Prevent auto-entering the chroot if we're not already in it.")
591 # If you ask for --no_enter_chroot, you're on your own for installing these
599 # user-friendly way.
625 # pylint: disable=not-context-manager
636 # - we don't collide with checkers that are running concurrently
637 # - we clearly print out everything that went wrong ahead of time, in case