22
22
import requests .utils
23
23
24
24
import gitlab .config
25
- from gitlab .const import * # noqa
26
- from gitlab .exceptions import * # noqa
27
- from gitlab import utils # noqa
25
+ import gitlab .const
26
+ import gitlab .exceptions
27
+ from gitlab import utils
28
28
from requests_toolbelt .multipart .encoder import MultipartEncoder
29
29
30
30
@@ -69,7 +69,7 @@ def __init__(
69
69
per_page = None ,
70
70
pagination = None ,
71
71
order_by = None ,
72
- user_agent = USER_AGENT ,
72
+ user_agent = gitlab . const . USER_AGENT ,
73
73
):
74
74
75
75
self ._api_version = str (api_version )
@@ -239,7 +239,7 @@ def version(self):
239
239
240
240
return self ._server_version , self ._server_revision
241
241
242
- @on_http_error (GitlabVerifyError )
242
+ @gitlab . exceptions . on_http_error (gitlab . exceptions . GitlabVerifyError )
243
243
def lint (self , content , ** kwargs ):
244
244
"""Validate a gitlab CI configuration.
245
245
@@ -259,7 +259,7 @@ def lint(self, content, **kwargs):
259
259
data = self .http_post ("/ci/lint" , post_data = post_data , ** kwargs )
260
260
return (data ["status" ] == "valid" , data ["errors" ])
261
261
262
- @on_http_error (GitlabMarkdownError )
262
+ @gitlab . exceptions . on_http_error (gitlab . exceptions . GitlabMarkdownError )
263
263
def markdown (self , text , gfm = False , project = None , ** kwargs ):
264
264
"""Render an arbitrary Markdown document.
265
265
@@ -284,7 +284,7 @@ def markdown(self, text, gfm=False, project=None, **kwargs):
284
284
data = self .http_post ("/markdown" , post_data = post_data , ** kwargs )
285
285
return data ["html" ]
286
286
287
- @on_http_error (GitlabLicenseError )
287
+ @gitlab . exceptions . on_http_error (gitlab . exceptions . GitlabLicenseError )
288
288
def get_license (self , ** kwargs ):
289
289
"""Retrieve information about the current license.
290
290
@@ -300,7 +300,7 @@ def get_license(self, **kwargs):
300
300
"""
301
301
return self .http_get ("/license" , ** kwargs )
302
302
303
- @on_http_error (GitlabLicenseError )
303
+ @gitlab . exceptions . on_http_error (gitlab . exceptions . GitlabLicenseError )
304
304
def set_license (self , license , ** kwargs ):
305
305
"""Add a new license.
306
306
@@ -438,7 +438,7 @@ def _check_redirects(self, result):
438
438
# Did we end-up with an https:// URL?
439
439
location = item .headers .get ("Location" , None )
440
440
if location and location .startswith ("https://" ):
441
- raise RedirectError (REDIRECT_MSG )
441
+ raise gitlab . exceptions . RedirectError (REDIRECT_MSG )
442
442
443
443
def http_request (
444
444
self ,
@@ -559,13 +559,13 @@ def http_request(
559
559
pass
560
560
561
561
if result .status_code == 401 :
562
- raise GitlabAuthenticationError (
562
+ raise gitlab . exceptions . GitlabAuthenticationError (
563
563
response_code = result .status_code ,
564
564
error_message = error_message ,
565
565
response_body = result .content ,
566
566
)
567
567
568
- raise GitlabHttpError (
568
+ raise gitlab . exceptions . GitlabHttpError (
569
569
response_code = result .status_code ,
570
570
error_message = error_message ,
571
571
response_body = result .content ,
@@ -604,7 +604,7 @@ def http_get(self, path, query_data=None, streamed=False, raw=False, **kwargs):
604
604
try :
605
605
return result .json ()
606
606
except Exception as e :
607
- raise GitlabParsingError (
607
+ raise gitlab . exceptions . GitlabParsingError (
608
608
error_message = "Failed to parse the server message"
609
609
) from e
610
610
else :
@@ -686,7 +686,7 @@ def http_post(self, path, query_data=None, post_data=None, files=None, **kwargs)
686
686
if result .headers .get ("Content-Type" , None ) == "application/json" :
687
687
return result .json ()
688
688
except Exception as e :
689
- raise GitlabParsingError (
689
+ raise gitlab . exceptions . GitlabParsingError (
690
690
error_message = "Failed to parse the server message"
691
691
) from e
692
692
return result
@@ -724,7 +724,7 @@ def http_put(self, path, query_data=None, post_data=None, files=None, **kwargs):
724
724
try :
725
725
return result .json ()
726
726
except Exception as e :
727
- raise GitlabParsingError (
727
+ raise gitlab . exceptions . GitlabParsingError (
728
728
error_message = "Failed to parse the server message"
729
729
) from e
730
730
@@ -744,7 +744,7 @@ def http_delete(self, path, **kwargs):
744
744
"""
745
745
return self .http_request ("delete" , path , ** kwargs )
746
746
747
- @on_http_error (GitlabSearchError )
747
+ @gitlab . exceptions . on_http_error (gitlab . exceptions . GitlabSearchError )
748
748
def search (self , scope , search , ** kwargs ):
749
749
"""Search GitLab resources matching the provided string.'
750
750
@@ -804,7 +804,7 @@ def _query(self, url, query_data=None, **kwargs):
804
804
try :
805
805
self ._data = result .json ()
806
806
except Exception as e :
807
- raise GitlabParsingError (
807
+ raise gitlab . exceptions . GitlabParsingError (
808
808
error_message = "Failed to parse the server message"
809
809
) from e
810
810
0 commit comments