Exemplo n.º 1
0
def test_decamel():
    assert utils.decamel("thisIsACamelCase") == "this_is_a_camel_case"
    assert utils.decamel("thisIsACamelCase") == "this_is_a_camel_case"
    assert utils.decamel('CamelCamelCase') == "camel_camel_case"
    assert utils.decamel('Camel2Camel2Case') == 'camel2_camel2_case'
    assert utils.decamel('getHTTPResponseCode') == 'get_http_response_code'
    assert utils.decamel('get2HTTPResponseCode') == 'get2_http_response_code'
    assert utils.decamel('HTTPResponseCode') == 'http_response_code'
    assert utils.decamel('HTTPResponseCodeXYZ') == 'http_response_code_xyz'
Exemplo n.º 2
0
def test_decamel():
    assert utils.decamel("thisIsACamelCase") == "this_is_a_camel_case"
    assert utils.decamel("thisIsACamelCase") == "this_is_a_camel_case"
    assert utils.decamel('CamelCamelCase') == "camel_camel_case"
    assert utils.decamel('Camel2Camel2Case') == 'camel2_camel2_case'
    assert utils.decamel('getHTTPResponseCode') == 'get_http_response_code'
    assert utils.decamel('get2HTTPResponseCode') == 'get2_http_response_code'
    assert utils.decamel('HTTPResponseCode') == 'http_response_code'
    assert utils.decamel('HTTPResponseCodeXYZ') == 'http_response_code_xyz'
Exemplo n.º 3
0
Arquivo: api.py Projeto: daris/pmatic
        def decamel_dict_keys(d):
            for k in d:
                value = d.pop(k)

                if isinstance(value, list):
                    for entry in value:
                        if isinstance(entry, dict):
                            decamel_dict_keys(entry)

                d[utils.decamel(k)] = value
            return d
Exemplo n.º 4
0
        def decamel_dict_keys(d):
            for k in d:
                value = d.pop(k)

                if isinstance(value, list):
                    for entry in value:
                        if isinstance(entry, dict):
                            decamel_dict_keys(entry)

                d[utils.decamel(k)] = value
            return d
Exemplo n.º 5
0
        def decamel_dict_keys(d):
            temp = {}
            for k in d.keys():
                value = d[k]

                if isinstance(value, list):
                    for idx, entry in enumerate(value):
                        if isinstance(entry, dict):
                            value[idx] = decamel_dict_keys(entry)

                temp[utils.decamel(k)] = value
            return temp
Exemplo n.º 6
0
    def _to_internal_name(self, method_name_api):
        """Translates a raw API method name to the pmatic notation.

        These modifications are made:

        * . are replaced with _
        * BidCoS is replaced with bidcos
        * ReGa is replaced with rega
        * whole string is transformed from camel case to lowercase + underscore notation

        e.g. Interface.activateLinkParamset is changed to API.interface_activate_link_paramset
        """
        return utils.decamel(method_name_api.replace(".", "_")) \
                                            .replace("bid_co_s", "bidcos") \
                                            .replace("re_ga", "rega") \
                                            .replace("__", "_")
Exemplo n.º 7
0
    def _to_internal_name(self, method_name_api):
        """Translates a raw API method name to the pmatic notation.

        These modifications are made:

        * . are replaced with _
        * BidCoS is replaced with bidcos
        * ReGa is replaced with rega
        * whole string is transformed from camel case to lowercase + underscore notation

        e.g. Interface.activateLinkParamset is changed to API.interface_activate_link_paramset
        """
        return utils.decamel(method_name_api.replace(".", "_")) \
                                            .replace("bid_co_s", "bidcos") \
                                            .replace("re_ga", "rega") \
                                            .replace("__", "_")
Exemplo n.º 8
0
    def bidcos_interfaces(self):
        """Provides a list of all BidCos interfaces of the CCU.

        Example output:
          [{u'address': u'KEQ0714972',
            u'description': u'',
            u'duty_cycle': 0,
            u'is_connected': True,
            u'is_default': True}]
        """
        interfaces = []
        for interface in self.api.interface_list_bidcos_interfaces(interface="BidCos-RF"):
            new = {}
            for key, val in interface.items():
                if key == "dutyCycle":
                    val = int(val)
                new[utils.decamel(key)] = val
            interfaces.append(new)

        return interfaces
Exemplo n.º 9
0
    def bidcos_interfaces(self):
        """Provides a list of all BidCos interfaces of the CCU.

        Example output:
          [{u'address': u'KEQ0714972',
            u'description': u'',
            u'duty_cycle': 0,
            u'is_connected': True,
            u'is_default': True}]
        """
        interfaces = []
        for interface in self.api.interface_list_bidcos_interfaces(
                interface="BidCos-RF"):
            new = {}
            for key, val in interface.items():
                if key == "dutyCycle":
                    val = int(val)
                new[utils.decamel(key)] = val
            interfaces.append(new)

        return interfaces
Exemplo n.º 10
0
 def decamel_dict_keys(d):
     temp = {}
     for k in d.keys():
         temp[utils.decamel(k)] = d[k]
     return temp
Exemplo n.º 11
0
Arquivo: api.py Projeto: daris/pmatic
 def decamel_dict_keys(d):
     for k in d:
         d[utils.decamel(k)] = d.pop(k)
     return d
Exemplo n.º 12
0
 def decamel_dict_keys(d):
     for k in d:
         d[utils.decamel(k)] = d.pop(k)
     return d