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 pylint errors in parsers.py #915

Merged
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

check:
@which pylint >/dev/null || pip install --user --upgrade pylint
@if python --version | grep -qi 'python 3'; then pylint --reports=no minio/copy_conditions.py minio/definitions.py minio/signer.py minio/__init__.py; fi
@if python --version | grep -qi 'python 3'; then pylint --reports=no minio/copy_conditions.py minio/definitions.py minio/parsers.py minio/signer.py minio/__init__.py; fi

@which isort >/dev/null || pip install --user --upgrade isort
@isort --diff --recursive .
Expand Down
4 changes: 2 additions & 2 deletions minio/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
parse_list_buckets, parse_list_multipart_uploads,
parse_list_objects, parse_list_objects_v2,
parse_list_parts, parse_location_constraint,
parse_multi_object_delete_response,
parse_multi_delete_response,
parse_multipart_upload_result,
parse_new_multipart_upload)
from .select import SelectObjectReader
Expand Down Expand Up @@ -1176,7 +1176,7 @@ def _process_remove_objects_batch(self, bucket_name, objects_batch):
)

# parse response to find delete errors
return parse_multi_object_delete_response(response.data)
return parse_multi_delete_response(response.data)

def remove_objects(self, bucket_name, objects_iter):
"""
Expand Down
24 changes: 12 additions & 12 deletions minio/parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,14 @@

"""

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

from .compat import unquote
from .definitions import (Bucket, CopyObjectResult, IncompleteUpload,
MultipartUploadResult, Object, UploadPart)
# minio specific.
from .error import ETREE_EXCEPTIONS, InvalidXMLError, MultiDeleteError
from .error import InvalidXMLError, MultiDeleteError
from .helpers import _iso8601_to_utc_datetime
from .xml_marshal import NOTIFICATIONS_ARN_FIELDNAME_MAP

Expand All @@ -46,7 +45,7 @@
}


class S3Element(object):
class S3Element:
"""S3 aware XML parsing class. Wraps a root element name and
ElementTree.Element instance. Provides S3 namespace aware parsing
functions.
Expand All @@ -67,7 +66,7 @@ def fromstring(cls, root_name, data):
"""
try:
return cls(root_name, ElementTree.fromstring(data.strip()))
except ETREE_EXCEPTIONS as error:
except (ParseError, AttributeError, ValueError, TypeError) as error:
raise InvalidXMLError(
'"{}" XML is not parsable. Message: {}'.format(
root_name, error
Expand Down Expand Up @@ -99,7 +98,7 @@ def get_child_text(self, name, strict=True):
if strict:
try:
return self.element.find('s3:{}'.format(name), _XML_NS).text
except ETREE_EXCEPTIONS as error:
except (ParseError, AttributeError, ValueError, TypeError) as error:
raise InvalidXMLError(
('Invalid XML provided for "{}" - erroring tag <{}>. '
'Message: {}').format(self.root_name, name, error)
Expand Down Expand Up @@ -366,24 +365,25 @@ def parse_get_bucket_notification(data):
"""
root = S3Element.fromstring('GetBucketNotificationResult', data)

notifications = _parse_add_notifying_service_config(
notifications = _add_notifying_service_config(
root, {},
'TopicConfigurations', 'TopicConfiguration'
)
notifications = _parse_add_notifying_service_config(
notifications = _add_notifying_service_config(
root, notifications,
'QueueConfigurations', 'QueueConfiguration'
)
notifications = _parse_add_notifying_service_config(
notifications = _add_notifying_service_config(
root, notifications,
'CloudFunctionConfigurations', 'CloudFunctionConfiguration'
)

return notifications


def _parse_add_notifying_service_config(data, notifications, service_key,
service_xml_tag):
def _add_notifying_service_config(data, notifications, service_key,
service_xml_tag):
"""Add service configuration in notification."""

arn_elt_name = NOTIFICATIONS_ARN_FIELDNAME_MAP[service_xml_tag]
config = []
Expand Down Expand Up @@ -419,7 +419,7 @@ def _parse_add_notifying_service_config(data, notifications, service_key,
return notifications


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

:param data: XML response body content from service.
Expand Down