当前位置: 首页>>代码示例>>Python>>正文


Python utils.camelcase_to_underscores函数代码示例

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


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


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