Exemplo n.º 1
0
def gen_command(args):
	modules = module_searcher.parse_all()
	modules, mains = module_searcher.filter_mains(modules, args)
	print("Main modules: %s" % ", ".join([m.name for m in mains]))
	module_checker.check(modules)
	source_map = dependency_finder.track(modules)
	depend_generator.gen(config.DEPEND_FILE_NAME, modules, source_map, mains)
Exemplo n.º 2
0
def list_command(args):
    modules = module_searcher.parse_all()
    used_modules, _ = module_searcher.filter_mains(modules, args)
    used_map = {}
    for m in used_modules:
        used_map[m.name] = True
    if len(modules) == 0:
        print "No module found"
    else:
        unused_count = len(modules) - len(used_modules)
        extra = "" if unused_count == 0 else "\033[90m(+%d unused)\033[0m " % unused_count
        print "%d %smodule%s:" % (len(used_modules), extra,
                                  "s" if len(modules) > 1 else "")
        max_len = 0
        for m in modules:
            if len(m.name) > max_len:
                max_len = len(m.name)
        for m in sorted(modules,
                        key=lambda m:
                        (m.name in used_map, not m.is_main, m.name)):
            prefix, suffix = ("\033[90m",
                              "\033[0m") if not m.name in used_map else (
                                  "\033[32m", "\033[0m") if m.is_main else ("",
                                                                            "")
            print(
                "\t%s%-*s (%s)%s" %
                (prefix, max_len, m.name, os.path.relpath(m.base_dir), suffix))
Exemplo n.º 3
0
def gen_command(args):
    modules = module_searcher.parse_all()
    modules, mains = module_searcher.filter_mains(modules, args)
    print("Main modules: %s" % ", ".join([m.name for m in mains]))
    module_checker.check(modules)
    source_map = dependency_finder.track(modules)
    depend_generator.gen(config.DEPEND_FILE_NAME, modules, source_map, mains)
Exemplo n.º 4
0
def check_command(args):
	modules = module_searcher.parse_all()
	module_checker.check(modules)
	dependency_finder.track(modules)
	if len(modules) == 0:
		print "No module found"
	else:
		print "%d modules - OK" % len(modules)
Exemplo n.º 5
0
def print_command(args): # TODO: use args
	modules = module_searcher.parse_all()
	used_modules = module_searcher.filter_unused(modules)
	if len(args) == 0 or args[0] != '--all':
		modules = used_modules
	file_name = module_printer.gen(modules, set([m.name for m in used_modules]))
	print "Module tree generated to %s" % file_name
	utils.open_browser(file_name)
Exemplo n.º 6
0
def check_command(args):
    modules = module_searcher.parse_all()
    module_checker.check(modules)
    dependency_finder.track(modules)
    if len(modules) == 0:
        print "No module found"
    else:
        print "%d modules - OK" % len(modules)
Exemplo n.º 7
0
def print_command(args):  # TODO: use args
    modules = module_searcher.parse_all()
    used_modules = module_searcher.filter_unused(modules)
    if len(args) == 0 or args[0] != '--all':
        modules = used_modules
    file_name = module_printer.gen(modules,
                                   set([m.name for m in used_modules]))
    print "Module tree generated to %s" % file_name
    utils.open_browser(file_name)
Exemplo n.º 8
0
def _info_modules(args):
	modules = module_searcher.parse_all()
	modules = module_searcher.filter_mains(modules, [])
	module_checker.check(modules)
	if len(args) == 0:
		return modules
	arg_modules = []
	for m_name in args:
		ok = False
		for m in modules:
			if m.name == m_name:
				arg_modules.append(m)
				ok = True
				break
		if not ok:
			raise config.BaseError("Unknown module '%s'" % m_name) # TODO: exception
	return arg_modules
Exemplo n.º 9
0
def _info_modules(args):
    modules = module_searcher.parse_all()
    modules = module_searcher.filter_mains(modules, [])
    module_checker.check(modules)
    if len(args) == 0:
        return modules
    arg_modules = []
    for m_name in args:
        ok = False
        for m in modules:
            if m.name == m_name:
                arg_modules.append(m)
                ok = True
                break
        if not ok:
            raise config.BaseError("Unknown module '%s'" %
                                   m_name)  # TODO: exception
    return arg_modules
Exemplo n.º 10
0
def list_command(args):
	modules = module_searcher.parse_all()
	used_modules, _ = module_searcher.filter_mains(modules, args)
	used_map = {}
	for m in used_modules:
		used_map[m.name] = True
	if len(modules) == 0:
		print "No module found"
	else:
		unused_count = len(modules) - len(used_modules)
		extra = "" if unused_count == 0 else "\033[90m(+%d unused)\033[0m " % unused_count
		print "%d %smodule%s:" % (len(used_modules), extra, "s" if len(modules) > 1 else "")
		max_len = 0
		for m in modules:
			if len(m.name) > max_len:
				max_len = len(m.name)
		for m in sorted(modules, key=lambda m: (m.name in used_map, not m.is_main, m.name)):
			prefix, suffix = ("\033[90m", "\033[0m") if not m.name in used_map else ("\033[32m", "\033[0m") if m.is_main else ("", "")
			print ("\t%s%-*s (%s)%s" % (
				prefix, max_len, m.name, os.path.relpath(m.base_dir), suffix
			))