Remove duplicated method
This commit is contained in:
parent
888e0c31a0
commit
c32c17a13e
@ -196,22 +196,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="DhcpConfiguration"):
|
def dhcp_configuration_from_querystring(querystring, option="DhcpConfiguration"):
|
||||||
"""
|
"""
|
||||||
turn:
|
turn:
|
||||||
|
@ -10,9 +10,10 @@ from six.moves.urllib.parse import urlparse
|
|||||||
from moto.core.responses import AWSServiceSpec
|
from moto.core.responses import AWSServiceSpec
|
||||||
from moto.core.responses import BaseResponse
|
from moto.core.responses import BaseResponse
|
||||||
from moto.core.responses import xml_to_json_response
|
from moto.core.responses import xml_to_json_response
|
||||||
|
from moto.core.utils import tags_from_query_string
|
||||||
from .exceptions import EmrError
|
from .exceptions import EmrError
|
||||||
from .models import emr_backends
|
from .models import emr_backends
|
||||||
from .utils import steps_from_query_string, tags_from_query_string
|
from .utils import steps_from_query_string
|
||||||
|
|
||||||
|
|
||||||
def generate_boto3_response(operation):
|
def generate_boto3_response(operation):
|
||||||
@ -91,7 +92,7 @@ class ElasticMapReduceResponse(BaseResponse):
|
|||||||
@generate_boto3_response("AddTags")
|
@generate_boto3_response("AddTags")
|
||||||
def add_tags(self):
|
def add_tags(self):
|
||||||
cluster_id = self._get_param("ResourceId")
|
cluster_id = self._get_param("ResourceId")
|
||||||
tags = tags_from_query_string(self.querystring)
|
tags = tags_from_query_string(self.querystring, prefix="Tags")
|
||||||
self.backend.add_tags(cluster_id, tags)
|
self.backend.add_tags(cluster_id, tags)
|
||||||
template = self.response_template(ADD_TAGS_TEMPLATE)
|
template = self.response_template(ADD_TAGS_TEMPLATE)
|
||||||
return template.render()
|
return template.render()
|
||||||
|
@ -22,22 +22,6 @@ def random_instance_group_id(size=13):
|
|||||||
return "i-{0}".format(random_id())
|
return "i-{0}".format(random_id())
|
||||||
|
|
||||||
|
|
||||||
def tags_from_query_string(querystring_dict):
|
|
||||||
prefix = "Tags"
|
|
||||||
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("Tags.{0}.Key".format(tag_index))[0]
|
|
||||||
tag_value_key = "Tags.{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 steps_from_query_string(querystring_dict):
|
def steps_from_query_string(querystring_dict):
|
||||||
steps = []
|
steps = []
|
||||||
for step in querystring_dict:
|
for step in querystring_dict:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user