|
17 | 17 |
|
18 | 18 | HELPER_ATTRIBUTES= ["job_token","http_password","private_token","oauth_token"]
|
19 | 19 |
|
| 20 | +_CONFIG_PARSER_ERRORS= (configparser.NoOptionError,configparser.NoSectionError) |
| 21 | + |
20 | 22 |
|
21 | 23 | def_resolve_file(filepath:Union[Path,str])->str:
|
22 | 24 | resolved=Path(filepath).resolve(strict=True)
|
@@ -148,108 +150,102 @@ def _parse_config(self) -> None:
|
148 | 150 | # Value Error means the option exists but isn't a boolean.
|
149 | 151 | # Get as a string instead as it should then be a local path to a
|
150 | 152 | # CA bundle.
|
151 |
| -try: |
152 |
| -self.ssl_verify=_config.get("global","ssl_verify") |
153 |
| -exceptException:# pragma: no cover |
154 |
| -pass |
155 |
| -exceptException: |
| 153 | +self.ssl_verify=_config.get("global","ssl_verify") |
| 154 | +except_CONFIG_PARSER_ERRORS: |
156 | 155 | pass
|
157 | 156 | try:
|
158 | 157 | self.ssl_verify=_config.getboolean(self.gitlab_id,"ssl_verify")
|
159 | 158 | exceptValueError:
|
160 | 159 | # Value Error means the option exists but isn't a boolean.
|
161 | 160 | # Get as a string instead as it should then be a local path to a
|
162 | 161 | # CA bundle.
|
163 |
| -try: |
164 |
| -self.ssl_verify=_config.get(self.gitlab_id,"ssl_verify") |
165 |
| -exceptException:# pragma: no cover |
166 |
| -pass |
167 |
| -exceptException: |
| 162 | +self.ssl_verify=_config.get(self.gitlab_id,"ssl_verify") |
| 163 | +except_CONFIG_PARSER_ERRORS: |
168 | 164 | pass
|
169 | 165 |
|
170 | 166 | try:
|
171 | 167 | self.timeout=_config.getint("global","timeout")
|
172 |
| -exceptException: |
| 168 | +except_CONFIG_PARSER_ERRORS: |
173 | 169 | pass
|
174 | 170 | try:
|
175 | 171 | self.timeout=_config.getint(self.gitlab_id,"timeout")
|
176 |
| -exceptException: |
| 172 | +except_CONFIG_PARSER_ERRORS: |
177 | 173 | pass
|
178 | 174 |
|
179 | 175 | try:
|
180 | 176 | self.private_token=_config.get(self.gitlab_id,"private_token")
|
181 |
| -exceptException: |
| 177 | +except_CONFIG_PARSER_ERRORS: |
182 | 178 | pass
|
183 | 179 |
|
184 | 180 | try:
|
185 | 181 | self.oauth_token=_config.get(self.gitlab_id,"oauth_token")
|
186 |
| -exceptException: |
| 182 | +except_CONFIG_PARSER_ERRORS: |
187 | 183 | pass
|
188 | 184 |
|
189 | 185 | try:
|
190 | 186 | self.job_token=_config.get(self.gitlab_id,"job_token")
|
191 |
| -exceptException: |
| 187 | +except_CONFIG_PARSER_ERRORS: |
192 | 188 | pass
|
193 | 189 |
|
194 | 190 | try:
|
195 | 191 | self.http_username=_config.get(self.gitlab_id,"http_username")
|
196 | 192 | self.http_password=_config.get(
|
197 | 193 | self.gitlab_id,"http_password"
|
198 | 194 | )# pragma: no cover
|
199 |
| -exceptException: |
| 195 | +except_CONFIG_PARSER_ERRORS: |
200 | 196 | pass
|
201 | 197 |
|
202 | 198 | self._get_values_from_helper()
|
203 | 199 |
|
204 | 200 | try:
|
205 | 201 | self.api_version=_config.get("global","api_version")
|
206 |
| -exceptException: |
| 202 | +except_CONFIG_PARSER_ERRORS: |
207 | 203 | pass
|
208 | 204 | try:
|
209 | 205 | self.api_version=_config.get(self.gitlab_id,"api_version")
|
210 |
| -exceptException: |
| 206 | +except_CONFIG_PARSER_ERRORS: |
211 | 207 | pass
|
212 | 208 | ifself.api_versionnotin ("4",):
|
213 | 209 | raiseGitlabDataError(f"Unsupported API version:{self.api_version}")
|
214 | 210 |
|
215 | 211 | forsectionin ["global",self.gitlab_id]:
|
216 | 212 | try:
|
217 | 213 | self.per_page=_config.getint(section,"per_page")
|
218 |
| -exceptException: |
| 214 | +except_CONFIG_PARSER_ERRORS: |
219 | 215 | pass
|
220 | 216 | ifself.per_pageisnotNoneandnot0<=self.per_page<=100:
|
221 | 217 | raiseGitlabDataError(f"Unsupported per_page number:{self.per_page}")
|
222 | 218 |
|
223 | 219 | try:
|
224 | 220 | self.pagination=_config.get(self.gitlab_id,"pagination")
|
225 |
| -exceptException: |
| 221 | +except_CONFIG_PARSER_ERRORS: |
226 | 222 | pass
|
227 | 223 |
|
228 | 224 | try:
|
229 | 225 | self.order_by=_config.get(self.gitlab_id,"order_by")
|
230 |
| -exceptException: |
| 226 | +except_CONFIG_PARSER_ERRORS: |
231 | 227 | pass
|
232 | 228 |
|
233 | 229 | try:
|
234 | 230 | self.user_agent=_config.get("global","user_agent")
|
235 |
| -exceptException: |
| 231 | +except_CONFIG_PARSER_ERRORS: |
236 | 232 | pass
|
237 | 233 | try:
|
238 | 234 | self.user_agent=_config.get(self.gitlab_id,"user_agent")
|
239 |
| -exceptException: |
| 235 | +except_CONFIG_PARSER_ERRORS: |
240 | 236 | pass
|
241 | 237 |
|
242 | 238 | try:
|
243 | 239 | self.retry_transient_errors=_config.getboolean(
|
244 | 240 | "global","retry_transient_errors"
|
245 | 241 | )
|
246 |
| -exceptException: |
| 242 | +except_CONFIG_PARSER_ERRORS: |
247 | 243 | pass
|
248 | 244 | try:
|
249 | 245 | self.retry_transient_errors=_config.getboolean(
|
250 | 246 | self.gitlab_id,"retry_transient_errors"
|
251 | 247 | )
|
252 |
| -exceptException: |
| 248 | +except_CONFIG_PARSER_ERRORS: |
253 | 249 | pass
|
254 | 250 |
|
255 | 251 | def_get_values_from_helper(self)->None:
|
|