diff options
author | Mark E. Hamilton <mhamilt@sandia.gov> | 2016-02-10 10:44:30 -0700 |
---|---|---|
committer | Mark E. Hamilton <mhamilt@sandia.gov> | 2016-03-02 09:05:45 -0700 |
commit | 8ccfa74d121efcdc0bcc3d41e8a881aacdab93dc (patch) | |
tree | ae7076d782385b46c88077da0ffeb78274583b6a /command.py | |
parent | 30b0f4e02239afa1bc9b84f7e8180aa94e4cffa6 (diff) | |
download | git-repo-8ccfa74d121efcdc0bcc3d41e8a881aacdab93dc.tar.gz |
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
Diffstat (limited to 'command.py')
-rw-r--r-- | command.py | 28 |
1 files changed, 16 insertions, 12 deletions
@@ -31,7 +31,7 @@ class Command(object): | |||
31 | manifest = None | 31 | manifest = None |
32 | _optparse = None | 32 | _optparse = None |
33 | 33 | ||
34 | def WantPager(self, opt): | 34 | def WantPager(self, _opt): |
35 | return False | 35 | return False |
36 | 36 | ||
37 | def ReadEnvironmentOptions(self, opts): | 37 | def ReadEnvironmentOptions(self, opts): |
@@ -63,7 +63,7 @@ class Command(object): | |||
63 | usage = self.helpUsage.strip().replace('%prog', me) | 63 | usage = self.helpUsage.strip().replace('%prog', me) |
64 | except AttributeError: | 64 | except AttributeError: |
65 | usage = 'repo %s' % self.NAME | 65 | usage = 'repo %s' % self.NAME |
66 | self._optparse = optparse.OptionParser(usage = usage) | 66 | self._optparse = optparse.OptionParser(usage=usage) |
67 | self._Options(self._optparse) | 67 | self._Options(self._optparse) |
68 | return self._optparse | 68 | return self._optparse |
69 | 69 | ||
@@ -110,9 +110,9 @@ class Command(object): | |||
110 | project = None | 110 | project = None |
111 | if os.path.exists(path): | 111 | if os.path.exists(path): |
112 | oldpath = None | 112 | oldpath = None |
113 | while path \ | 113 | while path and \ |
114 | and path != oldpath \ | 114 | path != oldpath and \ |
115 | and path != manifest.topdir: | 115 | path != manifest.topdir: |
116 | try: | 116 | try: |
117 | project = self._by_path[path] | 117 | project = self._by_path[path] |
118 | break | 118 | break |
@@ -138,7 +138,7 @@ class Command(object): | |||
138 | mp = manifest.manifestProject | 138 | mp = manifest.manifestProject |
139 | 139 | ||
140 | if not groups: | 140 | if not groups: |
141 | groups = mp.config.GetString('manifest.groups') | 141 | groups = mp.config.GetString('manifest.groups') |
142 | if not groups: | 142 | if not groups: |
143 | groups = 'default,platform-' + platform.system().lower() | 143 | groups = 'default,platform-' + platform.system().lower() |
144 | groups = [x for x in re.split(r'[,\s]+', groups) if x] | 144 | groups = [x for x in re.split(r'[,\s]+', groups) if x] |
@@ -151,8 +151,7 @@ class Command(object): | |||
151 | for p in project.GetDerivedSubprojects()) | 151 | for p in project.GetDerivedSubprojects()) |
152 | all_projects_list.extend(derived_projects.values()) | 152 | all_projects_list.extend(derived_projects.values()) |
153 | for project in all_projects_list: | 153 | for project in all_projects_list: |
154 | if ((missing_ok or project.Exists) and | 154 | if (missing_ok or project.Exists) and project.MatchesGroups(groups): |
155 | project.MatchesGroups(groups)): | ||
156 | result.append(project) | 155 | result.append(project) |
157 | else: | 156 | else: |
158 | self._ResetPathToProjectMap(all_projects_list) | 157 | self._ResetPathToProjectMap(all_projects_list) |
@@ -166,8 +165,8 @@ class Command(object): | |||
166 | 165 | ||
167 | # If it's not a derived project, update path->project mapping and | 166 | # If it's not a derived project, update path->project mapping and |
168 | # search again, as arg might actually point to a derived subproject. | 167 | # search again, as arg might actually point to a derived subproject. |
169 | if (project and not project.Derived and | 168 | if (project and not project.Derived and (submodules_ok or |
170 | (submodules_ok or project.sync_s)): | 169 | project.sync_s)): |
171 | search_again = False | 170 | search_again = False |
172 | for subproject in project.GetDerivedSubprojects(): | 171 | for subproject in project.GetDerivedSubprojects(): |
173 | self._UpdatePathToProjectMap(subproject) | 172 | self._UpdatePathToProjectMap(subproject) |
@@ -205,6 +204,7 @@ class Command(object): | |||
205 | result.sort(key=lambda project: project.relpath) | 204 | result.sort(key=lambda project: project.relpath) |
206 | return result | 205 | return result |
207 | 206 | ||
207 | |||
208 | # pylint: disable=W0223 | 208 | # pylint: disable=W0223 |
209 | # Pylint warns that the `InteractiveCommand` and `PagedCommand` classes do not | 209 | # Pylint warns that the `InteractiveCommand` and `PagedCommand` classes do not |
210 | # override method `Execute` which is abstract in `Command`. Since that method | 210 | # override method `Execute` which is abstract in `Command`. Since that method |
@@ -214,28 +214,32 @@ class InteractiveCommand(Command): | |||
214 | """Command which requires user interaction on the tty and | 214 | """Command which requires user interaction on the tty and |
215 | must not run within a pager, even if the user asks to. | 215 | must not run within a pager, even if the user asks to. |
216 | """ | 216 | """ |
217 | def WantPager(self, opt): | 217 | def WantPager(self, _opt): |
218 | return False | 218 | return False |
219 | 219 | ||
220 | |||
220 | class PagedCommand(Command): | 221 | class PagedCommand(Command): |
221 | """Command which defaults to output in a pager, as its | 222 | """Command which defaults to output in a pager, as its |
222 | display tends to be larger than one screen full. | 223 | display tends to be larger than one screen full. |
223 | """ | 224 | """ |
224 | def WantPager(self, opt): | 225 | def WantPager(self, _opt): |
225 | return True | 226 | return True |
226 | 227 | ||
227 | # pylint: enable=W0223 | 228 | # pylint: enable=W0223 |
228 | 229 | ||
230 | |||
229 | class MirrorSafeCommand(object): | 231 | class MirrorSafeCommand(object): |
230 | """Command permits itself to run within a mirror, | 232 | """Command permits itself to run within a mirror, |
231 | and does not require a working directory. | 233 | and does not require a working directory. |
232 | """ | 234 | """ |
233 | 235 | ||
236 | |||
234 | class GitcAvailableCommand(object): | 237 | class GitcAvailableCommand(object): |
235 | """Command that requires GITC to be available, but does | 238 | """Command that requires GITC to be available, but does |
236 | not require the local client to be a GITC client. | 239 | not require the local client to be a GITC client. |
237 | """ | 240 | """ |
238 | 241 | ||
242 | |||
239 | class GitcClientCommand(object): | 243 | class GitcClientCommand(object): |
240 | """Command that requires the local client to be a GITC | 244 | """Command that requires the local client to be a GITC |
241 | client. | 245 | client. |