Declan Shanaghy b152c00642 Fix multiple bugs encountered with boto3
* Fix path detection for deleting keys in S3 bucket
* Fix stack deletion ensure delete method exists on object
  * Previous tests were using a stack with no resources
* Fix DESCRIBE_STACK_RESOURCES_RESPONSE,
  * Previously untested code path
2016-04-12 13:58:17 -07:00

25 lines
616 B
Python

from __future__ import unicode_literals
from six.moves.urllib.parse import urlparse
def bucket_name_from_url(url):
pth = urlparse(url).path.lstrip("/")
l = pth.lstrip("/").split("/")
if len(l) == 0 or l[0] == "":
return None
return l[0]
def parse_key_name(path):
return "/".join(path.rstrip("/").split("/")[2:])
def is_delete_keys(request, path, bucket_name):
return (
path == u'/' + bucket_name + u'/?delete' or
path == u'/' + bucket_name + u'?delete' or
(path == u'/' + bucket_name and
getattr(request, "query_string", "") == "delete")
)