patman: Convert camel case in command.py
Convert this file to snake case and update all files which use it.
Signed-off-by: Simon Glass <sjg@chromium.org>
diff --git a/tools/patman/checkpatch.py b/tools/patman/checkpatch.py
index 8978df2..4677a7a 100644
--- a/tools/patman/checkpatch.py
+++ b/tools/patman/checkpatch.py
@@ -213,7 +213,7 @@
args = [chk, '--no-tree']
if show_types:
args.append('--show-types')
- output = command.Output(*args, fname, raise_on_error=False)
+ output = command.output(*args, fname, raise_on_error=False)
return CheckPatchParse(output, verbose)
diff --git a/tools/patman/command.py b/tools/patman/command.py
index d54b1e0..c848aa1 100644
--- a/tools/patman/command.py
+++ b/tools/patman/command.py
@@ -32,7 +32,7 @@
self.return_code = return_code
self.exception = exception
- def ToOutput(self, binary):
+ def to_output(self, binary):
if not binary:
self.stdout = self.stdout.decode('utf-8')
self.stderr = self.stderr.decode('utf-8')
@@ -43,11 +43,11 @@
# This permits interception of RunPipe for test purposes. If it is set to
# a function, then that function is called with the pipe list being
# executed. Otherwise, it is assumed to be a CommandResult object, and is
-# returned as the result for every RunPipe() call.
+# returned as the result for every run_pipe() call.
# When this value is None, commands are executed as normal.
test_result = None
-def RunPipe(pipe_list, infile=None, outfile=None,
+def run_pipe(pipe_list, infile=None, outfile=None,
capture=False, capture_stderr=False, oneline=False,
raise_on_error=True, cwd=None, binary=False,
output_func=None, **kwargs):
@@ -104,7 +104,7 @@
if raise_on_error:
raise Exception("Error running '%s': %s" % (user_pipestr, str))
result.return_code = 255
- return result.ToOutput(binary)
+ return result.to_output(binary)
if capture:
result.stdout, result.stderr, result.combined = (
@@ -116,13 +116,13 @@
result.return_code = os.waitpid(last_pipe.pid, 0)[1]
if raise_on_error and result.return_code:
raise Exception("Error running '%s'" % user_pipestr)
- return result.ToOutput(binary)
+ return result.to_output(binary)
-def Output(*cmd, **kwargs):
+def output(*cmd, **kwargs):
kwargs['raise_on_error'] = kwargs.get('raise_on_error', True)
- return RunPipe([cmd], capture=True, **kwargs).stdout
+ return run_pipe([cmd], capture=True, **kwargs).stdout
-def OutputOneLine(*cmd, **kwargs):
+def output_one_line(*cmd, **kwargs):
"""Run a command and output it as a single-line string
The command us expected to produce a single line of output
@@ -131,15 +131,15 @@
String containing output of command
"""
raise_on_error = kwargs.pop('raise_on_error', True)
- result = RunPipe([cmd], capture=True, oneline=True,
+ result = run_pipe([cmd], capture=True, oneline=True,
raise_on_error=raise_on_error, **kwargs).stdout.strip()
return result
-def Run(*cmd, **kwargs):
- return RunPipe([cmd], **kwargs).stdout
+def run(*cmd, **kwargs):
+ return run_pipe([cmd], **kwargs).stdout
-def RunList(cmd):
- return RunPipe([cmd], capture=True).stdout
+def run_list(cmd):
+ return run_pipe([cmd], capture=True).stdout
-def StopAll():
+def stop_all():
cros_subprocess.stay_alive = False
diff --git a/tools/patman/get_maintainer.py b/tools/patman/get_maintainer.py
index af4ba15..98ab82f 100644
--- a/tools/patman/get_maintainer.py
+++ b/tools/patman/get_maintainer.py
@@ -43,6 +43,6 @@
print("WARNING: Couldn't find get_maintainer.pl")
return []
- stdout = command.Output(get_maintainer, '--norolestats', fname)
+ stdout = command.output(get_maintainer, '--norolestats', fname)
lines = stdout.splitlines()
return [ x.replace('"', '') for x in lines ]
diff --git a/tools/patman/gitutil.py b/tools/patman/gitutil.py
index e1ef96d..d06f052 100644
--- a/tools/patman/gitutil.py
+++ b/tools/patman/gitutil.py
@@ -67,7 +67,7 @@
else:
rev_range = '@{upstream}..'
pipe = [LogCmd(rev_range, oneline=True)]
- result = command.RunPipe(pipe, capture=True, capture_stderr=True,
+ result = command.run_pipe(pipe, capture=True, capture_stderr=True,
oneline=True, raise_on_error=False)
if result.return_code:
raise ValueError('Failed to determine upstream: %s' %
@@ -85,7 +85,7 @@
Name of revision, if any, else None
"""
pipe = ['git', 'name-rev', commit_hash]
- stdout = command.RunPipe([pipe], capture=True, oneline=True).stdout
+ stdout = command.run_pipe([pipe], capture=True, oneline=True).stdout
# We expect a commit, a space, then a revision name
name = stdout.split(' ')[1].strip()
@@ -108,7 +108,7 @@
Warning/error message, or None if none
"""
pipe = [LogCmd(branch, git_dir=git_dir, oneline=True, count=100)]
- result = command.RunPipe(pipe, capture=True, capture_stderr=True,
+ result = command.run_pipe(pipe, capture=True, capture_stderr=True,
raise_on_error=False)
if result.return_code:
return None, "Branch '%s' not found" % branch
@@ -134,9 +134,9 @@
Warning/error message, or None if none
"""
try:
- remote = command.OutputOneLine('git', '--git-dir', git_dir, 'config',
+ remote = command.output_one_line('git', '--git-dir', git_dir, 'config',
'branch.%s.remote' % branch)
- merge = command.OutputOneLine('git', '--git-dir', git_dir, 'config',
+ merge = command.output_one_line('git', '--git-dir', git_dir, 'config',
'branch.%s.merge' % branch)
except:
upstream, msg = GuessUpstream(git_dir, branch)
@@ -179,7 +179,7 @@
were found
"""
pipe = [LogCmd(range_expr, git_dir=git_dir, oneline=True)]
- result = command.RunPipe(pipe, capture=True, capture_stderr=True,
+ result = command.run_pipe(pipe, capture=True, capture_stderr=True,
raise_on_error=False)
if result.return_code:
return None, "Range '%s' not found or is invalid" % range_expr
@@ -211,7 +211,7 @@
"""
pipe = [LogCmd(commit_range, oneline=True),
['wc', '-l']]
- stdout = command.RunPipe(pipe, capture=True, oneline=True).stdout
+ stdout = command.run_pipe(pipe, capture=True, oneline=True).stdout
patch_count = int(stdout)
return patch_count
@@ -230,7 +230,7 @@
if force:
pipe.append('-f')
pipe.append(commit_hash)
- result = command.RunPipe([pipe], capture=True, raise_on_error=False,
+ result = command.run_pipe([pipe], capture=True, raise_on_error=False,
capture_stderr=True)
if result.return_code != 0:
raise OSError('git checkout (%s): %s' % (pipe, result.stderr))
@@ -242,7 +242,7 @@
commit_hash: Commit hash to check out
"""
pipe = ['git', 'clone', git_dir, '.']
- result = command.RunPipe([pipe], capture=True, cwd=output_dir,
+ result = command.run_pipe([pipe], capture=True, cwd=output_dir,
capture_stderr=True)
if result.return_code != 0:
raise OSError('git clone: %s' % result.stderr)
@@ -259,7 +259,7 @@
if work_tree:
pipe.extend(['--work-tree', work_tree])
pipe.append('fetch')
- result = command.RunPipe([pipe], capture=True, capture_stderr=True)
+ result = command.run_pipe([pipe], capture=True, capture_stderr=True)
if result.return_code != 0:
raise OSError('git fetch: %s' % result.stderr)
@@ -273,7 +273,7 @@
True if git-worktree commands will work, False otherwise.
"""
pipe = ['git', '--git-dir', git_dir, 'worktree', 'list']
- result = command.RunPipe([pipe], capture=True, capture_stderr=True,
+ result = command.run_pipe([pipe], capture=True, capture_stderr=True,
raise_on_error=False)
return result.return_code == 0
@@ -289,7 +289,7 @@
pipe = ['git', '--git-dir', git_dir, 'worktree', 'add', '.', '--detach']
if commit_hash:
pipe.append(commit_hash)
- result = command.RunPipe([pipe], capture=True, cwd=output_dir,
+ result = command.run_pipe([pipe], capture=True, cwd=output_dir,
capture_stderr=True)
if result.return_code != 0:
raise OSError('git worktree add: %s' % result.stderr)
@@ -301,7 +301,7 @@
git_dir: The repository whose deleted worktrees should be pruned
"""
pipe = ['git', '--git-dir', git_dir, 'worktree', 'prune']
- result = command.RunPipe([pipe], capture=True, capture_stderr=True)
+ result = command.run_pipe([pipe], capture=True, capture_stderr=True)
if result.return_code != 0:
raise OSError('git worktree prune: %s' % result.stderr)
@@ -336,7 +336,7 @@
brname = branch or 'HEAD'
cmd += ['%s~%d..%s~%d' % (brname, start + count, brname, start)]
- stdout = command.RunList(cmd)
+ stdout = command.run_list(cmd)
files = stdout.splitlines()
# We have an extra file if there is a cover letter
@@ -397,7 +397,7 @@
Returns:
True if the option is configured correctly, False otherwise.
"""
- suppresscc = command.OutputOneLine('git', 'config', 'sendemail.suppresscc',
+ suppresscc = command.output_one_line('git', 'config', 'sendemail.suppresscc',
raise_on_error=False)
# Other settings should be fine.
@@ -477,7 +477,7 @@
"""
to = BuildEmailList(series.get('to'), '--to', alias, warn_on_error)
if not to:
- git_config_to = command.Output('git', 'config', 'sendemail.to',
+ git_config_to = command.output('git', 'config', 'sendemail.to',
raise_on_error=False)
if not git_config_to:
print("No recipient.\n"
@@ -606,7 +606,7 @@
os.path.join(GetTopLevel(), 'tools', 'patman')
True
"""
- return command.OutputOneLine('git', 'rev-parse', '--show-toplevel')
+ return command.output_one_line('git', 'rev-parse', '--show-toplevel')
def GetAliasFile():
"""Gets the name of the git alias file.
@@ -614,7 +614,7 @@
Returns:
Filename of git alias file, or None if none
"""
- fname = command.OutputOneLine('git', 'config', 'sendemail.aliasesfile',
+ fname = command.output_one_line('git', 'config', 'sendemail.aliasesfile',
raise_on_error=False)
if not fname:
return None
@@ -631,7 +631,7 @@
Returns:
User name found in .gitconfig file, or None if none
"""
- uname = command.OutputOneLine('git', 'config', '--global', 'user.name')
+ uname = command.output_one_line('git', 'config', '--global', 'user.name')
return uname
def GetDefaultUserEmail():
@@ -640,7 +640,7 @@
Returns:
User's email found in .gitconfig file, or None if none
"""
- uemail = command.OutputOneLine('git', 'config', '--global', 'user.email')
+ uemail = command.output_one_line('git', 'config', '--global', 'user.email')
return uemail
def GetDefaultSubjectPrefix():
@@ -649,7 +649,7 @@
Returns:
Subject prefix found in local .git/config file, or None if none
"""
- sub_prefix = command.OutputOneLine('git', 'config', 'format.subjectprefix',
+ sub_prefix = command.output_one_line('git', 'config', 'format.subjectprefix',
raise_on_error=False)
return sub_prefix
@@ -663,7 +663,7 @@
if alias_fname:
settings.ReadGitAliases(alias_fname)
cmd = LogCmd(None, count=0)
- use_no_decorate = (command.RunPipe([cmd], raise_on_error=False)
+ use_no_decorate = (command.run_pipe([cmd], raise_on_error=False)
.return_code == 0)
def GetHead():
@@ -672,7 +672,7 @@
Returns:
Hash of HEAD
"""
- return command.OutputOneLine('git', 'show', '-s', '--pretty=format:%H')
+ return command.output_one_line('git', 'show', '-s', '--pretty=format:%H')
if __name__ == "__main__":
import doctest
diff --git a/tools/patman/patchstream.py b/tools/patman/patchstream.py
index 1da9d53..d57d22a 100644
--- a/tools/patman/patchstream.py
+++ b/tools/patman/patchstream.py
@@ -700,7 +700,7 @@
"""
params = gitutil.LogCmd(commit_range, reverse=True, count=count,
git_dir=git_dir)
- return command.RunPipe([params], capture=True).stdout
+ return command.run_pipe([params], capture=True).stdout
def get_metadata_for_list(commit_range, git_dir=None, count=None,
series=None, allow_overwrite=False):
diff --git a/tools/patman/test_util.py b/tools/patman/test_util.py
index 9654e73..c3f15f8 100644
--- a/tools/patman/test_util.py
+++ b/tools/patman/test_util.py
@@ -61,7 +61,7 @@
'--omit "%s" %s %s %s -P1' % (prefix, ','.join(glob_list),
prog, extra_args or '', test_cmd))
os.system(cmd)
- stdout = command.Output('python3-coverage', 'report')
+ stdout = command.output('python3-coverage', 'report')
lines = stdout.splitlines()
if required:
# Convert '/path/to/name.py' just the module name 'name'
diff --git a/tools/patman/tools.py b/tools/patman/tools.py
index 453f2a7..35fade0 100644
--- a/tools/patman/tools.py
+++ b/tools/patman/tools.py
@@ -360,7 +360,7 @@
args = tuple(extra_args) + args
name = os.path.expanduser(name) # Expand paths containing ~
all_args = (name,) + args
- result = command.RunPipe([all_args], capture=True, capture_stderr=True,
+ result = command.run_pipe([all_args], capture=True, capture_stderr=True,
env=env, raise_on_error=False, binary=binary)
if result.return_code:
if raise_on_error:
@@ -545,7 +545,7 @@
pager = [lesspath] if lesspath else None
if not pager:
pager = ['more']
- command.Run(*pager, fname)
+ command.run(*pager, fname)
def download(url, tmpdir_pattern='.patman'):
"""Download a file to a temporary directory