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 parsers.py #887

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
26 changes: 18 additions & 8 deletions minio/parsers.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) 2015 MinIO, Inc.
# MinIO Python Library for Amazon S3 Compatible Cloud Storage,
# (C) 2015 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 All @@ -26,8 +27,6 @@

# standard.
from xml.etree import ElementTree
from xml.etree.ElementTree import ParseError

from datetime import datetime

# dependencies.
Expand All @@ -42,7 +41,7 @@
from .xml_marshal import (NOTIFICATIONS_ARN_FIELDNAME_MAP)


_S3_NS = {'s3' : 'http://s3.amazonaws.com/doc/2006-03-01/'}
_S3_NS = {'s3': 'http://s3.amazonaws.com/doc/2006-03-01/'}


class S3Element(object):
Expand All @@ -51,6 +50,7 @@ class S3Element(object):
functions.

"""

def __init__(self, root_name, element):
self.root_name = root_name
self.element = element
Expand Down Expand Up @@ -86,7 +86,7 @@ def find(self, name):

"""
elt = self.element.find('s3:{}'.format(name), _S3_NS)
return S3Element(self.root_name, elt) if elt is not None else None
return S3Element(self.root_name, elt) if elt else None

def get_child_text(self, name, strict=True):
"""Extract text of a child element. If strict, and child element is
Expand Down Expand Up @@ -163,6 +163,7 @@ def parse_multipart_upload_result(data):
root.get_etag_elem()
)


def parse_copy_object(bucket_name, object_name, data):
"""
Parser for copy object response.
Expand All @@ -178,6 +179,7 @@ def parse_copy_object(bucket_name, object_name, data):
root.get_localized_time_elem('LastModified')
)


def parse_list_buckets(data):
"""
Parser for list buckets response.
Expand All @@ -194,6 +196,7 @@ def parse_list_buckets(data):
for bucket in buckets.findall('Bucket')
]


def _parse_objects_from_xml_elts(bucket_name, contents, common_prefixes):
"""Internal function that extracts objects and common prefixes from
list_objects responses.
Expand All @@ -209,14 +212,14 @@ def _parse_objects_from_xml_elts(bucket_name, contents, common_prefixes):
]

object_dirs = [
Object(bucket_name, dir_elt.text(), None, '',
0, is_dir=True)
Object(bucket_name, dir_elt.text(), None, '', 0, is_dir=True)
for dirs_elt in common_prefixes
for dir_elt in dirs_elt.findall('Prefix')
]

return objects, object_dirs


def parse_list_objects(data, bucket_name):
"""
Parser for list objects response.
Expand Down Expand Up @@ -270,6 +273,7 @@ def parse_list_objects_v2(data, bucket_name):

return objects + object_dirs, is_truncated, continuation_token


def parse_list_multipart_uploads(data, bucket_name):
"""
Parser for list multipart uploads response.
Expand Down Expand Up @@ -328,6 +332,7 @@ def parse_list_parts(data, bucket_name, object_name, upload_id):

return parts, is_truncated, part_marker


def parse_new_multipart_upload(data):
"""
Parser for new multipart upload response.
Expand All @@ -338,6 +343,7 @@ def parse_new_multipart_upload(data):
root = S3Element.fromstring('InitiateMultipartUploadResult', data)
return root.get_child_text('UploadId')


def parse_location_constraint(data):
"""
Parser for location constraint response.
Expand All @@ -348,6 +354,7 @@ def parse_location_constraint(data):
root = S3Element.fromstring('BucketLocationConstraintResult', data)
return root.text()


def _iso8601_to_localized_time(date_string):
"""
Convert iso8601 date string into UTC time.
Expand All @@ -366,6 +373,7 @@ def _iso8601_to_localized_time(date_string):
localized_time = pytz.utc.localize(parsed_date)
return localized_time


def parse_get_bucket_notification(data):
"""
Parser for a get_bucket_notification response from S3.
Expand All @@ -390,6 +398,7 @@ def parse_get_bucket_notification(data):

return notifications


def _parse_add_notifying_service_config(data, notifications, service_key,
service_xml_tag):

Expand All @@ -411,7 +420,7 @@ def _parse_add_notifying_service_config(data, notifications, service_key,
'Value': xml_filter_rule.get_child_text('Value'),
}
for xml_filter_rule in xml_filter_rules.findall(
'./S3Key/FilterRule')
'./S3Key/FilterRule')
]
}
}
Expand All @@ -426,6 +435,7 @@ def _parse_add_notifying_service_config(data, notifications, service_key,

return notifications


def parse_multi_object_delete_response(data):
"""Parser for Multi-Object Delete API response.

Expand Down