|
34 | 34 |
|
35 | 35 | HELPER_ATTRIBUTES= ["job_token","http_password","private_token","oauth_token"]
|
36 | 36 |
|
| 37 | +_CONFIG_PARSER_ERRORS= (configparser.NoOptionError,configparser.NoSectionError) |
| 38 | + |
37 | 39 |
|
38 | 40 | def_resolve_file(filepath:Union[Path,str])->str:
|
39 | 41 | resolved=Path(filepath).resolve(strict=True)
|
@@ -165,108 +167,102 @@ def _parse_config(self) -> None:
|
165 | 167 | # Value Error means the option exists but isn't a boolean.
|
166 | 168 | # Get as a string instead as it should then be a local path to a
|
167 | 169 | # CA bundle.
|
168 |
| -try: |
169 |
| -self.ssl_verify=_config.get("global","ssl_verify") |
170 |
| -exceptException:# pragma: no cover |
171 |
| -pass |
172 |
| -exceptException: |
| 170 | +self.ssl_verify=_config.get("global","ssl_verify") |
| 171 | +except_CONFIG_PARSER_ERRORS: |
173 | 172 | pass
|
174 | 173 | try:
|
175 | 174 | self.ssl_verify=_config.getboolean(self.gitlab_id,"ssl_verify")
|
176 | 175 | exceptValueError:
|
177 | 176 | # Value Error means the option exists but isn't a boolean.
|
178 | 177 | # Get as a string instead as it should then be a local path to a
|
179 | 178 | # CA bundle.
|
180 |
| -try: |
181 |
| -self.ssl_verify=_config.get(self.gitlab_id,"ssl_verify") |
182 |
| -exceptException:# pragma: no cover |
183 |
| -pass |
184 |
| -exceptException: |
| 179 | +self.ssl_verify=_config.get(self.gitlab_id,"ssl_verify") |
| 180 | +except_CONFIG_PARSER_ERRORS: |
185 | 181 | pass
|
186 | 182 |
|
187 | 183 | try:
|
188 | 184 | self.timeout=_config.getint("global","timeout")
|
189 |
| -exceptException: |
| 185 | +except_CONFIG_PARSER_ERRORS: |
190 | 186 | pass
|
191 | 187 | try:
|
192 | 188 | self.timeout=_config.getint(self.gitlab_id,"timeout")
|
193 |
| -exceptException: |
| 189 | +except_CONFIG_PARSER_ERRORS: |
194 | 190 | pass
|
195 | 191 |
|
196 | 192 | try:
|
197 | 193 | self.private_token=_config.get(self.gitlab_id,"private_token")
|
198 |
| -exceptException: |
| 194 | +except_CONFIG_PARSER_ERRORS: |
199 | 195 | pass
|
200 | 196 |
|
201 | 197 | try:
|
202 | 198 | self.oauth_token=_config.get(self.gitlab_id,"oauth_token")
|
203 |
| -exceptException: |
| 199 | +except_CONFIG_PARSER_ERRORS: |
204 | 200 | pass
|
205 | 201 |
|
206 | 202 | try:
|
207 | 203 | self.job_token=_config.get(self.gitlab_id,"job_token")
|
208 |
| -exceptException: |
| 204 | +except_CONFIG_PARSER_ERRORS: |
209 | 205 | pass
|
210 | 206 |
|
211 | 207 | try:
|
212 | 208 | self.http_username=_config.get(self.gitlab_id,"http_username")
|
213 | 209 | self.http_password=_config.get(
|
214 | 210 | self.gitlab_id,"http_password"
|
215 | 211 | )# pragma: no cover
|
216 |
| -exceptException: |
| 212 | +except_CONFIG_PARSER_ERRORS: |
217 | 213 | pass
|
218 | 214 |
|
219 | 215 | self._get_values_from_helper()
|
220 | 216 |
|
221 | 217 | try:
|
222 | 218 | self.api_version=_config.get("global","api_version")
|
223 |
| -exceptException: |
| 219 | +except_CONFIG_PARSER_ERRORS: |
224 | 220 | pass
|
225 | 221 | try:
|
226 | 222 | self.api_version=_config.get(self.gitlab_id,"api_version")
|
227 |
| -exceptException: |
| 223 | +except_CONFIG_PARSER_ERRORS: |
228 | 224 | pass
|
229 | 225 | ifself.api_versionnotin ("4",):
|
230 | 226 | raiseGitlabDataError(f"Unsupported API version:{self.api_version}")
|
231 | 227 |
|
232 | 228 | forsectionin ["global",self.gitlab_id]:
|
233 | 229 | try:
|
234 | 230 | self.per_page=_config.getint(section,"per_page")
|
235 |
| -exceptException: |
| 231 | +except_CONFIG_PARSER_ERRORS: |
236 | 232 | pass
|
237 | 233 | ifself.per_pageisnotNoneandnot0<=self.per_page<=100:
|
238 | 234 | raiseGitlabDataError(f"Unsupported per_page number:{self.per_page}")
|
239 | 235 |
|
240 | 236 | try:
|
241 | 237 | self.pagination=_config.get(self.gitlab_id,"pagination")
|
242 |
| -exceptException: |
| 238 | +except_CONFIG_PARSER_ERRORS: |
243 | 239 | pass
|
244 | 240 |
|
245 | 241 | try:
|
246 | 242 | self.order_by=_config.get(self.gitlab_id,"order_by")
|
247 |
| -exceptException: |
| 243 | +except_CONFIG_PARSER_ERRORS: |
248 | 244 | pass
|
249 | 245 |
|
250 | 246 | try:
|
251 | 247 | self.user_agent=_config.get("global","user_agent")
|
252 |
| -exceptException: |
| 248 | +except_CONFIG_PARSER_ERRORS: |
253 | 249 | pass
|
254 | 250 | try:
|
255 | 251 | self.user_agent=_config.get(self.gitlab_id,"user_agent")
|
256 |
| -exceptException: |
| 252 | +except_CONFIG_PARSER_ERRORS: |
257 | 253 | pass
|
258 | 254 |
|
259 | 255 | try:
|
260 | 256 | self.retry_transient_errors=_config.getboolean(
|
261 | 257 | "global","retry_transient_errors"
|
262 | 258 | )
|
263 |
| -exceptException: |
| 259 | +except_CONFIG_PARSER_ERRORS: |
264 | 260 | pass
|
265 | 261 | try:
|
266 | 262 | self.retry_transient_errors=_config.getboolean(
|
267 | 263 | self.gitlab_id,"retry_transient_errors"
|
268 | 264 | )
|
269 |
| -exceptException: |
| 265 | +except_CONFIG_PARSER_ERRORS: |
270 | 266 | pass
|
271 | 267 |
|
272 | 268 | def_get_values_from_helper(self)->None:
|
|