summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/binpkg.py3
-rw-r--r--lib/cgroups.py2
-rw-r--r--lib/chrome_util.py1
-rw-r--r--lib/commandline.py2
-rw-r--r--lib/cros_build_lib.py26
-rw-r--r--lib/cros_test_lib.py3
-rw-r--r--lib/gerrit.py5
-rw-r--r--lib/git.py66
-rwxr-xr-xlib/gob_util.py5
-rw-r--r--lib/gs.py24
-rw-r--r--lib/locking.py18
-rw-r--r--lib/namespaces.py1
-rw-r--r--lib/operation.py1
-rw-r--r--lib/osutils.py14
-rw-r--r--lib/parallel.py2
-rw-r--r--lib/partial_mock.py9
-rw-r--r--lib/patch.py14
-rw-r--r--lib/remote_access.py7
-rwxr-xr-xlib/rewrite_git_alternates.py6
-rw-r--r--lib/stats.py10
-rwxr-xr-xlib/timeout_util_unittest.py1
-rw-r--r--lib/toolchain.py8
22 files changed, 141 insertions, 87 deletions
diff --git a/lib/binpkg.py b/lib/binpkg.py
index e2cbe0994..283788368 100644
--- a/lib/binpkg.py
+++ b/lib/binpkg.py
@@ -94,7 +94,8 @@ class PackageIndex(object):
Args:
pkgfile: A python file object.
- Returns the dictionary of key-value pairs that was read from the file.
+ Returns:
+ The dictionary of key-value pairs that was read from the file.
"""
d = {}
for line in pkgfile:
diff --git a/lib/cgroups.py b/lib/cgroups.py
index 67d08d471..b2a9505ff 100644
--- a/lib/cgroups.py
+++ b/lib/cgroups.py
@@ -428,7 +428,7 @@ class Cgroup(object):
def RemoveGroup(self, name, strict=False):
"""Removes a nested cgroup of ours
- Args
+ Args:
name: the namespace to remove.
strict: if False, remove it if possible. If True, its an error if it
cannot be removed.
diff --git a/lib/chrome_util.py b/lib/chrome_util.py
index a6e953243..1b1b153e2 100644
--- a/lib/chrome_util.py
+++ b/lib/chrome_util.py
@@ -184,6 +184,7 @@ class Copier(object):
path: A Path instance that specifies what is to be copied.
strict: If set, enforce that all optional files are copied.
sloppy: If set, ignore when mandatory artifacts are missing.
+
Returns:
A list of the artifacts copied.
"""
diff --git a/lib/commandline.py b/lib/commandline.py
index 899496301..757376dcd 100644
--- a/lib/commandline.py
+++ b/lib/commandline.py
@@ -237,9 +237,11 @@ class BaseParser(object):
"""Method called to handle post opts/args setup.
This can be anything from logging setup to positional arg count validation.
+
Args:
opts: optparse.Values instance
args: position arguments unconsumed from parsing.
+
Returns:
(opts, args), w/ whatever modification done.
"""
diff --git a/lib/cros_build_lib.py b/lib/cros_build_lib.py
index f6875d9b7..196a03704 100644
--- a/lib/cros_build_lib.py
+++ b/lib/cros_build_lib.py
@@ -107,8 +107,10 @@ def SudoRunCommand(cmd, user='root', **kwargs):
kwargs: See RunCommand options, it's a direct pass thru to it.
Note that this supports a 'strict' keyword that defaults to True.
If set to False, it'll suppress strict sudo behavior.
+
Returns:
See RunCommand documentation.
+
Raises:
This function may immediately raise RunCommandError if we're operating
in a strict sudo context and the API is being misused.
@@ -300,6 +302,7 @@ def RunCommand(cmd, print_cmd=True, error_message=None, redirect_stdout=False,
Specified in seconds.
log_output: Log the command and its output automatically.
stdout_to_pipe: Redirect stdout to pipe.
+
Returns:
A CommandResult object.
@@ -630,8 +633,10 @@ def GenericRetry(handler, max_retry, functor, *args, **kwargs):
sleep: Optional keyword. Multiplier for how long to sleep between
retries; will delay (1*sleep) the first time, then (2*sleep),
continuing via attempt * sleep.
+
Returns:
Whatever functor(*args, **kwargs) returns.
+
Raises:
Exception: Whatever exceptions functor(*args, **kwargs) throws and
isn't suppressed is raised. Note that the first exception encountered
@@ -696,8 +701,10 @@ def RetryCommand(functor, max_retry, *args, **kwargs):
signal. By default, we retry on all non-negative exit codes.
args: Positional args passed to RunCommand; see RunCommand for specifics.
kwargs: Optional args passed to RunCommand; see RunCommand for specifics.
+
Returns:
A CommandResult object.
+
Raises:
Exception: Raises RunCommandError on error with optional error_message.
"""
@@ -729,8 +736,10 @@ def RunCommandWithRetries(max_retry, *args, **kwargs):
Args:
See RetryCommand and RunCommand; This is just a wrapper around it.
+
Returns:
A CommandResult object.
+
Raises:
Exception: Raises RunCommandError on error with optional error_message.
"""
@@ -804,8 +813,10 @@ def FindCompressor(compression, chroot=None):
Args:
compression: The type of compression desired.
chroot: Optional path to a chroot to search.
+
Returns:
Path to a compressor.
+
Raises:
ValueError: If compression is unknown.
"""
@@ -883,6 +894,7 @@ def BooleanPrompt(prompt="Do you want to continue?", default=True,
default: Boolean to return if the user just presses enter.
true_value: The text to display that represents a True returned.
false_value: The text to display that represents a False returned.
+
Returns:
True or False.
"""
@@ -928,8 +940,10 @@ def BooleanShellValue(sval, default, msg=None):
default: If we can't figure out if the value is true or false, use this.
msg: If |sval| is an unknown value, use |msg| to warn the user that we
could not decode the input. Otherwise, raise ValueError().
+
Returns:
The interpreted boolean value of |sval|.
+
Raises:
ValueError() if |sval| is an unknown value and |msg| is not set.
"""
@@ -1144,10 +1158,11 @@ def GetTargetChromiteApiVersion(buildroot, validate_version=True):
compatibility, and raises an ApiMismatchError when there is an
incompatibility.
+ Returns:
+ The version number in (major, minor) tuple.
+
Raises:
May raise an ApiMismatchError if validate_version is set.
-
- Returns the version number in (major, minor) tuple.
"""
try:
api = RunCommandCaptureOutput(
@@ -1217,11 +1232,11 @@ def load_module(name):
Args:
name: python dotted namespace path of the module to import
- Raises:
- FailedImport if importing fails
-
Returns:
imported module
+
+ Raises:
+ FailedImport if importing fails
"""
m = __import__(name)
# __import__('foo.bar') returns foo, so...
@@ -1392,6 +1407,7 @@ def UserDateTimeFormat(timeval=None):
Args:
timeval: Either a datetime object or a floating point time value as accepted
by gmtime()/localtime(). If None, the current time is used.
+
Returns:
A string format such as 'Wed, 20 Feb 2013 15:25:15 -0500 (EST)'
"""
diff --git a/lib/cros_test_lib.py b/lib/cros_test_lib.py
index 728fcb3d8..f1b84baff 100644
--- a/lib/cros_test_lib.py
+++ b/lib/cros_test_lib.py
@@ -366,6 +366,7 @@ class TruthTable(object):
Args:
inputs_index: Following must hold: 0 <= inputs_index < self.num_lines.
+
Returns:
Tuple of bools representing one line of inputs.
"""
@@ -388,6 +389,7 @@ class TruthTable(object):
Args:
inputs: Tuple of bools, length must be equal to self.dimension.
+
Returns:
bool value representing truth table output for given inputs.
"""
@@ -1614,6 +1616,7 @@ def FindTests(directory, module_namespace=''):
Args:
directory: The directory to scan for tests.
module_namespace: What namespace to prefix all found tests with.
+
Returns:
A list of python unittests in python namespace form.
"""
diff --git a/lib/gerrit.py b/lib/gerrit.py
index 34233793e..14d6a75f9 100644
--- a/lib/gerrit.py
+++ b/lib/gerrit.py
@@ -179,7 +179,8 @@ class GerritHelper(object):
kwargs: A dict of query parameters, as described here:
https://gerrit-review.googlesource.com/Documentation/rest-api-changes.html#list-changes
- Returns: A list of python dicts or cros_patch.GerritChange.
+ Returns:
+ A list of python dicts or cros_patch.GerritChange.
"""
query_kwds = kwargs
if options:
@@ -248,6 +249,7 @@ class GerritHelper(object):
Args:
changes: A sequence of gerrit change numbers.
+
Returns:
A list of cros_patch.GerritPatch.
"""
@@ -414,6 +416,7 @@ def GetChangeRef(change_number, patchset=None):
patchset: If given it must either be an integer or '*'. When given,
the returned refspec is for that exact patchset. If '*' is given, it's
used for pulling down all patchsets for that change.
+
Returns:
A git refspec.
"""
diff --git a/lib/git.py b/lib/git.py
index 5fda770af..f77f6e376 100644
--- a/lib/git.py
+++ b/lib/git.py
@@ -469,6 +469,7 @@ class ManifestCheckout(Manifest):
search: If True, the path can point into the repo, and the root will
be found automatically. If False, the path *must* be the root, else
an OSError ENOENT will be thrown.
+
Raises:
OSError: if a failure occurs.
"""
@@ -511,6 +512,7 @@ class ManifestCheckout(Manifest):
Returns:
True if content merging is enabled.
+
Raises:
RunCommandError: If the branch can't be fetched due to network
conditions or if this was invoked against a <gerrit-2.2 server,
@@ -546,12 +548,12 @@ class ManifestCheckout(Manifest):
branch: The branch that the project is tracking.
strict: Raise AssertionError if a checkout cannot be found.
+ Returns:
+ A ProjectCheckout object.
+
Raises:
AssertionError if there is more than one checkout associated with the
given project/branch combination.
-
- Returns:
- A ProjectCheckout object.
"""
checkouts = self.FindCheckouts(project, branch)
if len(checkouts) < 1:
@@ -583,7 +585,8 @@ class ManifestCheckout(Manifest):
strict: If True, fail when no checkout is found.
Returns:
- None if no checkout is found, else the checkout."""
+ None if no checkout is found, else the checkout.
+ """
# Realpath everything sans the target to keep people happy about
# how symlinks are handled; exempt the final node since following
# through that is unlikely even remotely desired.
@@ -711,6 +714,7 @@ def _GitRepoIsContentMerging(git_repo, remote):
Returns:
True if content merging is enabled, False if not.
+
Raises:
RunCommandError: Thrown if fetching fails due to either the namespace
not existing, or a network error intervening.
@@ -753,6 +757,7 @@ def RunGit(git_repo, cmd, retry=True, **kwargs):
this would be ['remote', 'update'] for example.
retry: If set, retry on transient errors. Defaults to True.
kwargs: Any RunCommand or GenericRetry options/overrides to use.
+
Returns:
A CommandResult object.
"""
@@ -790,6 +795,7 @@ def MatchBranchName(git_repo, pattern, namespace=''):
git_repo: The git repository to operate upon.
pattern: The regexp to search with.
namespace: The namespace to restrict search to (e.g. 'refs/heads/').
+
Returns:
List of matching branch names (with |namespace| trimmed).
"""
@@ -809,8 +815,10 @@ def MatchSingleBranchName(*args, **kwargs):
Args:
See MatchBranchName for more details; all args are passed on.
+
Returns:
The branch name.
+
Raises:
raise AmbiguousBranchName if we did not match exactly one branch.
"""
@@ -1038,14 +1046,14 @@ def GitPush(git_repo, refspec, push_to, dryrun=False, force=False, retry=True):
def CreatePushBranch(branch, git_repo, sync=True, remote_push_branch=None):
"""Create a local branch for pushing changes inside a repo repository.
- Args:
- branch: Local branch to create.
- git_repo: Git repository to create the branch in.
- sync: Update remote before creating push branch.
- remote_push_branch: A tuple of the (remote, branch) to push to. i.e.,
- ('cros', 'master'). By default it tries to
- automatically determine which tracking branch to use
- (see GetTrackingBranch()).
+ Args:
+ branch: Local branch to create.
+ git_repo: Git repository to create the branch in.
+ sync: Update remote before creating push branch.
+ remote_push_branch: A tuple of the (remote, branch) to push to. i.e.,
+ ('cros', 'master'). By default it tries to
+ automatically determine which tracking branch to use
+ (see GetTrackingBranch()).
"""
if not remote_push_branch:
remote, push_branch = GetTrackingBranch(git_repo, for_push=True)
@@ -1062,12 +1070,12 @@ def CreatePushBranch(branch, git_repo, sync=True, remote_push_branch=None):
def SyncPushBranch(git_repo, remote, rebase_target):
"""Sync and rebase a local push branch to the latest remote version.
- Args:
- git_repo: Git repository to rebase in.
- remote: The remote returned by GetTrackingBranch(for_push=True)
- rebase_target: The branch name returned by GetTrackingBranch(). Must
- start with refs/remotes/ (specifically must be a proper remote
- target rather than an ambiguous name).
+ Args:
+ git_repo: Git repository to rebase in.
+ remote: The remote returned by GetTrackingBranch(for_push=True)
+ rebase_target: The branch name returned by GetTrackingBranch(). Must
+ start with refs/remotes/ (specifically must be a proper remote
+ target rather than an ambiguous name).
"""
if not rebase_target.startswith("refs/remotes/"):
raise Exception(
@@ -1091,19 +1099,19 @@ def SyncPushBranch(git_repo, remote, rebase_target):
def PushWithRetry(branch, git_repo, dryrun=False, retries=5):
"""General method to push local git changes.
- This method only works with branches created via the CreatePushBranch
- function.
+ This method only works with branches created via the CreatePushBranch
+ function.
- Args:
- branch: Local branch to push. Branch should have already been created
- with a local change committed ready to push to the remote branch. Must
- also already be checked out to that branch.
- git_repo: Git repository to push from.
- dryrun: Git push --dry-run if set to True.
- retries: The number of times to retry before giving up, default: 5
+ Args:
+ branch: Local branch to push. Branch should have already been created
+ with a local change committed ready to push to the remote branch. Must
+ also already be checked out to that branch.
+ git_repo: Git repository to push from.
+ dryrun: Git push --dry-run if set to True.
+ retries: The number of times to retry before giving up, default: 5
- Raises:
- GitPushFailed if push was unsuccessful after retries
+ Raises:
+ GitPushFailed if push was unsuccessful after retries
"""
remote, ref = GetTrackingBranch(git_repo, branch, for_checkout=False,
for_push=True)
diff --git a/lib/gob_util.py b/lib/gob_util.py
index 145f04fa7..97a99a94c 100755
--- a/lib/gob_util.py
+++ b/lib/gob_util.py
@@ -89,6 +89,7 @@ def ReadHttpResponse(conn, ignore_404=True):
ignore_404: For many requests, gerrit-on-borg will return 404 if the request
doesn't match the database contents. In most such cases, we
want the API to return None rather than raise an Exception.
+
Returns:
A string buffer containing the connection's reply.
"""
@@ -140,8 +141,7 @@ def ReadHttpJsonResponse(conn, ignore_404=True):
def QueryChanges(host, param_dict, first_param=None, limit=None, o_params=None,
sortkey=None):
- """
- Queries a gerrit-on-borg server for changes matching query terms.
+ """Queries a gerrit-on-borg server for changes matching query terms.
Args:
param_dict: A dictionary of search parameters, as documented here:
@@ -150,6 +150,7 @@ def QueryChanges(host, param_dict, first_param=None, limit=None, o_params=None,
limit: Maximum number of results to return.
o_params: A list of additional output specifiers, as documented here:
https://gerrit-review.googlesource.com/Documentation/rest-api-changes.html#list-changes
+
Returns:
A list of json-decoded query results.
"""
diff --git a/lib/gs.py b/lib/gs.py
index 5e614951b..e1bfe9893 100644
--- a/lib/gs.py
+++ b/lib/gs.py
@@ -51,6 +51,7 @@ def GetGsURL(bucket, for_gsutil=False, public=True, suburl=''):
for_gsutil: Do you want a URL for passing to `gsutil`?
public: Do we want the public or private url
suburl: A url fragment to tack onto the end
+
Returns:
The fully constructed URL
"""
@@ -101,6 +102,7 @@ class GSCounter(object):
does not exist.
operation: Function that takes the current counter value as a
parameter, and returns the new desired value.
+
Returns:
The new counter value. None if value could not be set.
"""
@@ -132,28 +134,32 @@ class GSCounter(object):
"""Decrement the counter.
Returns:
- The new counter value. None if value could not be set."""
+ The new counter value. None if value could not be set.
+ """
return self.AtomicCounterOperation(-1, lambda x: x - 1)
def Reset(self):
"""Reset the counter to zero.
Returns:
- The new counter value. None if value could not be set."""
+ The new counter value. None if value could not be set.
+ """
return self.AtomicCounterOperation(0, lambda x: 0)
def StreakIncrement(self):
"""Increment the counter if it is positive, otherwise set it to 1.
Returns:
- The new counter value. None if value could not be set."""
+ The new counter value. None if value could not be set.
+ """
return self.AtomicCounterOperation(1, lambda x: x + 1 if x > 0 else 1)
def StreakDecrement(self):
"""Decrement the counter if it is negative, otherwise set it to -1.
Returns:
- The new counter value. None if value could not be set."""
+ The new counter value. None if value could not be set.
+ """
return self.AtomicCounterOperation(-1, lambda x: x - 1 if x < 0 else -1)
@@ -360,6 +366,7 @@ class GSContext(object):
Args:
dest_path: either a GS path or an absolute local path.
+
Returns:
The list of potential tracker filenames.
"""
@@ -392,6 +399,7 @@ class GSContext(object):
e: Exception object to filter. Exception may be re-raised as
as different type, if _RetryFilter determines a more appropriate
exception type based on the contents of e.
+
Returns:
True for exceptions thrown by a RunCommand gsutil that should be retried.
"""
@@ -509,10 +517,11 @@ class GSContext(object):
to ensure you don't overwrite someone else's creation, a version of
0 states "only update if no version exists".
- Raises:
- RunCommandError if the command failed despite retries.
Returns:
Return the CommandResult from the run.
+
+ Raises:
+ RunCommandError if the command failed despite retries.
"""
cmd, headers = [], []
@@ -596,7 +605,8 @@ class GSContext(object):
def GetGeneration(self, path):
"""Get the generation and metageneration of the given |path|.
- Returns a tuple of the generation and metageneration.
+ Returns:
+ A tuple of the generation and metageneration.
"""
def _Header(name):
if res and res.returncode == 0 and res.output is not None:
diff --git a/lib/locking.py b/lib/locking.py
index 74ebd4de4..ec51b87c6 100644
--- a/lib/locking.py
+++ b/lib/locking.py
@@ -66,13 +66,14 @@ class _Lock(cros_build_lib.MasterPidContextManager):
fcntl.lockf(self.fd, flags)
def read_lock(self, message="taking read lock"):
- """
- Take a read lock (shared), downgrading from write if required.
+ """Take a read lock (shared), downgrading from write if required.
Args:
message: A description of what/why this lock is being taken.
+
Returns:
self, allowing it to be used as a `with` target.
+
Raises:
IOError if the operation fails in some way.
"""
@@ -80,8 +81,7 @@ class _Lock(cros_build_lib.MasterPidContextManager):
return self
def write_lock(self, message="taking write lock"):
- """
- Take a write lock (exclusive), upgrading from read if required.
+ """Take a write lock (exclusive), upgrading from read if required.
Note that if the lock state is being upgraded from read to write,
a deadlock potential exists- as such we *will* release the lock
@@ -91,8 +91,10 @@ class _Lock(cros_build_lib.MasterPidContextManager):
Args:
message: A description of what/why this lock is being taken.
+
Returns:
self, allowing it to be used as a `with` target.
+
Raises:
IOError if the operation fails in some way.
"""
@@ -100,8 +102,7 @@ class _Lock(cros_build_lib.MasterPidContextManager):
return self
def unlock(self):
- """
- Release any locks held. Noop if no locks are held.
+ """Release any locks held. Noop if no locks are held.
Raises:
IOError if the operation fails in some way.
@@ -115,9 +116,7 @@ class _Lock(cros_build_lib.MasterPidContextManager):
self.close()
def close(self):
- """
- Release the underlying lock and close the fd.
- """
+ """Release the underlying lock and close the fd."""
if self._fd is not None:
self.unlock()
os.close(self._fd)
@@ -168,7 +167,6 @@ class FileLock(_Lock):
class ProcessLock(_Lock):
-
"""Process level locking visible to parent/child only.
This lock is basically a more robust version of what
diff --git a/lib/namespaces.py b/lib/namespaces.py
index d09fb89fe..b16958620 100644
--- a/lib/namespaces.py
+++ b/lib/namespaces.py
@@ -24,6 +24,7 @@ def Unshare(flags):
Args:
flags: Namespaces to unshare; bitwise OR of CLONE_* flags.
+
Raises:
OSError: if unshare failed.
"""
diff --git a/lib/operation.py b/lib/operation.py
index eda6851ea..2ef7d057e 100644
--- a/lib/operation.py
+++ b/lib/operation.py
@@ -406,7 +406,6 @@ class Operation:
Args:
request: True to request verbose mode if available, False to do nothing.
-
"""
old_verbose = self.verbose
if request and not self.explicit_verbose:
diff --git a/lib/osutils.py b/lib/osutils.py
index d47dd3c75..a2650f5cd 100644
--- a/lib/osutils.py
+++ b/lib/osutils.py
@@ -27,7 +27,7 @@ def GetNonRootUser():
ran the emerge command. If running using sudo, returns the username
of the person who ran the sudo command. If no non-root user is
found, returns None.
-"""
+ """
uid = os.getuid()
if uid == 0:
user = os.environ.get('PORTAGE_USERNAME', os.environ.get('SUDO_USER'))
@@ -106,7 +106,8 @@ def ReadFile(path, mode='r'):
def SafeUnlink(path, sudo=False):
"""Unlink a file from disk, ignoring if it doesn't exist.
- Returns True if the file existed and was removed, False if it didn't exist.
+ Returns:
+ True if the file existed and was removed, False if it didn't exist.
"""
if sudo:
try:
@@ -136,12 +137,13 @@ def SafeMakedirs(path, mode=0o775, sudo=False, user='root'):
mode: The access permissions in the style of chmod.
sudo: If True, create it via sudo, thus root owned.
user: If |sudo| is True, run sudo as |user|.
- Raises:
- EnvironmentError: if the makedir failed and it was non sudo.
- RunCommandError: If sudo mode, and the command failed for any reason.
Returns:
True if the directory had to be created, False if otherwise.
+
+ Raises:
+ EnvironmentError: if the makedir failed and it was non sudo.
+ RunCommandError: If sudo mode, and the command failed for any reason.
"""
if sudo:
if os.path.isdir(path):
@@ -222,6 +224,7 @@ def Which(binary, path=None, mode=os.X_OK):
binary: The binary to look for.
path: Search path. Defaults to os.environ['PATH'].
mode: File mode to check on the binary.
+
Returns:
The full path to |binary| if found (with the right mode). Otherwise, None.
"""
@@ -601,6 +604,7 @@ def StrSignal(sig_num):
Args:
sig_num: The numeric signal you wish to convert
+
Returns:
A string of the signal name(s)
"""
diff --git a/lib/parallel.py b/lib/parallel.py
index 4c433daeb..77db90116 100644
--- a/lib/parallel.py
+++ b/lib/parallel.py
@@ -526,7 +526,7 @@ def RunParallelSteps(steps, max_parallel=None, halt_on_error=False,
# Blocks until all calls have completed.
"""
def ReturnWrapper(queue, fn):
- """A function that """
+ """Put the return value of |fn| into |queue|."""
queue.put(fn())
full_steps = []
diff --git a/lib/partial_mock.py b/lib/partial_mock.py
index c8c179b4d..23f0dc2e2 100644
--- a/lib/partial_mock.py
+++ b/lib/partial_mock.py
@@ -256,10 +256,11 @@ class MockedCallResults(object):
def LookupResult(self, args, kwargs=None, hook_args=None, hook_kwargs=None):
"""For a given mocked function call lookup the recorded internal results.
- args: A list containing positional args the function was called with.
- kwargs: A dict containing keyword args the function was called with.
- hook_args: A list of positional args to call the hook with.
- hook_kwargs: A dict of key/value args to call the hook with.
+ Args:
+ args: A list containing positional args the function was called with.
+ kwargs: A dict containing keyword args the function was called with.
+ hook_args: A list of positional args to call the hook with.
+ hook_kwargs: A dict of key/value args to call the hook with.
Returns:
The recorded result for the invocation.
diff --git a/lib/patch.py b/lib/patch.py
index 16f43a1fa..59fb0f9fc 100644
--- a/lib/patch.py
+++ b/lib/patch.py
@@ -546,6 +546,7 @@ class GitRepoPatch(object):
Args:
git_repo: The git repository to fetch this patch into.
+
Returns:
The sha1 of the patch.
"""
@@ -609,7 +610,8 @@ class GitRepoPatch(object):
Args:
git_repo: Git repository to operate upon.
- returns: A dictionary of path -> modification_type tuples. See
+ Returns:
+ A dictionary of path -> modification_type tuples. See
`git log --help`, specifically the --diff-filter section for details.
"""
@@ -903,14 +905,14 @@ class GitRepoPatch(object):
def GetCheckout(self, manifest, strict=True):
"""Get the ProjectCheckout associated with this patch.
- Raises:
- ChangeMatchesMultipleCheckouts if there are multiple checkouts that
- match this change.
-
Args:
manifest: A ManifestCheckout object.
strict: If the change refers to a project/branch that is not in the
manifest, raise a ChangeNotInManifest error.
+
+ Raises:
+ ChangeMatchesMultipleCheckouts if there are multiple checkouts that
+ match this change.
"""
checkouts = manifest.FindCheckouts(self.project, self.tracking_branch)
if len(checkouts) != 1:
@@ -1020,6 +1022,7 @@ class LocalPatch(GitRepoPatch):
dryrun: Do the git push with --dry-run
reviewers: Iterable of reviewers to add.
cc: Iterable of people to add to cc.
+
Returns:
A list of gerrit URLs found in the output
"""
@@ -1271,6 +1274,7 @@ class GerritPatch(GitRepoPatch):
Args:
field: Which field to check ('VRIF', 'CRVW', ...).
+
Returns:
Most recent field value (as str) or '0' if no such field.
"""
diff --git a/lib/remote_access.py b/lib/remote_access.py
index d37c37f0a..6ab8c2748 100644
--- a/lib/remote_access.py
+++ b/lib/remote_access.py
@@ -94,15 +94,16 @@ class RemoteAccess(object):
See ssh_error_ok.
ssh_error_ok: Does not throw an exception when the ssh command itself
fails (return code 255).
- debug_level: See cros_build_lib.RunCommand documentation.
+ debug_level: See cros_build_lib.RunCommand documentation.
Returns:
A CommandResult object. The returncode is the returncode of the command,
or 255 if ssh encountered an error (could not connect, connection
interrupted, etc.)
- Raises: RunCommandError when error is not ignored through error_code_ok and
- ssh_error_ok flags.
+ Raises:
+ RunCommandError when error is not ignored through error_code_ok and
+ ssh_error_ok flags.
"""
if not debug_level:
debug_level = self.debug_level
diff --git a/lib/rewrite_git_alternates.py b/lib/rewrite_git_alternates.py
index 583c8ef7c..80d26466a 100755
--- a/lib/rewrite_git_alternates.py
+++ b/lib/rewrite_git_alternates.py
@@ -175,8 +175,7 @@ def _RebuildRepoCheckout(target_root, reference_map,
def WalkReferences(repo_root, max_depth=5, suppress=()):
- """
- Given a repo checkout root, find the repo's it references up to max_depth
+ """Given a repo checkout root, find the repo's it references up to max_depth.
Args:
repo_root: The root of a repo checkout to start from
@@ -222,8 +221,7 @@ def WalkReferences(repo_root, max_depth=5, suppress=()):
def RebuildRepoCheckout(repo_root, initial_reference,
chroot_reference_root=None):
- """
- Rebuild a repo checkouts ondisk 'alternate tree' rewriting the repo to use it
+ """Rebuild a repo checkout's 'alternate tree' rewriting the repo to use it
Args:
repo_root: absolute path to the root of a repository checkout
diff --git a/lib/stats.py b/lib/stats.py
index 63a5f4f5d..8eb5325b4 100644
--- a/lib/stats.py
+++ b/lib/stats.py
@@ -144,12 +144,12 @@ class StatsUploader(object):
def Upload(cls, stats, url=None, timeout=None):
"""Upload |stats| to |url|.
- Does nothing if upload conditions aren't met.
+ Does nothing if upload conditions aren't met.
- Args:
- stats: A Stats object to upload.
- url: The url to send the request to.
- timeout: A timeout value to set, in seconds.
+ Args:
+ stats: A Stats object to upload.
+ url: The url to send the request to.
+ timeout: A timeout value to set, in seconds.
"""
if url is None:
url = cls.URL
diff --git a/lib/timeout_util_unittest.py b/lib/timeout_util_unittest.py
index 96966d446..16c8dc65f 100755
--- a/lib/timeout_util_unittest.py
+++ b/lib/timeout_util_unittest.py
@@ -162,7 +162,6 @@ class TestTreeStatus(cros_test_lib.MoxTestCase):
"""Mocks out urllib.urlopen commands to simulate a given tree status.
Args:
-
status_url: The status url that status will be fetched from.
final_tree_status: The final value of tree status that will be returned
by urlopen.
diff --git a/lib/toolchain.py b/lib/toolchain.py
index 679a12580..f239271f3 100644
--- a/lib/toolchain.py
+++ b/lib/toolchain.py
@@ -71,7 +71,8 @@ def GetTuplesForOverlays(overlays):
def GetAllTargets():
"""Get the complete list of targets.
- returns the list of cross targets for the current tree
+ Returns:
+ The list of cross targets for the current tree
"""
targets = GetToolchainsForBoard('all')
@@ -83,7 +84,8 @@ def GetAllTargets():
def GetToolchainsForBoard(board, buildroot=constants.SOURCE_ROOT):
"""Get a list of toolchain tuples for a given board name
- returns the list of toolchain tuples for the given board
+ Returns:
+ The list of toolchain tuples for the given board
"""
overlays = portage_utilities.FindOverlays(
constants.BOTH_OVERLAYS, None if board in ('all', 'sdk') else board,
@@ -101,6 +103,7 @@ def FilterToolchains(targets, key, value):
targets: dict of toolchains
key: metadata to examine
value: expected value for metadata
+
Returns:
dict where all targets whose metadata |key| does not match |value|
have been deleted
@@ -114,6 +117,7 @@ def GetSdkURL(for_gsutil=False, suburl=''):
Args:
for_gsutil: Do you want a URL for passing to `gsutil`?
suburl: A url fragment to tack onto the end
+
Returns:
The fully constructed URL
"""