예제 #1
0
def get_component(componenttype: str):
    '''Get component function by type name (e.g. "Senza::MyComponent")'''

    prefix, _, componenttype = componenttype.partition('::')
    root_package = camel_case_to_underscore(prefix)
    module_name = camel_case_to_underscore(componenttype)
    try:
        module = importlib.import_module('{}.components.{}'.format(root_package, module_name))
    except ImportError:
        # component (module) not found
        return None
    function_name = 'component_{}'.format(module_name)
    return getattr(module, function_name)
예제 #2
0
def get_component(componenttype: str):
    '''Get component function by type name (e.g. "Senza::MyComponent")'''

    prefix, _, componenttype = componenttype.partition('::')
    root_package = camel_case_to_underscore(prefix)
    module_name = camel_case_to_underscore(componenttype)
    try:
        module = importlib.import_module('{}.components.{}'.format(
            root_package, module_name))
    except ImportError:
        # component (module) not found
        return None
    function_name = 'component_{}'.format(module_name)
    return getattr(module, function_name)
예제 #3
0
def test_camel_case_to_underscore():
    assert camel_case_to_underscore(
        'CamelCaseToUnderscore') == 'camel_case_to_underscore'
    assert camel_case_to_underscore('ThisIsABook') == 'this_is_a_book'
    assert camel_case_to_underscore('InstanceID') == 'instance_id'
예제 #4
0
파일: test_utils.py 프로젝트: elezar/senza
def test_camel_case_to_underscore():
    assert camel_case_to_underscore("CamelCaseToUnderscore") == "camel_case_to_underscore"
    assert camel_case_to_underscore("ThisIsABook") == "this_is_a_book"
    assert camel_case_to_underscore("InstanceID") == "instance_id"
예제 #5
0
def test_camel_case_to_underscore():
    assert camel_case_to_underscore('CamelCaseToUnderscore') == 'camel_case_to_underscore'
    assert camel_case_to_underscore('ThisIsABook') == 'this_is_a_book'
    assert camel_case_to_underscore('InstanceID') == 'instance_id'
예제 #6
0
def test_camel_case_to_underscore():
    assert camel_case_to_underscore('CamelCaseToUnderscore') == 'camel_case_to_underscore'