diff options
author | Gavin Mak <gavinmak@google.com> | 2023-03-11 06:46:20 +0000 |
---|---|---|
committer | LUCI <gerrit-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2023-03-22 17:46:28 +0000 |
commit | ea2e330e43c182dc16b0111ebc69ee5a71ee4ce1 (patch) | |
tree | dc33ba0e56825b3e007d0589891756724725a465 /error.py | |
parent | 1604cf255f8c1786a23388db6d5277ac7949a24a (diff) | |
download | git-repo-ea2e330e43c182dc16b0111ebc69ee5a71ee4ce1.tar.gz |
Format codebase with black and check formatting in CQ
Apply rules set by https://gerrit-review.googlesource.com/c/git-repo/+/362954/ across the codebase and fix any lingering errors caught
by flake8. Also check black formatting in run_tests (and CQ).
Bug: b/267675342
Change-Id: I972d77649dac351150dcfeb1cd1ad0ea2efc1956
Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/363474
Reviewed-by: Mike Frysinger <vapier@google.com>
Tested-by: Gavin Mak <gavinmak@google.com>
Commit-Queue: Gavin Mak <gavinmak@google.com>
Diffstat (limited to 'error.py')
-rw-r--r-- | error.py | 130 |
1 files changed, 60 insertions, 70 deletions
@@ -14,122 +14,112 @@ | |||
14 | 14 | ||
15 | 15 | ||
16 | class ManifestParseError(Exception): | 16 | class ManifestParseError(Exception): |
17 | """Failed to parse the manifest file. | 17 | """Failed to parse the manifest file.""" |
18 | """ | ||
19 | 18 | ||
20 | 19 | ||
21 | class ManifestInvalidRevisionError(ManifestParseError): | 20 | class ManifestInvalidRevisionError(ManifestParseError): |
22 | """The revision value in a project is incorrect. | 21 | """The revision value in a project is incorrect.""" |
23 | """ | ||
24 | 22 | ||
25 | 23 | ||
26 | class ManifestInvalidPathError(ManifestParseError): | 24 | class ManifestInvalidPathError(ManifestParseError): |
27 | """A path used in <copyfile> or <linkfile> is incorrect. | 25 | """A path used in <copyfile> or <linkfile> is incorrect.""" |
28 | """ | ||
29 | 26 | ||
30 | 27 | ||
31 | class NoManifestException(Exception): | 28 | class NoManifestException(Exception): |
32 | """The required manifest does not exist. | 29 | """The required manifest does not exist.""" |
33 | """ | ||
34 | 30 | ||
35 | def __init__(self, path, reason): | 31 | def __init__(self, path, reason): |
36 | super().__init__(path, reason) | 32 | super().__init__(path, reason) |
37 | self.path = path | 33 | self.path = path |
38 | self.reason = reason | 34 | self.reason = reason |
39 | 35 | ||
40 | def __str__(self): | 36 | def __str__(self): |
41 | return self.reason | 37 | return self.reason |
42 | 38 | ||
43 | 39 | ||
44 | class EditorError(Exception): | 40 | class EditorError(Exception): |
45 | """Unspecified error from the user's text editor. | 41 | """Unspecified error from the user's text editor.""" |
46 | """ | ||
47 | 42 | ||
48 | def __init__(self, reason): | 43 | def __init__(self, reason): |
49 | super().__init__(reason) | 44 | super().__init__(reason) |
50 | self.reason = reason | 45 | self.reason = reason |
51 | 46 | ||
52 | def __str__(self): | 47 | def __str__(self): |
53 | return self.reason | 48 | return self.reason |
54 | 49 | ||
55 | 50 | ||
56 | class GitError(Exception): | 51 | class GitError(Exception): |
57 | """Unspecified internal error from git. | 52 | """Unspecified internal error from git.""" |
58 | """ | ||
59 | 53 | ||
60 | def __init__(self, command): | 54 | def __init__(self, command): |
61 | super().__init__(command) | 55 | super().__init__(command) |
62 | self.command = command | 56 | self.command = command |
63 | 57 | ||
64 | def __str__(self): | 58 | def __str__(self): |
65 | return self.command | 59 | return self.command |
66 | 60 | ||
67 | 61 | ||
68 | class UploadError(Exception): | 62 | class UploadError(Exception): |
69 | """A bundle upload to Gerrit did not succeed. | 63 | """A bundle upload to Gerrit did not succeed.""" |
70 | """ | ||
71 | 64 | ||
72 | def __init__(self, reason): | 65 | def __init__(self, reason): |
73 | super().__init__(reason) | 66 | super().__init__(reason) |
74 | self.reason = reason | 67 | self.reason = reason |
75 | 68 | ||
76 | def __str__(self): | 69 | def __str__(self): |
77 | return self.reason | 70 | return self.reason |
78 | 71 | ||
79 | 72 | ||
80 | class DownloadError(Exception): | 73 | class DownloadError(Exception): |
81 | """Cannot download a repository. | 74 | """Cannot download a repository.""" |
82 | """ | ||
83 | 75 | ||
84 | def __init__(self, reason): | 76 | def __init__(self, reason): |
85 | super().__init__(reason) | 77 | super().__init__(reason) |
86 | self.reason = reason | 78 | self.reason = reason |
87 | 79 | ||
88 | def __str__(self): | 80 | def __str__(self): |
89 | return self.reason | 81 | return self.reason |
90 | 82 | ||
91 | 83 | ||
92 | class NoSuchProjectError(Exception): | 84 | class NoSuchProjectError(Exception): |
93 | """A specified project does not exist in the work tree. | 85 | """A specified project does not exist in the work tree.""" |
94 | """ | ||
95 | 86 | ||
96 | def __init__(self, name=None): | 87 | def __init__(self, name=None): |
97 | super().__init__(name) | 88 | super().__init__(name) |
98 | self.name = name | 89 | self.name = name |
99 | 90 | ||
100 | def __str__(self): | 91 | def __str__(self): |
101 | if self.name is None: | 92 | if self.name is None: |
102 | return 'in current directory' | 93 | return "in current directory" |
103 | return self.name | 94 | return self.name |
104 | 95 | ||
105 | 96 | ||
106 | class InvalidProjectGroupsError(Exception): | 97 | class InvalidProjectGroupsError(Exception): |
107 | """A specified project is not suitable for the specified groups | 98 | """A specified project is not suitable for the specified groups""" |
108 | """ | ||
109 | 99 | ||
110 | def __init__(self, name=None): | 100 | def __init__(self, name=None): |
111 | super().__init__(name) | 101 | super().__init__(name) |
112 | self.name = name | 102 | self.name = name |
113 | 103 | ||
114 | def __str__(self): | 104 | def __str__(self): |
115 | if self.name is None: | 105 | if self.name is None: |
116 | return 'in current directory' | 106 | return "in current directory" |
117 | return self.name | 107 | return self.name |
118 | 108 | ||
119 | 109 | ||
120 | class RepoChangedException(Exception): | 110 | class RepoChangedException(Exception): |
121 | """Thrown if 'repo sync' results in repo updating its internal | 111 | """Thrown if 'repo sync' results in repo updating its internal |
122 | repo or manifest repositories. In this special case we must | 112 | repo or manifest repositories. In this special case we must |
123 | use exec to re-execute repo with the new code and manifest. | 113 | use exec to re-execute repo with the new code and manifest. |
124 | """ | 114 | """ |
125 | 115 | ||
126 | def __init__(self, extra_args=None): | 116 | def __init__(self, extra_args=None): |
127 | super().__init__(extra_args) | 117 | super().__init__(extra_args) |
128 | self.extra_args = extra_args or [] | 118 | self.extra_args = extra_args or [] |
129 | 119 | ||
130 | 120 | ||
131 | class HookError(Exception): | 121 | class HookError(Exception): |
132 | """Thrown if a 'repo-hook' could not be run. | 122 | """Thrown if a 'repo-hook' could not be run. |
133 | 123 | ||
134 | The common case is that the file wasn't present when we tried to run it. | 124 | The common case is that the file wasn't present when we tried to run it. |
135 | """ | 125 | """ |