From 39e108fc77ebd3d64a21b2606764fd54256f2f17 Mon Sep 17 00:00:00 2001 From: "Bala.FA" Date: Sat, 11 Apr 2020 01:15:49 +0530 Subject: [PATCH 1/2] fix formatting as per pep8 in post_policy.py --- minio/post_policy.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/minio/post_policy.py b/minio/post_policy.py index 8241ef20..05ab1e81 100644 --- a/minio/post_policy.py +++ b/minio/post_policy.py @@ -40,6 +40,7 @@ class PostPolicy(object): A :class:`PostPolicy ` object for constructing Amazon S3 POST policy JSON string. """ + def __init__(self): self._expiration = None self._content_length_range = tuple() @@ -114,7 +115,7 @@ def set_content_length_range(self, min_length, max_length): err_msg = ('Min-length ({}) must be <= Max-length ({}), ' 'and they must be non-negative.').format( min_length, max_length - ) + ) if min_length > max_length or min_length < 0 or max_length < 0: raise ValueError(err_msg) @@ -157,7 +158,8 @@ def is_valid(self): Validate for required parameters. """ if not isinstance(self._expiration, datetime.datetime): - raise InvalidArgumentError('Expiration datetime must be specified.') + raise InvalidArgumentError( + 'Expiration datetime must be specified.') if 'key' not in self.form_data: raise InvalidArgumentError('object key must be specified.') From 521cd1c0add9066facc247c05a8128ef0af448af Mon Sep 17 00:00:00 2001 From: "Bala.FA" Date: Sat, 11 Apr 2020 01:22:34 +0530 Subject: [PATCH 2/2] use pythonic approach. --- minio/post_policy.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/minio/post_policy.py b/minio/post_policy.py index 05ab1e81..628e54fb 100644 --- a/minio/post_policy.py +++ b/minio/post_policy.py @@ -114,8 +114,7 @@ def set_content_length_range(self, min_length, max_length): """ err_msg = ('Min-length ({}) must be <= Max-length ({}), ' 'and they must be non-negative.').format( - min_length, max_length - ) + min_length, max_length) if min_length > max_length or min_length < 0 or max_length < 0: raise ValueError(err_msg) @@ -135,11 +134,10 @@ def _marshal_json(self, extras=()): list(self._content_length_range)) policy_stmt = { - "expiration": self._expiration.strftime( - "%Y-%m-%dT%H:%M:%S.000Z"), + "expiration": self._expiration.strftime("%Y-%m-%dT%H:%M:%S.000Z"), } - if len(policies) > 0: + if policies: policy_stmt["conditions"] = policies return json.dumps(policy_stmt)