@@ -44,19 +44,17 @@ class Archivist: # pylint: disable=too-many-instance-attributes
4444
4545 Either auth or cert must be specified
4646 """
47+
4748 def __init__ (self , url , * , auth = None , cert = None , verify = True ):
48- """docstring
49- """
50- self ._headers = {'content-type' : 'application/json' }
49+ """docstring"""
50+ self ._headers = {"content-type" : "application/json" }
5151 if auth is not None :
52- self ._headers [' authorization' ] = ' Bearer ' + auth .strip ()
52+ self ._headers [" authorization" ] = " Bearer " + auth .strip ()
5353
5454 self ._url = url
5555 self ._verify = verify
5656 if not cert and not auth :
57- raise ArchivistIllegalArgumentError (
58- "Either auth or cert must be specified"
59- )
57+ raise ArchivistIllegalArgumentError ("Either auth or cert must be specified" )
6058
6159 if cert and auth :
6260 raise ArchivistIllegalArgumentError (
@@ -65,9 +63,7 @@ def __init__(self, url, *, auth=None, cert=None, verify=True):
6563
6664 if cert :
6765 if not os_path_isfile (cert ):
68- raise ArchivistNotFoundError (
69- f"Cert file { cert } does not exist"
70- )
66+ raise ArchivistNotFoundError (f"Cert file { cert } does not exist" )
7167
7268 self ._cert = cert
7369
@@ -78,31 +74,26 @@ def __init__(self, url, *, auth=None, cert=None, verify=True):
7874
7975 @property
8076 def headers (self ):
81- """docstring
82- """
77+ """docstring"""
8378 return self ._headers
8479
8580 @property
8681 def url (self ):
87- """docstring
88- """
82+ """docstring"""
8983 return self ._url
9084
9185 @property
9286 def verify (self ):
93- """docstring
94- """
87+ """docstring"""
9588 return self ._verify
9689
9790 @property
9891 def cert (self ):
99- """docstring
100- """
92+ """docstring"""
10193 return self ._cert
10294
10395 def __add_headers (self , headers ):
104- """docstring
105- """
96+ """docstring"""
10697 if headers is not None :
10798 newheaders = {** self .headers , ** headers }
10899 else :
@@ -182,11 +173,11 @@ def post_file(self, path, fd, mtype):
182173
183174 multipart = MultipartEncoder (
184175 fields = {
185- ' file' : (' filename' , fd , mtype ),
176+ " file" : (" filename" , fd , mtype ),
186177 }
187178 )
188179 headers = {
189- ' content-type' : multipart .content_type ,
180+ " content-type" : multipart .content_type ,
190181 }
191182 response = requests .post (
192183 SEP .join ((self .url , ROOT , path )),
@@ -242,7 +233,7 @@ def patch(self, subpath, identity, request, *, headers=None):
242233
243234 def __list (self , path , args , * , headers = None ):
244235 if args :
245- path = '?' .join ((path , args ))
236+ path = "?" .join ((path , args ))
246237
247238 response = requests .get (
248239 SEP .join ((self .url , ROOT , path )),
@@ -258,10 +249,8 @@ def __list(self, path, args, *, headers=None):
258249
259250 @staticmethod
260251 def __query (query ):
261- return query and '&' .join (
262- sorted (
263- f"{ k } ={ v } " for k , v in flatten (query , reducer = 'dot' ).items ()
264- )
252+ return query and "&" .join (
253+ sorted (f"{ k } ={ v } " for k , v in flatten (query , reducer = "dot" ).items ())
265254 )
266255
267256 def get_by_signature (self , path , field , query , * , headers = None ):
@@ -281,9 +270,7 @@ def get_by_signature(self, path, field, query, *, headers=None):
281270
282271 response = self .__list (
283272 path ,
284- '&' .join (
285- (a for a in (paging , qry ) if a )
286- ),
273+ "&" .join ((a for a in (paging , qry ) if a )),
287274 headers = headers ,
288275 )
289276
@@ -311,15 +298,13 @@ def count(self, path, *, query=None):
311298
312299 paging = "page_size=1"
313300 qry = self .__query (query )
314- headers = {HEADERS_REQUEST_TOTAL_COUNT : ' true' }
301+ headers = {HEADERS_REQUEST_TOTAL_COUNT : " true" }
315302
316303 # v2/assets?page_size=10&something=something...
317304
318305 response = self .__list (
319306 path ,
320- '&' .join (
321- (a for a in (paging , qry ) if a )
322- ),
307+ "&" .join ((a for a in (paging , qry ) if a )),
323308 headers = headers ,
324309 )
325310
@@ -348,9 +333,7 @@ def list(self, path, field, *, page_size=None, query=None, headers=None):
348333 while True :
349334 response = self .__list (
350335 path ,
351- '&' .join (
352- (a for a in (paging , qry ) if a )
353- ),
336+ "&" .join ((a for a in (paging , qry ) if a )),
354337 headers = headers ,
355338 )
356339 data = response .json ()
0 commit comments