diff options
author | Bryan Newbold <bnewbold@archive.org> | 2021-10-27 18:50:17 -0700 |
---|---|---|
committer | Bryan Newbold <bnewbold@archive.org> | 2021-10-27 18:50:17 -0700 |
commit | 826c7538e091fac14d987a3cd654975da964e240 (patch) | |
tree | 90345b4cabb461c624ca5a218c2fc01dce3055cd /python/sandcrawler/minio.py | |
parent | 020037d4714e7ba2ab172c7278494aed0b2148ad (diff) | |
download | sandcrawler-826c7538e091fac14d987a3cd654975da964e240.tar.gz sandcrawler-826c7538e091fac14d987a3cd654975da964e240.zip |
make fmt (black 21.9b0)
Diffstat (limited to 'python/sandcrawler/minio.py')
-rw-r--r-- | python/sandcrawler/minio.py | 52 |
1 files changed, 29 insertions, 23 deletions
diff --git a/python/sandcrawler/minio.py b/python/sandcrawler/minio.py index 1967ba3..d47ab89 100644 --- a/python/sandcrawler/minio.py +++ b/python/sandcrawler/minio.py @@ -6,11 +6,13 @@ import minio class SandcrawlerMinioClient(object): - def __init__(self, - host_url: str, - access_key: str, - secret_key: str, - default_bucket: Optional[str] = None): + def __init__( + self, + host_url: str, + access_key: str, + secret_key: str, + default_bucket: Optional[str] = None, + ): """ host is minio connection string (host:port) access and secret key are as expected @@ -46,13 +48,15 @@ class SandcrawlerMinioClient(object): ) return obj_path - def put_blob(self, - folder: str, - blob: Union[str, bytes], - sha1hex: Optional[str] = None, - extension: str = "", - prefix: str = "", - bucket: Optional[str] = None) -> Tuple[str, str]: + def put_blob( + self, + folder: str, + blob: Union[str, bytes], + sha1hex: Optional[str] = None, + extension: str = "", + prefix: str = "", + bucket: Optional[str] = None, + ) -> Tuple[str, str]: """ blob should be bytes sha1hex is assumed to be sha1 of the blob itself; if not supplied it will be calculated @@ -61,7 +65,7 @@ class SandcrawlerMinioClient(object): filename is SHA1 with an optional file extension. """ if type(blob) == str: - blob = blob.encode('utf-8') + blob = blob.encode("utf-8") assert type(blob) == bytes if not sha1hex: h = hashlib.sha1() @@ -72,13 +76,13 @@ class SandcrawlerMinioClient(object): bucket = self.default_bucket assert bucket content_type = "application/octet-stream" - if extension.endswith('.xml'): + if extension.endswith(".xml"): content_type = "application/xml" - if extension.endswith('.png'): + if extension.endswith(".png"): content_type = "image/png" - elif extension.endswith('.jpg') or extension.endswith('.jpeg'): + elif extension.endswith(".jpg") or extension.endswith(".jpeg"): content_type = "image/jpeg" - elif extension.endswith('.txt'): + elif extension.endswith(".txt"): content_type = "text/plain" self.mc.put_object( bucket, @@ -89,12 +93,14 @@ class SandcrawlerMinioClient(object): ) return (bucket, obj_path) - def get_blob(self, - folder: str, - sha1hex: str, - extension: str = "", - prefix: str = "", - bucket: str = None) -> bytes: + def get_blob( + self, + folder: str, + sha1hex: str, + extension: str = "", + prefix: str = "", + bucket: str = None, + ) -> bytes: """ sha1hex is sha1 of the blob itself |