mirror of
https://gerrit.googlesource.com/git-repo
synced 2024-12-21 07:16:21 +00:00
command.py: Cleaned up pylint/pep8 violations
I noticed when running pylint (as the SUBMITTING_PATCHES file directs) that there were a few violations reported. This makes it difficult to see violations I might have introduced. This commit corrects all pylint violations in the command.py script. This script now has a pylint score of 10.0. Change-Id: Ibb35fa9af0e0b9b40e02ae043682b3af23286748
This commit is contained in:
parent
30b0f4e022
commit
8ccfa74d12
28
command.py
28
command.py
@ -31,7 +31,7 @@ class Command(object):
|
|||||||
manifest = None
|
manifest = None
|
||||||
_optparse = None
|
_optparse = None
|
||||||
|
|
||||||
def WantPager(self, opt):
|
def WantPager(self, _opt):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def ReadEnvironmentOptions(self, opts):
|
def ReadEnvironmentOptions(self, opts):
|
||||||
@ -63,7 +63,7 @@ class Command(object):
|
|||||||
usage = self.helpUsage.strip().replace('%prog', me)
|
usage = self.helpUsage.strip().replace('%prog', me)
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
usage = 'repo %s' % self.NAME
|
usage = 'repo %s' % self.NAME
|
||||||
self._optparse = optparse.OptionParser(usage = usage)
|
self._optparse = optparse.OptionParser(usage=usage)
|
||||||
self._Options(self._optparse)
|
self._Options(self._optparse)
|
||||||
return self._optparse
|
return self._optparse
|
||||||
|
|
||||||
@ -110,9 +110,9 @@ class Command(object):
|
|||||||
project = None
|
project = None
|
||||||
if os.path.exists(path):
|
if os.path.exists(path):
|
||||||
oldpath = None
|
oldpath = None
|
||||||
while path \
|
while path and \
|
||||||
and path != oldpath \
|
path != oldpath and \
|
||||||
and path != manifest.topdir:
|
path != manifest.topdir:
|
||||||
try:
|
try:
|
||||||
project = self._by_path[path]
|
project = self._by_path[path]
|
||||||
break
|
break
|
||||||
@ -138,7 +138,7 @@ class Command(object):
|
|||||||
mp = manifest.manifestProject
|
mp = manifest.manifestProject
|
||||||
|
|
||||||
if not groups:
|
if not groups:
|
||||||
groups = mp.config.GetString('manifest.groups')
|
groups = mp.config.GetString('manifest.groups')
|
||||||
if not groups:
|
if not groups:
|
||||||
groups = 'default,platform-' + platform.system().lower()
|
groups = 'default,platform-' + platform.system().lower()
|
||||||
groups = [x for x in re.split(r'[,\s]+', groups) if x]
|
groups = [x for x in re.split(r'[,\s]+', groups) if x]
|
||||||
@ -151,8 +151,7 @@ class Command(object):
|
|||||||
for p in project.GetDerivedSubprojects())
|
for p in project.GetDerivedSubprojects())
|
||||||
all_projects_list.extend(derived_projects.values())
|
all_projects_list.extend(derived_projects.values())
|
||||||
for project in all_projects_list:
|
for project in all_projects_list:
|
||||||
if ((missing_ok or project.Exists) and
|
if (missing_ok or project.Exists) and project.MatchesGroups(groups):
|
||||||
project.MatchesGroups(groups)):
|
|
||||||
result.append(project)
|
result.append(project)
|
||||||
else:
|
else:
|
||||||
self._ResetPathToProjectMap(all_projects_list)
|
self._ResetPathToProjectMap(all_projects_list)
|
||||||
@ -166,8 +165,8 @@ class Command(object):
|
|||||||
|
|
||||||
# If it's not a derived project, update path->project mapping and
|
# If it's not a derived project, update path->project mapping and
|
||||||
# search again, as arg might actually point to a derived subproject.
|
# search again, as arg might actually point to a derived subproject.
|
||||||
if (project and not project.Derived and
|
if (project and not project.Derived and (submodules_ok or
|
||||||
(submodules_ok or project.sync_s)):
|
project.sync_s)):
|
||||||
search_again = False
|
search_again = False
|
||||||
for subproject in project.GetDerivedSubprojects():
|
for subproject in project.GetDerivedSubprojects():
|
||||||
self._UpdatePathToProjectMap(subproject)
|
self._UpdatePathToProjectMap(subproject)
|
||||||
@ -205,6 +204,7 @@ class Command(object):
|
|||||||
result.sort(key=lambda project: project.relpath)
|
result.sort(key=lambda project: project.relpath)
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
# pylint: disable=W0223
|
# pylint: disable=W0223
|
||||||
# Pylint warns that the `InteractiveCommand` and `PagedCommand` classes do not
|
# Pylint warns that the `InteractiveCommand` and `PagedCommand` classes do not
|
||||||
# override method `Execute` which is abstract in `Command`. Since that method
|
# override method `Execute` which is abstract in `Command`. Since that method
|
||||||
@ -214,28 +214,32 @@ class InteractiveCommand(Command):
|
|||||||
"""Command which requires user interaction on the tty and
|
"""Command which requires user interaction on the tty and
|
||||||
must not run within a pager, even if the user asks to.
|
must not run within a pager, even if the user asks to.
|
||||||
"""
|
"""
|
||||||
def WantPager(self, opt):
|
def WantPager(self, _opt):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
class PagedCommand(Command):
|
class PagedCommand(Command):
|
||||||
"""Command which defaults to output in a pager, as its
|
"""Command which defaults to output in a pager, as its
|
||||||
display tends to be larger than one screen full.
|
display tends to be larger than one screen full.
|
||||||
"""
|
"""
|
||||||
def WantPager(self, opt):
|
def WantPager(self, _opt):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
# pylint: enable=W0223
|
# pylint: enable=W0223
|
||||||
|
|
||||||
|
|
||||||
class MirrorSafeCommand(object):
|
class MirrorSafeCommand(object):
|
||||||
"""Command permits itself to run within a mirror,
|
"""Command permits itself to run within a mirror,
|
||||||
and does not require a working directory.
|
and does not require a working directory.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
class GitcAvailableCommand(object):
|
class GitcAvailableCommand(object):
|
||||||
"""Command that requires GITC to be available, but does
|
"""Command that requires GITC to be available, but does
|
||||||
not require the local client to be a GITC client.
|
not require the local client to be a GITC client.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
class GitcClientCommand(object):
|
class GitcClientCommand(object):
|
||||||
"""Command that requires the local client to be a GITC
|
"""Command that requires the local client to be a GITC
|
||||||
client.
|
client.
|
||||||
|
Loading…
Reference in New Issue
Block a user