Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix formatting as per pep8 in sse.py #890

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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