Search for the imported file in order of included paths
508518
function findImportedPath(url, prev, includedFilesMap, includedPaths) {
  let candidateFromPaths;

  if(prev !== 'stdin') {
    const prevPath = path.posix.dirname(prev);
    candidateFromPaths = [prevPath, ...includedPaths];
  } else {
    candidateFromPaths = [...includedPaths];
  }

  for(let i = 0; i < candidateFromPaths.length; i++) {
    let candidatePath;
    let candidateFromPath = normalizePath(makeAbsolute(candidateFromPaths[i]));
    if (path.isAbsolute(url)) {
      candidatePath = normalizePath(url);
    } else {
      // Get normalize absolute candidate from path
      candidatePath = path.posix.join(candidateFromPath, url);
    }

    if(includedFilesMap[candidatePath]) {
      return candidatePath;
    } else {
      let urlBasename = path.posix.basename(url);
      let indexOfBasename = url.lastIndexOf(urlBasename);
      let partialUrl = `${url.substring(0, indexOfBasename)}_${urlBasename}`;

      if (path.isAbsolute(partialUrl)) {
        candidatePath = normalizePath(partialUrl);
      } else {
        candidatePath = path.posix.join(candidateFromPath, partialUrl);
      }

      if(includedFilesMap[candidatePath]) {
        return candidatePath;
      }
    }
  }

  return null;
}
139634
def include(d, e):
    """"""

    return (d, [f for f in glob.glob('%s/%s' % (d, e)) if os.path.isfile(f)])
569512
def get_paths(folder, ignore_endswith=ignore_endswith):
    '''
    '''
    folder = pathlib.Path(folder).resolve()
    files = folder.rglob("*")
    for ie in ignore_endswith:
        files = [ff for ff in files if not ff.name.endswith(ie)]
    return sorted(files)
41347
def include_path(self):
        
        parts = [self.include_dir(root=self.url_root)]
        parts.append("index")
        return "/".join(parts)
898862
def import_path_from_file(filename, as_list=False):
    '''
    '''
    module_path = []
    basename = os.path.splitext(os.path.basename(filename))[0]
    if basename != '__init__':
        module_path.append(basename)

    dirname = os.path.dirname(filename)
    while os.path.isfile(os.path.join(dirname, '__init__.py')):
        dirname, tail = os.path.split(dirname)
        module_path.insert(0, tail)

    if as_list:
        return module_path, dirname
    return '.'.join(module_path), dirname
704784
private boolean findFiles(String[] args, String option, Set<String> suffixes,
                              Map<String,Source> found_files, Map<String, Module> found_modules,
                              Module current_module, boolean inLinksrc)
        throws ProblemException, ProblemException
    {
        // Track which source roots, source path roots and class path roots have been added.
        Set<File> roots = new HashSet<File>();
        // Track the current set of package includes,excludes as well as excluded source files,
        // to be used in the next -src/-sourcepath/-classpath
        List<String> includes = new LinkedList<String>();
        List<String> excludes = new LinkedList<String>();
        List<String> excludefiles = new LinkedList<String>();
        List<String> includefiles = new LinkedList<String>();
        // This include is used to find all modules in the source.
        List<String> moduleinfo = new LinkedList<String>();
        moduleinfo.add("module-info.java");

        for (int i = 0; i<args.length; ++i) {
            if (args[i].equals("-i")) {
                if (i+1 >= args.length) {
                    throw new ProblemException("You have to specify a package pattern following -i");
                }
                String incl = args[i+1];
                checkPattern(incl);
                includes.add(incl);
            }
            if (args[i].equals("-x")) {
                if (i+1 >= args.length) {
                    throw new ProblemException("You have to specify a package pattern following -x");
                }
                String excl = args[i+1];
                checkPattern(excl);
                excludes.add(excl);
            }
            if (args[i].equals("-xf")) {
                if (i+1 >= args.length) {
                    throw new ProblemException("You have to specify a file following -xf");
                }
                String exclf = args[i+1];
                checkFilePattern(exclf);
                exclf = Util.normalizeDriveLetter(exclf);
                excludefiles.add(fixupSeparator(exclf));
            }
            if (args[i].equals("-if")) {
                if (i+1 >= args.length) {
                    throw new ProblemException("You have to specify a file following -xf");
                }
                String inclf = args[i+1];
                checkFilePattern(inclf);
                inclf = Util.normalizeDriveLetter(inclf);
                includefiles.add(fixupSeparator(inclf));
            }
            if (args[i].equals(option)) {
                if (i+1 >= args.length) {
                    throw new ProblemException("You have to specify a directory following "+option);
                }
                String[] root_dirs = args[i+1].split(File.pathSeparator);
                for (String r : root_dirs) {
                    File root = new File(r);
                    if (!root.isDirectory()) {
                        throw new ProblemException("\""+r+"\" is not a directory.");
                    }
                    try {
                        root = root.getCanonicalFile();
                    } catch (IOException e) {
                        throw new ProblemException(""+e);
                    }
                    if (roots.contains(root)) {
                        throw new ProblemException("\""+r+"\" has already been used for "+option);
                    }
                    if (root.equals(bin_dir)) {
                        throw new ProblemException("\""+r+"\" cannot be used both for "+option+" and -d");
                    }
                    if (root.equals(gensrc_dir)) {
                        throw new ProblemException("\""+r+"\" cannot be used both for "+option+" and -s");
                    }
                    if (root.equals(header_dir)) {
                        throw new ProblemException("\""+r+"\" cannot be used both for "+option+" and -h");
                    }
                    roots.add(root);
                    Source.scanRoot(root, suffixes, excludes, includes, excludefiles, includefiles,
                                    found_files, found_modules, current_module,
                                    findBooleanOption(args, "--permit-sources-without-package"),
                                    false, inLinksrc);
                }
            }
            if (args[i].equals("-src") ||
                args[i].equals("-sourcepath") ||
                args[i].equals("-modulepath") ||
                args[i].equals("-classpath") ||
                args[i].equals("-cp"))
            {
                // Reset the includes,excludes and excludefiles after they have been used.
                includes = new LinkedList<String>();
                excludes = new LinkedList<String>();
                excludefiles = new LinkedList<String>();
                includefiles = new LinkedList<String>();
            }
        }
        return true;
    }
558313
def traverse_tree(cls, static_dir):
        """"""
        for root, dirs, files in os.walk(static_dir):
            for filename in files:
                if cls._pattern.match(filename):
                    APPS_INCLUDE_DIRS.append(static_dir)
                    return
1028667
def _read_import_root_map_file(path):
    """"""
    if os.path.exists(path):
      with open(path, 'r') as fp:
        return dict({import_path: root for import_path, root in
                     (x.strip().split('\t') for x in fp.readlines())})
    else:
      return {}
1283926
def find_imports(filename):
    
    with open(filename) as f:
        root = ast.parse(f.read(), filename)
    visitor = ImportFinder(filename)
    visitor.visit(root)
    return visitor.imports
1324798
def parsePathname(self, pathname):
        
        if os.path.isdir(pathname):
            for root, dirs, files in os.walk(pathname):
                dirs.sort()
                files.sort()
                for fn in files:
                    # ignore emacsish junk
                    if fn.endswith('.py') and not fn.startswith('.#'):
                        self.parseFile(os.path.join(root, fn))
        elif pathname.endswith('.importcache'):
            self.readCache(pathname)
        else:
            self.parseFile(pathname)
1040815
def find_compiled_files(self):
        
        files = self._find_files()
        self.announce(
            "found '{}' compiled python files in '{}'".format(
                len(files), self.root
            )
        )
        return files
530004
function isImported(source, classifiedName, importPath) {
    const allNodes = getSourceNodes(source);
    const matchingNodes = allNodes
        .filter(node => node.kind === ts.SyntaxKind.ImportDeclaration)
        .filter((imp) => imp.moduleSpecifier.kind === ts.SyntaxKind.StringLiteral)
        .filter((imp) => {
        return imp.moduleSpecifier.text === importPath;
    })
        .filter((imp) => {
        if (!imp.importClause) {
            return false;
        }
        const nodes = findNodes(imp.importClause, ts.SyntaxKind.ImportSpecifier).filter(n => n.getText() === classifiedName);
        return nodes.length > 0;
    });
    return matchingNodes.length > 0;
}
1133592
def find_on_path(importer, path_item, only=False):
    """"""
    path_item = _normalize_cached(path_item)

    if _is_unpacked_egg(path_item):
        yield Distribution.from_filename(
            path_item, metadata=PathMetadata(
                path_item, os.path.join(path_item, 'EGG-INFO')
            )
        )
        return

    entries = safe_listdir(path_item)

    # for performance, before sorting by version,
    # screen entries for only those that will yield
    # distributions
    filtered = (
        entry
        for entry in entries
        if dist_factory(path_item, entry, only)
    )

    # scan for .egg and .egg-info in directory
    path_item_entries = _by_version_descending(filtered)
    for entry in path_item_entries:
        fullpath = os.path.join(path_item, entry)
        factory = dist_factory(path_item, entry, only)
        for dist in factory(fullpath):
            yield dist
610400
def _inner_search(obj, glob, separator, dirs=True, leaves=False):
    """"""
    for path in dpath.path.paths(obj, dirs, leaves, skip=True):
        if dpath.path.match(path, glob):
            yield path
536128
function includeRawDataFile(includedFiles, files, entryFilename, data) {
  let orderedFiles = includedFiles;

  if(entryFilename === RAW_DATA_FILE && data) {
    files[RAW_DATA_FILE] = data;
    orderedFiles = [...orderedFiles, RAW_DATA_FILE];
  } else if(orderedFiles.length > 0) {
    orderedFiles = [...orderedFiles.slice(1), orderedFiles[0]];
  }

  return {
    compiledFiles: files,
    orderedFiles,
  };
}
999830
def finddirs(pattern, path='.', exclude=None, recursive=True):
    """"""
    import fnmatch
    import os
    if recursive:
        for root, dirnames, filenames in os.walk(path):
            for pat in _to_list(pattern):
                for dirname in fnmatch.filter(dirnames, pat):
                    dirpath = join(abspath(root), dirname)
                    for excl in _to_list(exclude):
                        if excl and fnmatch.fnmatch(dirpath, excl):
                            break
                    else:
                        yield dirpath
    else:
        for pat in _to_list(pattern):
            for dirname in fnmatch.filter(listdirs(path), pat):
                dirpath = join(abspath(path), dirname)
                for excl in _to_list(exclude):
                    if excl and fnmatch.fnmatch(dirpath, excl):
                        break
                else:
                    yield dirpath
64729
function getRelativePath(cssPath, importCssPath, imgPath) {
        var count1 = 0,
            count2 = 0,
            result = '';
        importCssPath = getFilePath(cssPath, importCssPath);
        imgPath = getFilePath(importCssPath, imgPath);
        for (var i = 0, length = cssPath.length; i < length; i++) {
            if (cssPath[i] == imgPath[i]) {
                count1++;
            } else {
                break;
            }
        }
        count2 = cssPath.length - count1 - 1;
        for (var i = 0; i < count2; i++) {
            result += '../';
        }
        result = result + imgPath.splice(count1).join('/');
        return result;
    }