23
23
import requests .utils
24
24
25
25
import gitlab .config
26
- from gitlab .const import * # noqa
27
- from gitlab .exceptions import * # noqa
28
- from gitlab import utils # noqa
26
+ import gitlab .const
27
+ import gitlab .exceptions
28
+ from gitlab import utils
29
29
from requests_toolbelt .multipart .encoder import MultipartEncoder
30
30
31
31
@@ -70,7 +70,7 @@ def __init__(
70
70
per_page = None ,
71
71
pagination = None ,
72
72
order_by = None ,
73
- user_agent = USER_AGENT ,
73
+ user_agent = gitlab . const . USER_AGENT ,
74
74
):
75
75
76
76
self ._api_version = str (api_version )
@@ -227,7 +227,7 @@ def version(self):
227
227
228
228
return self ._server_version , self ._server_revision
229
229
230
- @on_http_error (GitlabVerifyError )
230
+ @gitlab . exceptions . on_http_error (gitlab . exceptions . GitlabVerifyError )
231
231
def lint (self , content , ** kwargs ):
232
232
"""Validate a gitlab CI configuration.
233
233
@@ -247,7 +247,7 @@ def lint(self, content, **kwargs):
247
247
data = self .http_post ("/ci/lint" , post_data = post_data , ** kwargs )
248
248
return (data ["status" ] == "valid" , data ["errors" ])
249
249
250
- @on_http_error (GitlabMarkdownError )
250
+ @gitlab . exceptions . on_http_error (gitlab . exceptions . GitlabMarkdownError )
251
251
def markdown (self , text , gfm = False , project = None , ** kwargs ):
252
252
"""Render an arbitrary Markdown document.
253
253
@@ -272,7 +272,7 @@ def markdown(self, text, gfm=False, project=None, **kwargs):
272
272
data = self .http_post ("/markdown" , post_data = post_data , ** kwargs )
273
273
return data ["html" ]
274
274
275
- @on_http_error (GitlabLicenseError )
275
+ @gitlab . exceptions . on_http_error (gitlab . exceptions . GitlabLicenseError )
276
276
def get_license (self , ** kwargs ):
277
277
"""Retrieve information about the current license.
278
278
@@ -288,7 +288,7 @@ def get_license(self, **kwargs):
288
288
"""
289
289
return self .http_get ("/license" , ** kwargs )
290
290
291
- @on_http_error (GitlabLicenseError )
291
+ @gitlab . exceptions . on_http_error (gitlab . exceptions . GitlabLicenseError )
292
292
def set_license (self , license , ** kwargs ):
293
293
"""Add a new license.
294
294
@@ -426,7 +426,7 @@ def _check_redirects(self, result):
426
426
# Did we end-up with an https:// URL?
427
427
location = item .headers .get ("Location" , None )
428
428
if location and location .startswith ("https://" ):
429
- raise RedirectError (REDIRECT_MSG )
429
+ raise gitlab . exceptions . RedirectError (REDIRECT_MSG )
430
430
431
431
def http_request (
432
432
self ,
@@ -547,13 +547,13 @@ def http_request(
547
547
pass
548
548
549
549
if result .status_code == 401 :
550
- raise GitlabAuthenticationError (
550
+ raise gitlab . exceptions . GitlabAuthenticationError (
551
551
response_code = result .status_code ,
552
552
error_message = error_message ,
553
553
response_body = result .content ,
554
554
)
555
555
556
- raise GitlabHttpError (
556
+ raise gitlab . exceptions . GitlabHttpError (
557
557
response_code = result .status_code ,
558
558
error_message = error_message ,
559
559
response_body = result .content ,
@@ -592,7 +592,7 @@ def http_get(self, path, query_data=None, streamed=False, raw=False, **kwargs):
592
592
try :
593
593
return result .json ()
594
594
except Exception as e :
595
- raise GitlabParsingError (
595
+ raise gitlab . exceptions . GitlabParsingError (
596
596
error_message = "Failed to parse the server message"
597
597
) from e
598
598
else :
@@ -674,7 +674,7 @@ def http_post(self, path, query_data=None, post_data=None, files=None, **kwargs)
674
674
if result .headers .get ("Content-Type" , None ) == "application/json" :
675
675
return result .json ()
676
676
except Exception as e :
677
- raise GitlabParsingError (
677
+ raise gitlab . exceptions . GitlabParsingError (
678
678
error_message = "Failed to parse the server message"
679
679
) from e
680
680
return result
@@ -712,7 +712,7 @@ def http_put(self, path, query_data=None, post_data=None, files=None, **kwargs):
712
712
try :
713
713
return result .json ()
714
714
except Exception as e :
715
- raise GitlabParsingError (
715
+ raise gitlab . exceptions . GitlabParsingError (
716
716
error_message = "Failed to parse the server message"
717
717
) from e
718
718
@@ -732,7 +732,7 @@ def http_delete(self, path, **kwargs):
732
732
"""
733
733
return self .http_request ("delete" , path , ** kwargs )
734
734
735
- @on_http_error (GitlabSearchError )
735
+ @gitlab . exceptions . on_http_error (gitlab . exceptions . GitlabSearchError )
736
736
def search (self , scope , search , ** kwargs ):
737
737
"""Search GitLab resources matching the provided string.'
738
738
@@ -792,7 +792,7 @@ def _query(self, url, query_data=None, **kwargs):
792
792
try :
793
793
self ._data = result .json ()
794
794
except Exception as e :
795
- raise GitlabParsingError (
795
+ raise gitlab . exceptions . GitlabParsingError (
796
796
error_message = "Failed to parse the server message"
797
797
) from e
798
798
0 commit comments