Extract types dependencies from specs for each exported signature.
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)
893903
def all_dependencies(self, target):
    """"""
    for dep in target.closure(bfs=True, **self.target_closure_kwargs):
      yield dep
1297157
def target_types_from_build_file_aliases(aliases):
  """"""
  target_types = dict(aliases.target_types)
  for alias, factory in aliases.target_macro_factories.items():
    target_type, = factory.target_types
    target_types[alias] = target_type
  return target_types
1291215
def dependencies(dist, recursive=False, info=False):
    """"""

    def case_sorted(items):
        """Return unique list sorted in case-insensitive order."""
        return sorted(set(items), key=lambda i: i.lower())

    def requires(distribution):
        """Return the requirements for a distribution."""
        if recursive:
            req = set(pkg_resources.require(distribution.project_name))
            req.remove(distribution)
            return {r.as_requirement() for r in req}
        return distribution.requires()

    def modifier(distribution):
        """Return project's name or full requirement string."""
        return str(distribution) if info else distribution.project_name

    return case_sorted(modifier(r) for r in requires(dist))
1202180
private Collection<DependencyInfo> collectPackageJsonDependencies(Collection<BomFile> packageJsons) {
        Collection<DependencyInfo> dependencies = new LinkedList<>();
        ConcurrentHashMap<DependencyInfo, BomFile> dependencyPackageJsonMap = new ConcurrentHashMap<>();
        ExecutorService executorService = Executors.newWorkStealingPool(NUM_THREADS);
        Collection<EnrichDependency> threadsCollection = new LinkedList<>();
        for (BomFile packageJson : packageJsons) {
            if (packageJson != null && packageJson.isValid()) {
                // do not add new dependencies if 'npm ls' already returned all
                DependencyInfo dependency = new DependencyInfo();
                dependencies.add(dependency);
                threadsCollection.add(new EnrichDependency(packageJson, dependency, dependencyPackageJsonMap, npmAccessToken));
                logger.debug("Collect package.json of the dependency in the file: {}", dependency.getFilename());
            }
        }
        runThreadCollection(executorService, threadsCollection);
        logger.debug("set hierarchy of the dependencies");
        // remove duplicates dependencies
        Map<String, DependencyInfo> existDependencies = new HashMap<>();
        Map<DependencyInfo, BomFile> dependencyPackageJsonMapWithoutDuplicates = new HashMap<>();
        for (Map.Entry<DependencyInfo, BomFile> entry : dependencyPackageJsonMap.entrySet()) {
            DependencyInfo keyDep = entry.getKey();
            String key = keyDep.getSha1() + keyDep.getVersion() + keyDep.getArtifactId();
            if (!existDependencies.containsKey(key)) {
                existDependencies.put(key, keyDep);
                dependencyPackageJsonMapWithoutDuplicates.put(keyDep, entry.getValue());
            }
        }
        setHierarchy(dependencyPackageJsonMapWithoutDuplicates, existDependencies);
        return existDependencies.values();
    }
26178
def extract_types(cls, schema):
        
        for field in cls.extract_fields(schema):
            if field.has_format:
                yield field.format_spec.type
750136
def dependencies(self, sort=False):
        
        alldeps = []
        if sort:
            def key(obj):
                # sort deps such that we get functions, variables, self.
                if not isinstance(obj, Variable):
                    return (0, 0)
                else:
                    return (1, obj.vtype)
            
            deps = sorted(self._deps, key=key)
        else:
            deps = self._deps
        
        for dep in deps:
            alldeps.extend(dep.dependencies(sort=sort))
        alldeps.append(self)
        return alldeps
1132031
def search_dependencies(self):
        
        #It is understood that this executable's module is obviously required. Just
        #add any additional modules from the parameters.
        result = [p.dependency() for p in self.ordered_parameters]
        result.extend([v.dependency() for k, v in list(self.members.items())])
        for ekey, anexec in list(self.executables.items()):
            result.extend(anexec.search_dependencies())
        return [m for m in result if m is not None and m != self.module.name]
1161345
def check_exports(mod, specs, renamings):
    '''
    
    '''
    functions = {renamings.get(k, k): v for k, v in specs.functions.items()}

    mod_functions = {node.name: node for node in mod.body
                     if isinstance(node, ast.FunctionDef)}

    for fname, signatures in functions.items():
        try:
            fnode = mod_functions[fname]
        except KeyError:
            raise PythranSyntaxError(
                "Invalid spec: exporting undefined function `{}`"
                .format(fname))
        for signature in signatures:
            args_count = len(fnode.args.args)
            if len(signature) > args_count:
                raise PythranSyntaxError(
                    "Too many arguments when exporting `{}`"
                    .format(fname))
            elif len(signature) < args_count - len(fnode.args.defaults):
                raise PythranSyntaxError(
                    "Not enough arguments when exporting `{}`"
                    .format(fname))
791620
function getDepsFromDataObject(data, lookup) {
  var results = {};
  if (categories.length == 0) {
    for(var k in data.dependencies) {
      var dep = extractDep(data.dependencies[k]);
      results[k]=dep;
    }
  }

  if (lookup) {
    for (var i = 0; i < categories.length; i++) {
      var category = categories[i];
      for(var k in data[category]) {
        var spec = k + "@" + data[category][k];

        var specMatch = lookupSpecMatch(lookup, spec);

        // If there is no match in the lookup then this dependency was "deduped"
        if (specMatch) {
          results[k]=specMatch;
        }
      }
    }
  }
  return results;
}
1277113
def extract_deps(bundles, log=None):
    """"""
    def _flatten(bundle):
        deps = []
        if hasattr(bundle, 'npm'):
            deps.append(bundle.npm)
        for content in bundle.contents:
            if isinstance(content, BundleBase):
                deps.extend(_flatten(content))
        return deps

    flatten_deps = []
    for bundle in bundles:
        flatten_deps.extend(_flatten(bundle))

    packages = defaultdict(list)
    for dep in flatten_deps:
        for pkg, version in dep.items():
            packages[pkg].append(version)

    deps = {}
    for package, versions in packages.items():
        deps[package] = semver.max_satisfying(versions, '*', True)

        if log and len(versions) > 1:
            log('Warn: {0} version {1} resolved to: {2}'.format(
                repr(package), versions, repr(deps[package])
            ))

    return deps
388844
def extract_dependencies(pipe_def=None, pipe_generator=None):
    """"""
    if pipe_def:
        pydeps = gen_dependencies(pipe_def)
    elif pipe_generator:
        pydeps = pipe_generator(Context(describe_dependencies=True))
    else:
        raise Exception('Must supply at least one kwarg!')

    return sorted(set(pydeps))
1343832
function parseDependencies(s) {
    if(s.indexOf('require') == -1) {
      return []
    }
    var index = 0, peek, length = s.length, isReg = 1, modName = 0, res = []
    var parentheseState = 0, parentheseStack = []
    var braceState, braceStack = [], isReturn
    while(index < length) {
      readch()
      if(isBlank()) {
        if(isReturn && (peek == '\n' || peek == '\r')) {
          braceState = 0
          isReturn = 0
        }
      }
      else if(isQuote()) {
        dealQuote()
        isReg = 1
        isReturn = 0
        braceState = 0
      }
      else if(peek == '/') {
        readch()
        if(peek == '/') {
          index = s.indexOf('\n', index)
          if(index == -1) {
            index = s.length
          }
        }
        else if(peek == '*') {
          var i = s.indexOf('\n', index)
          index = s.indexOf('*/', index)
          if(index == -1) {
            index = length
          }
          else {
            index += 2
          }
          if(isReturn && i != -1 && i < index) {
            braceState = 0
            isReturn = 0
          }
        }
        else if(isReg) {
          dealReg()
          isReg = 0
          isReturn = 0
          braceState = 0
        }
        else {
          index--
          isReg = 1
          isReturn = 0
          braceState = 1
        }
      }
      else if(isWord()) {
        dealWord()
      }
      else if(isNumber()) {
        dealNumber()
        isReturn = 0
        braceState = 0
      }
      else if(peek == '(') {
        parentheseStack.push(parentheseState)
        isReg = 1
        isReturn = 0
        braceState = 1
      }
      else if(peek == ')') {
        isReg = parentheseStack.pop()
        isReturn = 0
        braceState = 0
      }
      else if(peek == '{') {
        if(isReturn) {
          braceState = 1
        }
        braceStack.push(braceState)
        isReturn = 0
        isReg = 1
      }
      else if(peek == '}') {
        braceState = braceStack.pop();
        isReg = !braceState
        isReturn = 0
      }
      else {
        var next = s.charAt(index)
        if(peek == ';') {
          braceState = 0
        }
        else if(peek == '-' && next == '-'
          || peek == '+' && next == '+'
          || peek == '=' && next == '>') {
          braceState = 0
          index++
        }
        else {
          braceState = 1
        }
        isReg = peek != ']'
        isReturn = 0
      }
    }
    return res
    function readch() {
      peek = s.charAt(index++)
    }
    function isBlank() {
      return /\s/.test(peek)
    }
    function isQuote() {
      return peek == '"' || peek == "'"
    }
    function dealQuote() {
      var start = index
      var c = peek
      var end = s.indexOf(c, start)
      if(end == -1) {
        index = length
      }
      else if(s.charAt(end - 1) != '\\') {
        index = end + 1
      }
      else {
        while(index < length) {
          readch()
          if(peek == '\\') {
            index++
          }
          else if(peek == c) {
            break
          }
        }
      }
      if(modName) {
        res.push(s.slice(start, index - 1))
        modName = 0
      }
    }
    function dealReg() {
      index--
      while(index < length) {
        readch()
        if(peek == '\\') {
          index++
        }
        else if(peek == '/') {
          break
        }
        else if(peek == '[') {
          while(index < length) {
            readch()
            if(peek == '\\') {
              index++
            }
            else if(peek == ']') {
              break
            }
          }
        }
      }
    }
    function isWord() {
      return /[a-z_$]/i.test(peek)
    }
    function dealWord() {
      var s2 = s.slice(index - 1)
      var r = /^[\w$]+/.exec(s2)[0]
      parentheseState = {
        'if': 1,
        'for': 1,
        'while': 1,
        'with': 1
      }[r]
      isReg = {
        'break': 1,
        'case': 1,
        'continue': 1,
        'debugger': 1,
        'delete': 1,
        'do': 1,
        'else': 1,
        'false': 1,
        'if': 1,
        'in': 1,
        'instanceof': 1,
        'return': 1,
        'typeof': 1,
        'void': 1
      }[r]
      isReturn = r == 'return'
      braceState = {
        'instanceof': 1,
        'delete': 1,
        'void': 1,
        'typeof': 1,
        'return': 1
      }.hasOwnProperty(r);
      modName = /^require\s*\(\s*(['"]).+?\1\s*\)/.test(s2)
      if(modName) {
        r = /^require\s*\(\s*['"]/.exec(s2)[0]
        index += r.length - 2
      }
      else {
        index += /^[\w$]+(?:\s*\.\s*[\w$]+)*/.exec(s2)[0].length - 1
      }
    }
    function isNumber() {
      return /\d/.test(peek)
        || peek == '.' && /\d/.test(s.charAt(index))
    }
    function dealNumber() {
      var s2 = s.slice(index - 1)
      var r
      if(peek == '.') {
        r = /^\.\d+(?:E[+-]?\d*)?\s*/i.exec(s2)[0]
      }
      else if(/^0x[\da-f]*/i.test(s2)) {
        r = /^0x[\da-f]*\s*/i.exec(s2)[0]
      }
      else {
        r = /^\d+\.?\d*(?:E[+-]?\d*)?\s*/i.exec(s2)[0]
      }
      index += r.length - 1
      isReg = 0
    }
  }
118267
def dependencies(self) -> List[Dependency]:
        """"""
        dependencies_str = DB.get_hash_value(self.key, 'dependencies')
        dependencies = []
        for dependency in ast.literal_eval(dependencies_str):
            dependencies.append(Dependency(dependency))
        return dependencies
798833
def build_helpers_module_registry_dependencies(registry_name='calmjs.module'):
    

    def get_module_registry_dependencies(
            pkg_names, registry_name=registry_name, working_set=None):
        """
        Get dependencies for the given package names from module
        registry identified by registry name.

        For the given packages 'pkg_names' and the registry identified
        by 'registry_name', resolve the exported location for just the
        package.
        """

        working_set = working_set or default_working_set
        registry = get(registry_name)
        if not isinstance(registry, BaseModuleRegistry):
            return {}
        result = {}
        for pkg_name in pkg_names:
            result.update(registry.get_records_for_package(pkg_name))
        return result

    def _flatten_module_registry_dependencies(
            pkg_names, registry_name, find_dists, working_set):
        """
        Flatten dependencies for the given package names from module
        registry identified by registry name using the find_dists
        function on the given working_set.

        For the given packages 'pkg_names' and the registry identified
        by 'registry_name', resolve and flatten all the exported
        locations.
        """

        result = {}
        registry = get(registry_name)
        if not isinstance(registry, BaseModuleRegistry):
            return result

        dists = find_dists(pkg_names, working_set=working_set)
        for dist in dists:
            result.update(registry.get_records_for_package(dist.project_name))

        return result

    def flatten_module_registry_dependencies(
            pkg_names, registry_name=registry_name, working_set=None):
        """
        Flatten dependencies for the specified packages from the module
        registry identified by registry name.

        For the given packages 'pkg_names' and the registry identified
        by 'registry_name', resolve and flatten all the exported
        locations.
        """

        working_set = working_set or default_working_set
        return _flatten_module_registry_dependencies(
            pkg_names, registry_name, find_packages_requirements_dists,
            working_set)

    def flatten_parents_module_registry_dependencies(
            pkg_names, registry_name=registry_name, working_set=None):
        """
        Flatten dependencies for the parents of the specified packages
        from the module registry identified by registry name.

        For the given packages 'pkg_names' and the registry identified
        by 'registry_name', resolve and flatten all the exported
        locations.
        """

        working_set = working_set or default_working_set
        return _flatten_module_registry_dependencies(
            pkg_names, registry_name, find_packages_parents_requirements_dists,
            working_set)

    return (
        get_module_registry_dependencies,
        flatten_module_registry_dependencies,
        flatten_parents_module_registry_dependencies,
    )
382731
def export_module_spec(spec, path, checkpoint_path, name_transform_fn):
  """"""
  with tf.Graph().as_default():
    m = Module(spec)
    assign_map = {
        name_transform_fn(name): value for name, value in m.variable_map.items()
    }
    tf_v1.train.init_from_checkpoint(checkpoint_path, assign_map)
    init_op = tf_v1.initializers.global_variables()
    with tf_v1.Session() as session:
      session.run(init_op)
      m.export(path, session)
743670
def _compile_signature(self, iexec, call_name):
        """"""
        if iexec is not None:
            summary = iexec.summary
            if isinstance(iexec, Function):
                summary = iexec.returns + "| " + iexec.summary
            elif isinstance(iexec, Subroutine) and len(iexec.modifiers) > 0:
                summary = ", ".join(iexec.modifiers) + " | " + iexec.summary
            elif isinstance(iexec, Interface):
                summary = iexec.describe()
            else:
                summary = iexec.summary

            #Add the name of the module who owns the method. Useful in case the
            #same executable is defined in multiple modules, but only one is
            #referenced in the current context.
            if iexec.parent is not None:
                summary += " | MODULE: {}".format(iexec.module.name)
            else:
                summary += " | BUILTIN"

            return dict(
                params=[p.name for p in iexec.ordered_parameters],
                index=0,
                call_name=call_name,
                description=summary,
            )        
        else:
            return []