diff options
author | Mike Frysinger <vapier@google.com> | 2021-02-19 13:34:09 -0500 |
---|---|---|
committer | Mike Frysinger <vapier@google.com> | 2021-02-19 20:06:20 +0000 |
commit | 5d9c4972e075afb55dca0f65095b2c7dfffdf389 (patch) | |
tree | 512d667e1ede4eb0a54a9b8bdcdfdfc0583a7b40 | |
parent | 057905fa1d074e6dd341822e5a6a1e49b6b97a21 (diff) | |
download | git-repo-5d9c4972e075afb55dca0f65095b2c7dfffdf389.tar.gz |
use simpler super() magic
Python 3 has a simpler super() style so switch to it to make the
code a little simpler and to stop pylint warnings.
Change-Id: I1b3ccf57ae968d56a9a0bcfc1258fbd8bfa3afee
Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/297383
Reviewed-by: Michael Mortensen <mmortensen@google.com>
Tested-by: Mike Frysinger <vapier@google.com>
-rw-r--r-- | error.py | 16 | ||||
-rw-r--r-- | manifest_xml.py | 7 | ||||
-rw-r--r-- | project.py | 6 | ||||
-rw-r--r-- | subcmds/gitc_init.py | 4 |
4 files changed, 16 insertions, 17 deletions
@@ -37,7 +37,7 @@ class NoManifestException(Exception): | |||
37 | """ | 37 | """ |
38 | 38 | ||
39 | def __init__(self, path, reason): | 39 | def __init__(self, path, reason): |
40 | super(NoManifestException, self).__init__(path, reason) | 40 | super().__init__(path, reason) |
41 | self.path = path | 41 | self.path = path |
42 | self.reason = reason | 42 | self.reason = reason |
43 | 43 | ||
@@ -50,7 +50,7 @@ class EditorError(Exception): | |||
50 | """ | 50 | """ |
51 | 51 | ||
52 | def __init__(self, reason): | 52 | def __init__(self, reason): |
53 | super(EditorError, self).__init__(reason) | 53 | super().__init__(reason) |
54 | self.reason = reason | 54 | self.reason = reason |
55 | 55 | ||
56 | def __str__(self): | 56 | def __str__(self): |
@@ -62,7 +62,7 @@ class GitError(Exception): | |||
62 | """ | 62 | """ |
63 | 63 | ||
64 | def __init__(self, command): | 64 | def __init__(self, command): |
65 | super(GitError, self).__init__(command) | 65 | super().__init__(command) |
66 | self.command = command | 66 | self.command = command |
67 | 67 | ||
68 | def __str__(self): | 68 | def __str__(self): |
@@ -74,7 +74,7 @@ class UploadError(Exception): | |||
74 | """ | 74 | """ |
75 | 75 | ||
76 | def __init__(self, reason): | 76 | def __init__(self, reason): |
77 | super(UploadError, self).__init__(reason) | 77 | super().__init__(reason) |
78 | self.reason = reason | 78 | self.reason = reason |
79 | 79 | ||
80 | def __str__(self): | 80 | def __str__(self): |
@@ -86,7 +86,7 @@ class DownloadError(Exception): | |||
86 | """ | 86 | """ |
87 | 87 | ||
88 | def __init__(self, reason): | 88 | def __init__(self, reason): |
89 | super(DownloadError, self).__init__(reason) | 89 | super().__init__(reason) |
90 | self.reason = reason | 90 | self.reason = reason |
91 | 91 | ||
92 | def __str__(self): | 92 | def __str__(self): |
@@ -98,7 +98,7 @@ class NoSuchProjectError(Exception): | |||
98 | """ | 98 | """ |
99 | 99 | ||
100 | def __init__(self, name=None): | 100 | def __init__(self, name=None): |
101 | super(NoSuchProjectError, self).__init__(name) | 101 | super().__init__(name) |
102 | self.name = name | 102 | self.name = name |
103 | 103 | ||
104 | def __str__(self): | 104 | def __str__(self): |
@@ -112,7 +112,7 @@ class InvalidProjectGroupsError(Exception): | |||
112 | """ | 112 | """ |
113 | 113 | ||
114 | def __init__(self, name=None): | 114 | def __init__(self, name=None): |
115 | super(InvalidProjectGroupsError, self).__init__(name) | 115 | super().__init__(name) |
116 | self.name = name | 116 | self.name = name |
117 | 117 | ||
118 | def __str__(self): | 118 | def __str__(self): |
@@ -128,7 +128,7 @@ class RepoChangedException(Exception): | |||
128 | """ | 128 | """ |
129 | 129 | ||
130 | def __init__(self, extra_args=None): | 130 | def __init__(self, extra_args=None): |
131 | super(RepoChangedException, self).__init__(extra_args) | 131 | super().__init__(extra_args) |
132 | self.extra_args = extra_args or [] | 132 | self.extra_args = extra_args or [] |
133 | 133 | ||
134 | 134 | ||
diff --git a/manifest_xml.py b/manifest_xml.py index 84e3d9f9..ff8e0612 100644 --- a/manifest_xml.py +++ b/manifest_xml.py | |||
@@ -1301,7 +1301,7 @@ class GitcManifest(XmlManifest): | |||
1301 | 1301 | ||
1302 | def _ParseProject(self, node, parent=None): | 1302 | def _ParseProject(self, node, parent=None): |
1303 | """Override _ParseProject and add support for GITC specific attributes.""" | 1303 | """Override _ParseProject and add support for GITC specific attributes.""" |
1304 | return super(GitcManifest, self)._ParseProject( | 1304 | return super()._ParseProject( |
1305 | node, parent=parent, old_revision=node.getAttribute('old-revision')) | 1305 | node, parent=parent, old_revision=node.getAttribute('old-revision')) |
1306 | 1306 | ||
1307 | def _output_manifest_project_extras(self, p, e): | 1307 | def _output_manifest_project_extras(self, p, e): |
@@ -1325,7 +1325,7 @@ class RepoClient(XmlManifest): | |||
1325 | if manifest_file is None: | 1325 | if manifest_file is None: |
1326 | manifest_file = os.path.join(repodir, MANIFEST_FILE_NAME) | 1326 | manifest_file = os.path.join(repodir, MANIFEST_FILE_NAME) |
1327 | local_manifests = os.path.abspath(os.path.join(repodir, LOCAL_MANIFESTS_DIR_NAME)) | 1327 | local_manifests = os.path.abspath(os.path.join(repodir, LOCAL_MANIFESTS_DIR_NAME)) |
1328 | super(RepoClient, self).__init__(repodir, manifest_file, local_manifests) | 1328 | super().__init__(repodir, manifest_file, local_manifests) |
1329 | 1329 | ||
1330 | # TODO: Completely separate manifest logic out of the client. | 1330 | # TODO: Completely separate manifest logic out of the client. |
1331 | self.manifest = self | 1331 | self.manifest = self |
@@ -1340,6 +1340,5 @@ class GitcClient(RepoClient, GitcManifest): | |||
1340 | self.gitc_client_dir = os.path.join(gitc_utils.get_gitc_manifest_dir(), | 1340 | self.gitc_client_dir = os.path.join(gitc_utils.get_gitc_manifest_dir(), |
1341 | gitc_client_name) | 1341 | gitc_client_name) |
1342 | 1342 | ||
1343 | super(GitcManifest, self).__init__( | 1343 | super().__init__(repodir, os.path.join(self.gitc_client_dir, '.manifest')) |
1344 | repodir, os.path.join(self.gitc_client_dir, '.manifest')) | ||
1345 | self.isGitcClient = True | 1344 | self.isGitcClient = True |
@@ -232,7 +232,7 @@ class ReviewableBranch(object): | |||
232 | class StatusColoring(Coloring): | 232 | class StatusColoring(Coloring): |
233 | 233 | ||
234 | def __init__(self, config): | 234 | def __init__(self, config): |
235 | Coloring.__init__(self, config, 'status') | 235 | super().__init__(config, 'status') |
236 | self.project = self.printer('header', attr='bold') | 236 | self.project = self.printer('header', attr='bold') |
237 | self.branch = self.printer('header', attr='bold') | 237 | self.branch = self.printer('header', attr='bold') |
238 | self.nobranch = self.printer('nobranch', fg='red') | 238 | self.nobranch = self.printer('nobranch', fg='red') |
@@ -246,7 +246,7 @@ class StatusColoring(Coloring): | |||
246 | class DiffColoring(Coloring): | 246 | class DiffColoring(Coloring): |
247 | 247 | ||
248 | def __init__(self, config): | 248 | def __init__(self, config): |
249 | Coloring.__init__(self, config, 'diff') | 249 | super().__init__(config, 'diff') |
250 | self.project = self.printer('header', attr='bold') | 250 | self.project = self.printer('header', attr='bold') |
251 | self.fail = self.printer('fail', fg='red') | 251 | self.fail = self.printer('fail', fg='red') |
252 | 252 | ||
@@ -3091,7 +3091,7 @@ class _Later(object): | |||
3091 | class _SyncColoring(Coloring): | 3091 | class _SyncColoring(Coloring): |
3092 | 3092 | ||
3093 | def __init__(self, config): | 3093 | def __init__(self, config): |
3094 | Coloring.__init__(self, config, 'reposync') | 3094 | super().__init__(config, 'reposync') |
3095 | self.project = self.printer('header', attr='bold') | 3095 | self.project = self.printer('header', attr='bold') |
3096 | self.info = self.printer('info') | 3096 | self.info = self.printer('info') |
3097 | self.fail = self.printer('fail', fg='red') | 3097 | self.fail = self.printer('fail', fg='red') |
diff --git a/subcmds/gitc_init.py b/subcmds/gitc_init.py index 7ecfdcac..89472edb 100644 --- a/subcmds/gitc_init.py +++ b/subcmds/gitc_init.py | |||
@@ -47,7 +47,7 @@ use for this GITC client. | |||
47 | """ | 47 | """ |
48 | 48 | ||
49 | def _Options(self, p): | 49 | def _Options(self, p): |
50 | super(GitcInit, self)._Options(p, gitc_init=True) | 50 | super()._Options(p, gitc_init=True) |
51 | g = p.add_option_group('GITC options') | 51 | g = p.add_option_group('GITC options') |
52 | g.add_option('-f', '--manifest-file', | 52 | g.add_option('-f', '--manifest-file', |
53 | dest='manifest_file', | 53 | dest='manifest_file', |
@@ -64,7 +64,7 @@ use for this GITC client. | |||
64 | sys.exit(1) | 64 | sys.exit(1) |
65 | self.client_dir = os.path.join(gitc_utils.get_gitc_manifest_dir(), | 65 | self.client_dir = os.path.join(gitc_utils.get_gitc_manifest_dir(), |
66 | gitc_client) | 66 | gitc_client) |
67 | super(GitcInit, self).Execute(opt, args) | 67 | super().Execute(opt, args) |
68 | 68 | ||
69 | manifest_file = self.manifest.manifestFile | 69 | manifest_file = self.manifest.manifestFile |
70 | if opt.manifest_file: | 70 | if opt.manifest_file: |