Did I find the right examples for you? yes no      Crawl my project      Python Jobs

All Samples(4)  |  Call(3)  |  Derive(0)  |  Import(1)
Given a module, recursively find all the modules and libraries it depends on (transitively)

return a 3 tuple (relations,mod_set,lib_set) where:

relations is a list of two tuples (A,B), where A and B are modules and A depends on B
mod_set: will be filled with all the modules top_mod depends on
lib_set: will be filled with all libraries top_mod depends on

        def collect_dependencies(top_mod):
    """
    Given a module, recursively find all the modules and libraries it depends on (transitively)

    return a 3 tuple (relations,mod_set,lib_set) where:

    relations is a list of two tuples (A,B), where A and B are modules and A depends on B
    mod_set: will be filled with all the modules top_mod depends on
    lib_set: will be filled with all libraries top_mod depends on
    """
    # already computed?
    if mod_dep_mods.has_key(top_mod):
        return (mod_dep_relations[top_mod], mod_dep_mods[top_mod], mod_dep_libs[top_mod])

    module = __import__(top_mod)
    mod_name_mapping[top_mod] = module
    deps = find_direct_dependencies(top_mod)
    dep_relations = [ (top_mod,x ) for x in deps ]
    mod_set = set()
    lib_set = set()
    if hasattr(module, 'libs'):
        lib_set |= set(module.libs)

    # recursively add
    for dep in deps:
        if not dep in mod_set: # deal with cycles and a module appear a dependency twice
            sub_relations, sub_mods, sub_libs = collect_dependencies(dep)
            dep_relations += sub_relations
            mod_set |= sub_mods
            lib_set |= sub_libs
        mod_set.add(dep)

    mod_dep_mods[top_mod] = mod_set
    mod_dep_libs[top_mod] = lib_set
    mod_dep_relations[top_mod] = dep_relations
    return dep_relations, mod_set, lib_set
        


src/l/a/lattice-HEAD/lattice/__main__.py   lattice(Download)
import modules, pdlibs
import tasks
from modules import  collect_dependencies, find_all_mods
import inspect
 
        if verbose:
            print mod
        dummy, dep_mods, libs = collect_dependencies(mod)
        eclipse.gen_module(mod, dep_mods, libs, dry_run, verbose)
        bulkprj.write(os.getcwd() + os.sep + mod + '\n')
 
    if options.show_dependencies:
        dummy, deps, libs = collect_dependencies(mod)
        print 'Listing dependencies of module %s: ' % mod
        print 'Modules it depends on (including indirect ones): %s.' % ','.join(deps)

src/l/a/lattice-HEAD/lattice/tasks.py   lattice(Download)
def build(mod,  *args, **dict_p):
    """
    Compile a module, recursively compile all other modules this module depends on first in the correct order
    """
    dep_relations, all_mods, dummy = modules.collect_dependencies(mod)