diff --git a/S3/S3.py b/S3/S3.py index 73cef680e..995f16ed0 100644 --- a/S3/S3.py +++ b/S3/S3.py @@ -919,7 +919,9 @@ def object_move(self, src_uri, dst_uri, extra_headers = None): debug("Object %s copied to %s" % (src_uri, dst_uri)) if not response_copy["data"] or getRootTagName(response_copy["data"]) == "CopyObjectResult": self.object_delete(src_uri) - debug("Object %s deleted" % src_uri) + debug("Object '%s' deleted", src_uri) + else: + debug("Object '%s' NOT deleted because of an unexepected response data content.", src_uri) return response_copy def object_info(self, uri): diff --git a/S3/Utils.py b/S3/Utils.py index bde99de3d..6bcfeb292 100644 --- a/S3/Utils.py +++ b/S3/Utils.py @@ -84,16 +84,17 @@ def getPrettyFromXml(xmlstr): __all__.append("getPrettyFromXml") +RE_XML_NAMESPACE = re.compile(b'^(]+?>\s*|\s*)(<\w+) xmlns=[\'"](http://[^\'"]+)[\'"]', re.MULTILINE) def stripNameSpace(xml): """ removeNameSpace(xml) -- remove top-level AWS namespace Operate on raw byte(utf-8) xml string. (Not unicode) """ - r = re.compile(b'^(]+?>\s*)(<\w+) xmlns=[\'"](http://[^\'"]+)[\'"](.*)', re.MULTILINE) - if r.match(xml): - xmlns = r.match(xml).groups()[2] - xml = r.sub("\\1\\2\\4", xml) + xmlns_match = RE_XML_NAMESPACE.match(xml) + if xmlns_match: + xmlns = xmlns_match.group(3) + xml = RE_XML_NAMESPACE.sub("\\1\\2", xml, 1) else: xmlns = None return xml, xmlns @@ -169,9 +170,11 @@ def appendXmlTextNode(tag_name, text, parent): return el __all__.append("appendXmlTextNode") +RE_S3_DATESTRING = re.compile('\.[0-9]*(?:[Z\\-\\+]*?)') + def dateS3toPython(date): # Reset milliseconds to 000 - date = re.compile('\.[0-9]*(?:[Z\\-\\+]*?)').sub(".000", date) + date = RE_S3_DATESTRING.sub(".000", date) return dateutil.parser.parse(date, fuzzy=True) __all__.append("dateS3toPython")