Move tags_from_query_string to core.utils
This commit is contained in:
parent
6f23a39fc2
commit
91fb408102
@ -297,3 +297,20 @@ def path_url(url):
|
|||||||
if parsed_url.query:
|
if parsed_url.query:
|
||||||
path = path + '?' + parsed_url.query
|
path = path + '?' + parsed_url.query
|
||||||
return path
|
return path
|
||||||
|
|
||||||
|
|
||||||
|
def tags_from_query_string(querystring_dict):
|
||||||
|
prefix = 'Tag'
|
||||||
|
suffix = 'Key'
|
||||||
|
response_values = {}
|
||||||
|
for key, value in querystring_dict.items():
|
||||||
|
if key.startswith(prefix) and key.endswith(suffix):
|
||||||
|
tag_index = key.replace(prefix + ".", "").replace("." + suffix, "")
|
||||||
|
tag_key = querystring_dict.get("Tag.{0}.Key".format(tag_index))[0]
|
||||||
|
tag_value_key = "Tag.{0}.Value".format(tag_index)
|
||||||
|
if tag_value_key in querystring_dict:
|
||||||
|
response_values[tag_key] = querystring_dict.get(tag_value_key)[
|
||||||
|
0]
|
||||||
|
else:
|
||||||
|
response_values[tag_key] = None
|
||||||
|
return response_values
|
||||||
|
@ -2,7 +2,8 @@ from __future__ import unicode_literals
|
|||||||
|
|
||||||
from moto.core.responses import BaseResponse
|
from moto.core.responses import BaseResponse
|
||||||
from moto.ec2.models import validate_resource_ids
|
from moto.ec2.models import validate_resource_ids
|
||||||
from moto.ec2.utils import tags_from_query_string, filters_from_querystring
|
from moto.ec2.utils import filters_from_querystring
|
||||||
|
from moto.core.utils import tags_from_query_string
|
||||||
|
|
||||||
|
|
||||||
class TagResponse(BaseResponse):
|
class TagResponse(BaseResponse):
|
||||||
|
@ -198,23 +198,6 @@ def split_route_id(route_id):
|
|||||||
return values[0], values[1]
|
return values[0], values[1]
|
||||||
|
|
||||||
|
|
||||||
def tags_from_query_string(querystring_dict):
|
|
||||||
prefix = 'Tag'
|
|
||||||
suffix = 'Key'
|
|
||||||
response_values = {}
|
|
||||||
for key, value in querystring_dict.items():
|
|
||||||
if key.startswith(prefix) and key.endswith(suffix):
|
|
||||||
tag_index = key.replace(prefix + ".", "").replace("." + suffix, "")
|
|
||||||
tag_key = querystring_dict.get("Tag.{0}.Key".format(tag_index))[0]
|
|
||||||
tag_value_key = "Tag.{0}.Value".format(tag_index)
|
|
||||||
if tag_value_key in querystring_dict:
|
|
||||||
response_values[tag_key] = querystring_dict.get(tag_value_key)[
|
|
||||||
0]
|
|
||||||
else:
|
|
||||||
response_values[tag_key] = None
|
|
||||||
return response_values
|
|
||||||
|
|
||||||
|
|
||||||
def dhcp_configuration_from_querystring(querystring, option=u'DhcpConfiguration'):
|
def dhcp_configuration_from_querystring(querystring, option=u'DhcpConfiguration'):
|
||||||
"""
|
"""
|
||||||
turn:
|
turn:
|
||||||
|
Loading…
Reference in New Issue
Block a user