Skip to content

Commit

Permalink
fix formatting as per pep8 in sse.py (#890)
Browse files Browse the repository at this point in the history
  • Loading branch information
balamurugana authored Apr 14, 2020
1 parent 528f8ec commit a30dfa0
Showing 1 changed file with 22 additions and 14 deletions.
36 changes: 22 additions & 14 deletions minio/sse.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# -*- coding: utf-8 -*-
# MinIO Python Library for Amazon S3 Compatible Cloud Storage, (C) 2018 MinIO, Inc.
# MinIO Python Library for Amazon S3 Compatible Cloud Storage,
# (C) 2018 MinIO, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -28,12 +29,14 @@
import json
from .error import (InvalidArgumentError, InvalidSizeError)


class SSE_C(object):

def __init__(self, key):
self.key = key
if len(self.key) != 32:
raise InvalidSizeError("SSE-C keys need to be 256 bit base64 encoded")
raise InvalidSizeError(
"SSE-C keys need to be 256 bit base64 encoded")

def type(self):
return "SSE-C"
Expand All @@ -48,16 +51,18 @@ def marshal(self):
"X-Amz-Server-Side-Encryption-Customer-Algorithm": "AES256",
"X-Amz-Server-Side-Encryption-Customer-Key": b64key.decode(),
"X-Amz-Server-Side-Encryption-Customer-Key-MD5": md5_key
}
}

return keys


class copy_SSE_C(object):

def __init__(self, key):
self.key = key
if len(self.key) != 32:
raise InvalidArgumentError("Length of Customer key must be 32 Bytes")
raise InvalidArgumentError(
"Length of Customer key must be 32 Bytes")

def type(self):
return "copy_SSE-C"
Expand All @@ -68,9 +73,12 @@ def marshal(self):
md5.update(self.key)
md5_key = base64.b64encode(md5.digest()).decode()
keys = {
"X-Amz-Copy-Source-Server-Side-Encryption-Customer-Algorithm":"AES256",
"X-Amz-Copy-Source-Server-Side-Encryption-Customer-Key": b64key.decode(),
"X-Amz-Copy-Source-Server-Side-Encryption-Customer-Key-MD5": md5_key
"X-Amz-Copy-Source-Server-Side-Encryption-Customer-Algorithm":
"AES256",
"X-Amz-Copy-Source-Server-Side-Encryption-Customer-Key":
b64key.decode(),
"X-Amz-Copy-Source-Server-Side-Encryption-Customer-Key-MD5":
md5_key
}
return keys

Expand All @@ -86,15 +94,15 @@ def type(self):
def marshal(self):
keys = {
"X-Amz-Server-Side-Encryption-Aws-Kms-Key-Id": self.key,
"X-Amz-Server-Side-Encryption":"aws:kms"
"X-Amz-Server-Side-Encryption": "aws:kms"
}

if self.context:
ctx_str = json.dumps(self.context)
ctx_str = bytes(ctx_str, 'utf-8')
b64key = base64.b64encode(ctx_str)
header = {"X-Amz-Server-Side-Encryption-Context": b64key.decode()}
keys.update(header)
ctx_str = json.dumps(self.context)
ctx_str = bytes(ctx_str, 'utf-8')
b64key = base64.b64encode(ctx_str)
header = {"X-Amz-Server-Side-Encryption-Context": b64key.decode()}
keys.update(header)

return keys

Expand All @@ -105,6 +113,6 @@ def type(self):

def marshal(self):
keys = {
"X-Amz-Server-Side-Encryption":"AES256"
"X-Amz-Server-Side-Encryption": "AES256"
}
return keys

0 comments on commit a30dfa0

Please sign in to comment.