Compute 'requires transitive' dependences by analyzing API dependencies
497133
private Map<Archive, Set<Archive>> computeRequiresTransitive()
        throws IOException
    {
        // parse the input modules
        dependencyFinder.parseExportedAPIs(automaticModules().stream());

        return dependencyFinder.dependences();
    }
55834
def compute_dependency_specs(cls, kwargs=None, payload=None):
    """"""
    for spec in super(ImportRemoteSourcesMixin, cls).compute_dependency_specs(kwargs, payload):
      yield spec

    imported_target_specs = cls.imported_target_specs(kwargs=kwargs, payload=payload)
    for spec in imported_target_specs:
      yield spec
18210
function getDependencies(jsSource) {
  const lines = jsSource.split('\n');
  const dependencies = {
    ol: pkg.version
  };
  for (let i = 0, ii = lines.length; i < ii; ++i) {
    const line = lines[i];
    const importMatch = line.match(importRegEx);
    if (importMatch) {
      const imp = importMatch[1];
      if (!imp.startsWith('ol/') && imp != 'ol') {
        const parts = imp.split('/');
        let dep;
        if (imp.startsWith('@')) {
          dep = parts.slice(0, 2).join('/');
        } else {
          dep = parts[0];
        }
        if (dep in pkg.devDependencies) {
          dependencies[dep] = pkg.devDependencies[dep];
        }
      }
    }
  }
  return dependencies;
}
759371
def i_depend_on_them(decl):
        """"""

        to_be_included = set()
        for dependency_info in get_dependencies_from_decl(decl):
            for ddecl in dependency_info.find_out_depend_on_it_declarations():
                if ddecl:
                    to_be_included.add(ddecl)

        if isinstance(decl.parent, class_declaration.class_t):
            to_be_included.add(decl.parent)
        return to_be_included
428859
async function recDependencies(dependencies, root) {
    let url;

    // TODO think about doing this in parallel using promises

    for (const dependency of Reflect.ownKeys(dependencies)) {
        const range = dependencies[dependency];
        url = `${constants.FIREBASE_DATABASE_URL}/package/${dependency}/versions.json`;
        const versions = await request({
            url,
            method: "GET",
            json: true,
            headers: {
                "content-type": "application/json",
            },
        });

        // Translate db versions to semver versions
        const semverVersions = {};
        for (const version of Reflect.ownKeys(versions)) {
            semverVersions[version.replace(/_/g, '.')] = true;
        }
        const semverMatch = semver.maxSatisfying(Reflect.ownKeys(semverVersions), range);
        const match = semverMatch.replace(/\./g, '_');
        const versionKey = `${dependency}_${match}`;

        // Set result
        if (dependencies[dependency]) {
            Reflect.deleteProperty(dependencies, dependency);
        }
        dependencies[versionKey] = true;

        // check if in dependency list yet
        if (!depencyList[versionKey]) {
            // Resolve new dependencies
            url = `${constants.FIREBASE_DATABASE_URL}/package/${dependency}/version/${match}/dependencies.json`;
            const newDependencies = await request({
                url,
                method: "GET",
                json: true,
                headers: {
                    "content-type": "application/json",
                },
            });

            // Add to dependencyList
            depencyList[versionKey] = {};

            // Resolve new dependencies
            if (newDependencies) {
                depencyList[versionKey].dependencies = await recDependencies(newDependencies);
            }
        }

        if (root) {
            depencyList[versionKey].isRootDependency = true;
        }
        depencyList[versionKey].packageName = dependency;
        depencyList[versionKey].version = match;
    }
    return dependencies;
}
650548
function dependencies(dependencyObject) {
    'use strict';

    function extractSpecificPath(depPath, loadType) {
        if (typeof depPath === 'object') {
            return depPath[loadType];
        }

        return depPath;
    }

    var depNames, depPaths;

    depNames = Object.keys(dependencyObject);
    depPaths = depNames.map(function (depName) {return dependencyObject[depName]; });

    function init(root, factory) {

        if (typeof module === 'object' && module.exports) {
            // Node/CommonJS
            console.log("NODE MODE");
            factory.apply(root, depPaths.map(function (depPath) {return require(extractSpecificPath(depPath, 'node')); }));
        } else if (typeof define === 'function' && define.amd) {
            // AMD
            console.log("AMD MODE");
            define(depPaths.map(function (depPath) { return extractSpecificPath(depPath, 'browser'); }), factory);
        } else {
            // Browser globals
            console.log("GLOBALS MODE");
            factory.apply(root, depNames.map(function (depName) {return root[depName]; }));
        }
    }

    return { init: init };
}
1264213
def _needs_dependencies(p_function):
    
    def build_dependency_information(p_todolist):
        for todo in p_todolist._todos:
            p_todolist._register_todo(todo)

    def inner(self, *args, **kwargs):
        if not self._initialized:
            self._initialized = True

            from topydo.lib.Graph import DirectedGraph
            self._depgraph = DirectedGraph()

            build_dependency_information(self)

        return p_function(self, *args, **kwargs)

    return inner
322080
def _extract_specs_dependencies(specs):
    
    deps = set()
    # for each function
    for signatures in specs.functions.values():
        # for each signature
        for signature in signatures:
            # for each argument
            for t in signature:
                deps.update(pytype_to_deps(t))
    # and each capsule
    for signature in specs.capsules.values():
        # for each argument
        for t in signature:
            deps.update(pytype_to_deps(t))
    # Keep "include" first
    return sorted(deps, key=lambda x: "include" not in x)
207831
async function fetchAllDependents (name) {
  let pkg = await npm.getLatest(name)
  let deps = Object.keys(pkg.dependencies || {})
  if (!deps.length) return []
  let promises = []
  for (let dep of deps) {
    promises.push(fetchAllDependents(dep))
  }
  for (let subdeps of await Promise.all(promises)) {
    deps = deps.concat(subdeps)
  }
  return _.uniq(deps.sort())
}
1224782
function (a, b) {
    var aNeedsB = false;
    var bNeedsA = false;

    aNeedsB = Object.
    keys(a.dependencies).
    some(function (dependency) {
        return dependency === b.name;
    });

    if (aNeedsB) {
        return 1;
    }

    bNeedsA = Object.
    keys(b.dependencies).
    some(function (dependency) {
        return dependency === a.name;
    });

    if (bNeedsA) {
        return -1;
    }

    return 0;
}
134090
function buildDependencyObjectLookup(data, lookup, parentPath) {
  if (lookup == undefined) {
    lookup = {};
  }

  parentPath = parentPath || '';

  for(var k in data.dependencies) {
    var dep = data.dependencies[k];
    depPath = parentPath + '/' + dep.name;

    var lookupKey = 'UNKNOWN'; //If we can't find a key below, something's wrong.
    var depToStore = dep;
    if (dep.name) {
      lookupKey = dep.name + '@' + dep.version
    } else if (dep._from) {
      lookupKey = dep._from;
    } else if (dep.requiredBy) {
      // If we can't find the node_modules folder, we'll get 'requiredBy' instead.
      lookupKey = k + "@" + dep.requiredBy;
      depToStore = extractDep(data.dependencies[k]);
    }

    var existing = lookup[lookupKey];
    if (existing) {
      existing.depPaths.push(depPath);
    } else {
      lookup[lookupKey] = depToStore;
      lookup[lookupKey].depPaths = [depPath];
    }

    buildDependencyObjectLookup(dep, lookup, depPath);
  }
  return lookup;
}
690306
function fetchUnmetDependencies() {
        var runAgain = false;
        for (var id in dependencyMap) {
            _.forEach(dependencyMap[id], function (depId) {
                if (!dependencyMap[depId] && !injectedMap[depId]) {
                    try {
                        loadExternalModule(id, depId);
                    } catch (err) {
                        throw new Error('Error loading dependency ' + depId + ' for ' + id + ': ' + err.message);
                    }

                    runAgain = true;
                }
            });
        }

        if (runAgain) { //continue until all we don't have any more unmet dependencies
            fetchUnmetDependencies();
        }
    }
139957
def dependencies(names)
      names.each do |name|
        calculation = fetch(name, nil)
        next unless calculation

        calculation.dependencies.each do |dependency|
          names << dependency unless names.include?(dependency)
        end
      end
    end
484255
function searchDependencies (dependencies, root) {
  if (!dependencies) {
    return Promise.resolve([])
  } else {
    var pluginPkgPath
    var pluginPkgPaths = []
    for (var key in dependencies) {
      pluginPkgPath = path.join(root, 'node_modules', key)
      pluginPkgPaths.push(pluginPkgPath)
    }
    return Promise.all(pluginPkgPaths.map(function (pkgRoot) {
      var pkgPath = path.join(pkgRoot, 'package.json')
      return readJSON(pkgPath)
        .then(function (pkg) {
          if (pkg.vigour && pkg.vigour.plugin) {
            return searchDependencies(pkg.dependencies, pkgRoot)
              .then(function (deps) {
                return searchDependencies(pkg.dependencies, root)
                  .then(function (otherDeps) {
                    return deps.concat(otherDeps)
                  })
              })
          } else {
            return false
          }
        })
        .catch(function (reason) {
          return false
        })
    }))
    .then(function (arr) {
      arr = _flatten(arr)
      return pluginPkgPaths.concat(arr.reduce(function (prev, curr) {
        if (curr) {
          prev.push(curr)
        }
        return prev
      }, []))
    })
  }
}
133729
function getDependencies(node, name, locals) {
      var deps = [];

      if (!locals) {
        locals = [];
      }

      function log() {
        if (name === 'xxx') {
          console.log.apply(null, [name + ':'].concat(Array.prototype.slice.call(arguments, 0)));
        }
      }

      function pushLocal(loc) {
        if (locals.indexOf(loc) === -1) {
          log('PUSHING LOCAL', loc);
          locals.push(loc);
        }
      }

      function pushDependency(dep) {
        if (deps.indexOf(dep) === -1) {
          log('PUSHING DEPENDENCY', dep);
          deps.push(dep);
        }
      }

      function pushDependencies(arr) {
        arr.forEach(pushDependency);
      }

      function getLocals(nodes) {
        return nodes.map(function(id) {
          return id.name;
        });
      }

      function walk(nodes) {
        if (!nodes) {
          return;
        }
        if (nodes.type) nodes = [nodes];
        nodes.forEach(processNode);
      }

      function processNode(node) {
        log('PROCESSING:', node.type);
        switch(node.type) {
          case 'Identifier':
            pushDependency(node.name);
            return;
          case 'VariableDeclarator':
            pushLocal(node.id.name);
            walk(node.init);
            return;
          case 'FunctionDeclaration':
            pushLocal(node.id.name);
            // Recursively get this function's local dependencies.
            // so that flat locals don't clobber them.
            pushDependencies(getDependencies(node.body, name, getLocals(node.params)));
            return;
          case 'FunctionExpression':
            // Recursively get this function's local dependencies.
            // so that flat locals don't clobber them.
            pushDependencies(getDependencies(node.body, name, getLocals(node.params)));
            return;
          case 'CatchClause':
            pushLocal(node.param);
            walk(node.body);
            return;
          case 'MemberExpression':
            walk(node.object);
            // If the MemberExpression is computed syntax (a[b]) then
            // the property value may be a depencency, so step in.
            if (node.computed) walk(node.property);
            return;
          case 'ExpressionStatement':
            walk(node.expression);
            return;
          case 'SequenceExpression':
            walk(node.expressions);
            return;
          case 'SwitchStatement':
            walk(node.discriminant);
            walk(node.cases);
            return;
          case 'ObjectExpression':
            walk(node.properties);
            return;
          case 'ArrayExpression':
            walk(node.elements);
            return;
          case 'TryStatement':
            walk(node.block);
            walk(node.handler);
            walk(node.finalizer);
            return;
          case 'BlockStatement':
            walk(node.body);
            return;
          case 'ForStatement':
            walk(node.init);
            walk(node.test);
            walk(node.update);
            walk(node.body);
            return;
          case 'ForInStatement':
            walk(node.left);
            walk(node.right);
            walk(node.body);
            return;
          case 'WhileStatement':
            walk(node.test);
            walk(node.body);
            return;
          case 'DoWhileStatement':
            walk(node.body);
            walk(node.test);
            return;
          case 'VariableDeclaration':
            walk(node.declarations);
            return;
          case 'Property':
            walk(node.value);
            return;
          case 'NewExpression':
          case 'CallExpression':
            walk(node.callee);
            walk(node.arguments);
            return;
          case 'SwitchCase':
          case 'IfStatement':
          case 'ConditionalExpression':
            walk(node.test);
            walk(node.consequent);
            walk(node.alternate);
            return;
          case 'BinaryExpression':
          case 'LogicalExpression':
          case 'AssignmentExpression':
            walk(node.left);
            walk(node.right);
            return;
          case 'ThrowStatement':
          case 'ReturnStatement':
          case 'UnaryExpression':
          case 'UpdateExpression':
            walk(node.argument);
            return;
          case 'Literal':
          case 'EmptyStatement':
          case 'ThisExpression':
          case 'BreakStatement':
          case 'ContinueStatement':
            // Pass on literals, {}, this, break, continue
            return;
          default:
            console.log(node);
            throw new Error('Unknown Node: ' + node.type);
        }
      }

      function isValidDependency(d) {
        // Remove any local variables, whitelisted tokens like "arguments" or "NaN",
        // and anything in the global scope. Cheating a bit here by using the node
        // global scope instead of a ton of whitelisted tokens.
        return locals.indexOf(d) === -1 && !global[d] && WHITELISTED.indexOf(d) === -1;
      }

      walk(node);
      return deps.filter(isValidDependency);
    }
1254936
def compute_transitive_deps_by_target(self, targets):
    """"""
    # Sort from least to most dependent.
    sorted_targets = reversed(sort_targets(targets))
    transitive_deps_by_target = defaultdict(set)
    # Iterate in dep order, to accumulate the transitive deps for each target.
    for target in sorted_targets:
      transitive_deps = set()
      for dep in target.dependencies:
        transitive_deps.update(transitive_deps_by_target.get(dep, []))
        transitive_deps.add(dep)

      # Need to handle the case where a java_sources target has dependencies.
      # In particular if it depends back on the original target.
      if hasattr(target, 'java_sources'):
        for java_source_target in target.java_sources:
          for transitive_dep in java_source_target.dependencies:
            transitive_deps_by_target[java_source_target].add(transitive_dep)

      transitive_deps_by_target[target] = transitive_deps
    return transitive_deps_by_target
1171556
def recreate_parent_dependencies(apps, schema_editor):
    """"""
    Data = apps.get_model('flow', 'Data')
    DataDependency = apps.get_model('flow', 'DataDependency')

    def process_dependency(data, parent):
        if not Data.objects.filter(pk=parent).exists():
            DataDependency.objects.create(
                child=data, parent=None, kind='io'
            )

    for data in Data.objects.all():
        for field_schema, fields in iterate_fields(data.input, data.process.input_schema):
            name = field_schema['name']
            value = fields[name]

            if field_schema.get('type', '').startswith('data:'):
                process_dependency(data, value)

            elif field_schema.get('type', '').startswith('list:data:'):
                for parent in value:
                    process_dependency(data, parent)