Skip to content

Commit

Permalink
fix pylint errors in parsers.py
Browse files Browse the repository at this point in the history
  • Loading branch information
balamurugana committed May 7, 2020
1 parent a0065ce commit 77883e7
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
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; 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; 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

0 comments on commit 77883e7

Please sign in to comment.