Cleanup: run autopep8 on build_files/

Replace multiple hashes with over-lines for make_source_archive.py.
This commit is contained in:
Campbell Barton 2022-04-20 15:08:46 +10:00
parent 972a697f82
commit df3316cbe9
5 changed files with 18 additions and 14 deletions

View File

@ -202,9 +202,9 @@ def parm_size(node_child):
# NOT PERFECT CODE, EXTRACT SIZE FROM TOKENS
if len(tokens) >= 3: # foo [ 1 ]
if ((tokens[-3].kind == TokenKind.PUNCTUATION and tokens[-3].spelling == "[") and
(tokens[-2].kind == TokenKind.LITERAL and tokens[-2].spelling.isdigit()) and
(tokens[-1].kind == TokenKind.PUNCTUATION and tokens[-1].spelling == "]")):
if ((tokens[-3].kind == TokenKind.PUNCTUATION and tokens[-3].spelling == "[") and
(tokens[-2].kind == TokenKind.LITERAL and tokens[-2].spelling.isdigit()) and
(tokens[-1].kind == TokenKind.PUNCTUATION and tokens[-1].spelling == "]")):
# ---
return int(tokens[-2].spelling)
return -1

View File

@ -114,12 +114,11 @@ def makefile_log() -> List[str]:
print("Can't execute process")
sys.exit(1)
while process.poll():
time.sleep(1)
# We know this is always true based on the input arguments to `Popen`.
stdout: IO[bytes] = process.stdout # type: ignore
stdout: IO[bytes] = process.stdout # type: ignore
out = stdout.read()
stdout.close()
@ -210,7 +209,7 @@ def build_defines_as_source() -> str:
)
# We know this is always true based on the input arguments to `Popen`.
stdout: IO[bytes] = process.stdout # type: ignore
stdout: IO[bytes] = process.stdout # type: ignore
return cast(str, stdout.read().strip().decode('ascii'))
@ -228,7 +227,7 @@ def build_defines_as_args() -> List[str]:
def queue_processes(
process_funcs: Sequence[Tuple[Callable[..., subprocess.Popen[Any]], Tuple[Any, ...]]],
*,
job_total: int =-1,
job_total: int = -1,
sleep: float = 0.1,
) -> None:
""" Takes a list of function arg pairs, each function must return a process

View File

@ -143,8 +143,8 @@ def packages_path(current_directory: Path, cli_args: Any) -> Optional[Path]:
return Path(relpath)
### Manifest creation
# -----------------------------------------------------------------------------
# Manifest creation
def create_manifest(
@ -195,7 +195,8 @@ def packages_to_manifest(outfile: TextIO, packages_dir: Path) -> None:
print(path, file=outfile)
### Higher-level functions
# -----------------------------------------------------------------------------
# Higher-level functions
def create_tarball(
@ -249,7 +250,8 @@ def cleanup(manifest: Path) -> None:
print("OK")
## Low-level commands
# -----------------------------------------------------------------------------
# Low-level commands
def git_ls_files(directory: Path = Path(".")) -> Iterable[Path]:
@ -265,7 +267,7 @@ def git_ls_files(directory: Path = Path(".")) -> Iterable[Path]:
yield path
def git_command(*cli_args: Union[bytes, str, Path] ) -> Iterable[str]:
def git_command(*cli_args: Union[bytes, str, Path]) -> Iterable[str]:
"""Generator, yields lines of output from a Git command."""
command = ("git", *cli_args)

View File

@ -129,6 +129,7 @@ def svn_update(args, release_version):
call(svn_non_interactive + ["switch", svn_url + dirname, dirpath], exit_on_error=False)
call(svn_non_interactive + ["update", dirpath])
# Test if git repo can be updated.
def git_update_skip(args, check_remote_exists=True):
if make_utils.command_missing(args.git_command):

View File

@ -47,8 +47,10 @@ def check_output(cmd, exit_on_error=True):
def git_branch_exists(git_command, branch):
return call([git_command, "rev-parse", "--verify", branch], exit_on_error=False, silent=True) == 0 or \
call([git_command, "rev-parse", "--verify", "remotes/origin/" + branch], exit_on_error=False, silent=True) == 0
return (
call([git_command, "rev-parse", "--verify", branch], exit_on_error=False, silent=True) == 0 or
call([git_command, "rev-parse", "--verify", "remotes/origin/" + branch], exit_on_error=False, silent=True) == 0
)
def git_branch(git_command):