Beispiel #1
0
def check_loc():
    veil_component.load_all_components()
    component_files = {}
    for module_name, module in sys.modules.items():
        component_name = veil_component.get_leaf_component(module_name)
        if component_name and hasattr(module, '__file__'):
            module_file = module.__file__.replace('.pyc', '.py')
            module_loc = get_loc(module_file)
            component_files.setdefault(component_name, []).append(
                (module_file, module_loc))
    max_loc = 0
    application = get_application()
    ignored_app_components = getattr(application,
                                     'LOC_CHECK_IGNORED_COMPONENTS', set())
    ignored_app_component_prefixes = getattr(
        application, 'LOC_CHECK_IGNORED_COMPONENT_PREFIXES', set())
    for component_name in sorted(component_files):
        files = component_files[component_name]
        component_loc = sum(f[1] for f in files)
        if component_name not in WHITE_LIST and component_name not in ignored_app_components and all(
                not component_name.startswith(prefix)
                for prefix in ignored_app_component_prefixes):
            max_loc = max(component_loc, max_loc)
            if component_loc > THRESHOLD:
                raise Exception(
                    '{} contains {} lines of code, extract component out!\n{}'.
                    format(component_name, component_loc,
                           '\n'.join(unicode(f) for f in files)))
    if THRESHOLD > GOAL and THRESHOLD - max_loc > 50:
        raise Exception('Threshold can be reduced to {} now', max_loc)
Beispiel #2
0
 def wrapper(**kwargs):
     if not kwargs.pop('do_install', False):
         return '{}.{}'.format(veil_component.get_leaf_component(func.__module__), func.__name__), kwargs
     try:
         executing_installers.append(func)
         return func(**kwargs)
     finally:
         executing_installers.pop()
Beispiel #3
0
def check_logger():
    wrong_usages_count = 0
    for module_name, module in sys.modules.items():
        component_name = veil_component.get_leaf_component(module_name)
        if component_name and hasattr(module, '__file__'):
            module_file = module.__file__.replace('.pyc', '.py')
            if check_file(module_file):
                wrong_usages_count += 1
    if wrong_usages_count:
        raise Exception('Loggers were not being used correctly, in {} places'.format(wrong_usages_count))
Beispiel #4
0
 def wrapper(**kwargs):
     if not kwargs.pop('do_install', False):
         return '{}.{}'.format(
             veil_component.get_leaf_component(func.__module__),
             func.__name__), kwargs
     try:
         executing_installers.append(func)
         return func(**kwargs)
     finally:
         executing_installers.pop()
Beispiel #5
0
def check_logger():
    wrong_usages_count = 0
    for module_name, module in sys.modules.items():
        component_name = veil_component.get_leaf_component(module_name)
        if component_name and hasattr(module, '__file__'):
            module_file = module.__file__.replace('.pyc', '.py')
            if check_file(module_file):
                wrong_usages_count += 1
    if wrong_usages_count:
        raise Exception('Loggers were not being used correctly, in {} places'.format(wrong_usages_count))
Beispiel #6
0
def check_loc():
    component_files = {}
    for module_name, module in sys.modules.items():
        component_name = veil_component.get_leaf_component(module_name)
        if component_name and hasattr(module, '__file__'):
            module_file = module.__file__.replace('.pyc', '.py')
            module_loc = get_loc(module_file)
            component_files.setdefault(component_name, []).append((module_file, module_loc))
    max_loc = 0
    for component_name in sorted(component_files.keys()):
        files = component_files[component_name]
        component_loc = sum(f[1] for f in files)
        if component_name not in WHITE_LIST:
            max_loc = max(component_loc, max_loc)
            if component_loc > THRESHOLD:
                raise Exception('{} contains {} lines of code, extract component out!\n{}'.format(
                    component_name, component_loc, '\n'.join(str(f) for f in files)))
    if THRESHOLD > GOAL and THRESHOLD - max_loc > 50:
        raise Exception('Threshold can be reduced to {} now', max_loc)
Beispiel #7
0
def check_loc():
    veil_component.load_all_components()
    component_files = {}
    for module_name, module in sys.modules.items():
        component_name = veil_component.get_leaf_component(module_name)
        if component_name and hasattr(module, '__file__'):
            module_file = module.__file__.replace('.pyc', '.py')
            module_loc = get_loc(module_file)
            component_files.setdefault(component_name, []).append((module_file, module_loc))
    max_loc = 0
    application = get_application()
    ignored_app_components = getattr(application, 'LOC_CHECK_IGNORED_COMPONENTS', set())
    ignored_app_component_prefixes = getattr(application, 'LOC_CHECK_IGNORED_COMPONENT_PREFIXES', set())
    for component_name in sorted(component_files):
        files = component_files[component_name]
        component_loc = sum(f[1] for f in files)
        if component_name not in WHITE_LIST and component_name not in ignored_app_components and all(
                not component_name.startswith(prefix) for prefix in ignored_app_component_prefixes):
            max_loc = max(component_loc, max_loc)
            if component_loc > THRESHOLD:
                raise Exception('{} contains {} lines of code, extract component out!\n{}'.format(
                    component_name, component_loc, '\n'.join(unicode(f) for f in files)))
    if THRESHOLD > GOAL and THRESHOLD - max_loc > 50:
        raise Exception('Threshold can be reduced to {} now', max_loc)