• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python utils.camelcase_to_underscores函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中moto.core.utils.camelcase_to_underscores函数的典型用法代码示例。如果您正苦于以下问题:Python camelcase_to_underscores函数的具体用法?Python camelcase_to_underscores怎么用?Python camelcase_to_underscores使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了camelcase_to_underscores函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: attributes

    def attributes(self):
        result = {}

        for attribute in self.base_attributes:
            attr = getattr(self, camelcase_to_underscores(attribute))
            result[attribute] = attr

        if self.fifo_queue:
            for attribute in self.fifo_attributes:
                attr = getattr(self, camelcase_to_underscores(attribute))
                result[attribute] = attr

        if self.kms_master_key_id:
            for attribute in self.kms_attributes:
                attr = getattr(self, camelcase_to_underscores(attribute))
                result[attribute] = attr

        if self.policy:
            result['Policy'] = self.policy

        if self.redrive_policy:
            result['RedrivePolicy'] = json.dumps(self.redrive_policy)

        for key in result:
            if isinstance(result[key], bool):
                result[key] = str(result[key]).lower()

        return result
开发者ID:copland,项目名称:moto,代码行数:28,代码来源:models.py


示例2: test_camelcase_to_underscores

def test_camelcase_to_underscores():
    cases = {
        "theNewAttribute": "the_new_attribute",
        "attri bute With Space": "attribute_with_space",
        "FirstLetterCapital": "first_letter_capital",
    }
    for arg, expected in cases.items():
        camelcase_to_underscores(arg).should.equal(expected)
开发者ID:DarthLorenzo,项目名称:moto,代码行数:8,代码来源:test_utils.py


示例3: set_queue_attributes

 def set_queue_attributes(self):
     queue_name = self._get_queue_name()
     if "Attribute.Name" in self.querystring:
         key = camelcase_to_underscores(self.querystring.get("Attribute.Name")[0])
         value = self.querystring.get("Attribute.Value")[0]
         self.sqs_backend.set_queue_attribute(queue_name, key, value)
     for a in self._get_list_prefix("Attribute"):
         key = camelcase_to_underscores(a["name"])
         value = a["value"]
         self.sqs_backend.set_queue_attribute(queue_name, key, value)
     return SET_QUEUE_ATTRIBUTE_RESPONSE
开发者ID:adamdeprince,项目名称:moto,代码行数:11,代码来源:responses.py


示例4: set_queue_attributes

 def set_queue_attributes(self):
     # TODO validate self.get_param('QueueUrl')
     queue_name = self._get_queue_name()
     for key, value in self.attribute.items():
         key = camelcase_to_underscores(key)
         self.sqs_backend.set_queue_attribute(queue_name, key, value)
     return SET_QUEUE_ATTRIBUTE_RESPONSE
开发者ID:whummer,项目名称:moto,代码行数:7,代码来源:responses.py


示例5: _get_dict_param

 def _get_dict_param(self, param_prefix):
     return {
         camelcase_to_underscores(key.replace(param_prefix, "")): value[0]
         for key, value
         in self.querystring.items()
         if key.startswith(param_prefix)
     }
开发者ID:attili,项目名称:moto,代码行数:7,代码来源:responses.py


示例6: dispatch

 def dispatch(self):
     endpoint = self.get_endpoint_name(self.headers)
     if endpoint:
         endpoint = camelcase_to_underscores(endpoint)
         return getattr(self, endpoint)(self.uri, self.method, self.body, self.headers)
     else:
         return "", dict(status=404)
开发者ID:Katafalkas,项目名称:moto,代码行数:7,代码来源:responses.py


示例7: describe_vpc_attribute

 def describe_vpc_attribute(self):
     vpc_id = self.querystring.get('VpcId')[0]
     attribute = self.querystring.get('Attribute')[0]
     attr_name = camelcase_to_underscores(attribute)
     value = self.ec2_backend.describe_vpc_attribute(vpc_id, attr_name)
     template = self.response_template(DESCRIBE_VPC_ATTRIBUTE_RESPONSE)
     return template.render(vpc_id=vpc_id, attribute=attribute, value=value)
开发者ID:balintzs,项目名称:moto,代码行数:7,代码来源:vpcs.py


示例8: call_action

    def call_action(self):
        headers = self.response_headers
        action = self.querystring.get('Action', [""])[0]
        if not action:  # Some services use a header for the action
            # Headers are case-insensitive. Probably a better way to do this.
            match = self.headers.get(
                'x-amz-target') or self.headers.get('X-Amz-Target')
            if match:
                action = match.split(".")[-1]

        action = camelcase_to_underscores(action)
        method_names = method_names_from_class(self.__class__)
        if action in method_names:
            method = getattr(self, action)
            try:
                response = method()
            except HTTPException as http_error:
                response = http_error.description, dict(status=http_error.code)
            if isinstance(response, six.string_types):
                return 200, headers, response
            else:
                body, new_headers = response
                status = new_headers.get('status', 200)
                headers.update(new_headers)
                # Cast status to string
                if "status" in headers:
                    headers['status'] = str(headers['status'])
                return status, headers, body

        raise NotImplementedError(
            "The {0} action has not been implemented".format(action))
开发者ID:netors,项目名称:moto,代码行数:31,代码来源:responses.py


示例9: call_action

    def call_action(self):
        headers = self.response_headers
        action = camelcase_to_underscores(self._get_action())
        method_names = method_names_from_class(self.__class__)
        if action in method_names:
            method = getattr(self, action)
            try:
                response = method()
            except HTTPException as http_error:
                response = http_error.description, dict(status=http_error.code)

            if isinstance(response, six.string_types):
                return 200, headers, response
            else:
                if len(response) == 2:
                    body, new_headers = response
                else:
                    status, new_headers, body = response
                status = new_headers.get('status', 200)
                headers.update(new_headers)
                # Cast status to string
                if "status" in headers:
                    headers['status'] = str(headers['status'])
                return status, headers, body

        if not action:
            return 404, headers, ''

        raise NotImplementedError(
            "The {0} action has not been implemented".format(action))
开发者ID:spulec,项目名称:moto,代码行数:30,代码来源:responses.py


示例10: describe_instance_attribute

 def describe_instance_attribute(self):
     # TODO this and modify below should raise IncorrectInstanceState if instance not in stopped state
     attribute = self.querystring.get("Attribute")[0]
     key = camelcase_to_underscores(attribute)
     instance_id = self.instance_ids[0]
     instance, value = ec2_backend.describe_instance_attribute(instance_id, key)
     template = Template(EC2_DESCRIBE_INSTANCE_ATTRIBUTE)
     return template.render(instance=instance, attribute=attribute, value=value)
开发者ID:Katafalkas,项目名称:moto,代码行数:8,代码来源:instances.py


示例11: attributes

 def attributes(self):
     result = {}
     for attribute in self.camelcase_attributes:
         attr = getattr(self, camelcase_to_underscores(attribute))
         if isinstance(attr, bool):
             attr = str(attr).lower()
         result[attribute] = attr
     return result
开发者ID:whummer,项目名称:moto,代码行数:8,代码来源:models.py


示例12: modify_vpc_attribute

    def modify_vpc_attribute(self):
        vpc_id = self.querystring.get('VpcId')[0]

        for attribute in ('EnableDnsSupport', 'EnableDnsHostnames'):
            if self.querystring.get('%s.Value' % attribute):
                attr_name = camelcase_to_underscores(attribute)
                attr_value = self.querystring.get('%s.Value' % attribute)[0]
                self.ec2_backend.modify_vpc_attribute(vpc_id, attr_name, attr_value)
                return MODIFY_VPC_ATTRIBUTE_RESPONSE
开发者ID:balintzs,项目名称:moto,代码行数:9,代码来源:vpcs.py


示例13: modify_instance_attribute

    def modify_instance_attribute(self):
        for key, value in self.querystring.iteritems():
            if ".Value" in key:
                break

        value = self.querystring.get(key)[0]
        normalized_attribute = camelcase_to_underscores(key.split(".")[0])
        instance_id = self.instance_ids[0]
        ec2_backend.modify_instance_attribute(instance_id, normalized_attribute, value)
        return EC2_MODIFY_INSTANCE_ATTRIBUTE
开发者ID:Katafalkas,项目名称:moto,代码行数:10,代码来源:instances.py


示例14: modify_subnet_attribute

    def modify_subnet_attribute(self):
        subnet_id = self._get_param('SubnetId')

        for attribute in ('MapPublicIpOnLaunch', 'AssignIpv6AddressOnCreation'):
            if self.querystring.get('%s.Value' % attribute):
                attr_name = camelcase_to_underscores(attribute)
                attr_value = self.querystring.get('%s.Value' % attribute)[0]
                self.ec2_backend.modify_subnet_attribute(
                    subnet_id, attr_name, attr_value)
                return MODIFY_SUBNET_ATTRIBUTE_RESPONSE
开发者ID:spulec,项目名称:moto,代码行数:10,代码来源:subnets.py


示例15: to_full_dict

 def to_full_dict(self):
     hsh = {
         "typeInfo": self.to_medium_dict(),
         "configuration": {}
     }
     if self.task_list:
         hsh["configuration"]["defaultTaskList"] = {"name": self.task_list}
     for key in self._configuration_keys:
         attr = camelcase_to_underscores(key)
         if not getattr(self, attr):
             continue
         hsh["configuration"][key] = getattr(self, attr)
     return hsh
开发者ID:2rs2ts,项目名称:moto,代码行数:13,代码来源:generic_type.py


示例16: _get_list_prefix

 def _get_list_prefix(self, param_prefix):
     results = []
     param_index = 1
     while True:
         index_prefix = "{0}.{1}.".format(param_prefix, param_index)
         new_items = {}
         for key, value in self.querystring.items():
             if key.startswith(index_prefix):
                 new_items[camelcase_to_underscores(key.replace(index_prefix, ""))] = value[0]
         if not new_items:
             break
         results.append(new_items)
         param_index += 1
     return results
开发者ID:Anislav,项目名称:moto,代码行数:14,代码来源:responses.py


示例17: set_topic_attributes

    def set_topic_attributes(self):
        topic_arn = self._get_param('TopicArn')
        attribute_name = self._get_param('AttributeName')
        attribute_name = camelcase_to_underscores(attribute_name)
        attribute_value = self._get_param('AttributeValue')
        self.backend.set_topic_attribute(topic_arn, attribute_name, attribute_value)

        return json.dumps({
            "SetTopicAttributesResponse": {
                "ResponseMetadata": {
                    "RequestId": "a8763b99-33a7-11df-a9b7-05d48da6f042"
                }
            }
        })
开发者ID:mob-akiyama,项目名称:moto,代码行数:14,代码来源:responses.py


示例18: call_action

    def call_action(self):
        self.body = json.loads(self.body or '{}')
        endpoint = self.get_endpoint_name(self.headers)
        if endpoint:
            endpoint = camelcase_to_underscores(endpoint)
            response = getattr(self, endpoint)()
            if isinstance(response, six.string_types):
                return 200, self.response_headers, response

            else:
                status_code, new_headers, response_content = response
                self.response_headers.update(new_headers)
                return status_code, self.response_headers, response_content
        else:
            return 404, self.response_headers, ""
开发者ID:singingwolfboy,项目名称:moto,代码行数:15,代码来源:responses.py


示例19: describe_instance_attribute

    def describe_instance_attribute(self):
        # TODO this and modify below should raise IncorrectInstanceState if
        # instance not in stopped state
        attribute = self.querystring.get("Attribute")[0]
        key = camelcase_to_underscores(attribute)
        instance_ids = instance_ids_from_querystring(self.querystring)
        instance_id = instance_ids[0]
        instance, value = self.ec2_backend.describe_instance_attribute(instance_id, key)

        if key == "group_set":
            template = self.response_template(EC2_DESCRIBE_INSTANCE_GROUPSET_ATTRIBUTE)
        else:
            template = self.response_template(EC2_DESCRIBE_INSTANCE_ATTRIBUTE)

        return template.render(instance=instance, attribute=attribute, value=value)
开发者ID:rouge8,项目名称:moto,代码行数:15,代码来源:instances.py


示例20: __init__

 def __init__(self, name, version, **kwargs):
     self.name = name
     self.version = version
     self.status = "REGISTERED"
     if "description" in kwargs:
         self.description = kwargs.pop("description")
     for key, value in kwargs.items():
         self.__setattr__(key, value)
     # default values set to none
     for key in self._configuration_keys:
         attr = camelcase_to_underscores(key)
         if not hasattr(self, attr):
             self.__setattr__(attr, None)
     if not hasattr(self, "task_list"):
         self.task_list = None
开发者ID:2rs2ts,项目名称:moto,代码行数:15,代码来源:generic_type.py



注:本文中的moto.core.utils.camelcase_to_underscores函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python utils.iso_8601_datetime_with_milliseconds函数代码示例发布时间:2022-05-27
下一篇:
Python compat.OrderedDict类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap