Given a path, a list of existing paths and counts for each of the
    existing paths.
518456
def make_path_unique(path, counts, new):
    
    added = False
    while any(path == c[:i] for c in counts for i in range(1, len(c)+1)):
        count = counts[path]
        counts[path] += 1
        if (not new and len(path) > 1) or added:
            path = path[:-1]
        else:
            added = True
        path = path + (int_to_roman(count),)
    if len(path) == 1:
        path = path + (int_to_roman(counts.get(path, 1)),)
    if path not in counts:
        counts[path] = 1
    return path
858736
function tally(pathname, offenses) {
    var count = offenses.length,
        plural = count > 1 ? 'errors' : 'error';

    function perOffense(o) {
        if (!errors[pathname]) {
            errors[pathname] = [];
        }

        if (o) {
            errors[pathname].push({
                line: o.line,
                col: o.character,
                msg: o.reason,
                evidence: o.evidence || ''
            });
        }
    }

    log.error([count, plural, 'in', pathname].join(' '));
    offenses.forEach(perOffense);
}
1143655
def expand_path(path):
    """"""

    paths = []
    path = os.path.expanduser(path)
    path = os.path.expandvars(path)

    if os.path.isdir(path):

        for (dir, dirs, files) in os.walk(path):
            for file in files:
                paths.append(os.path.join(dir, file))
    else:
        paths.extend(glob(path))

    return paths
132515
private void updateQuotaForPath(String path) {
        Counts c = new Counts();
        getCounts(path, c);
        StatsTrack strack = new StatsTrack();
        strack.setBytes(c.bytes);
        strack.setCount(c.count);
        String statPath = Quotas.quotaZookeeper + path + "/" + Quotas.statNode;
        DataNode node = getNode(statPath);
        // it should exist
        if (node == null) {
            LOG.warn("Missing quota stat node " + statPath);
            return;
        }
        synchronized (node) {
            node.data = strack.toString().getBytes();
        }
    }
433582
def filter_paths(pathnames, patterns=None, ignore_patterns=None):
    """"""
    result = []
    if patterns is None:
        patterns = ['*']
    if ignore_patterns is None:
        ignore_patterns = []
    for pathname in pathnames:
        if match_patterns(pathname, patterns) and not match_patterns(pathname, ignore_patterns):
            result.append(pathname)
    return result
467214
def relpath(path, start=posixpath.curdir):
    """"""
    if not path:
        raise ValueError("no path specified")

    start_list = posixpath.abspath(start).split(posixpath.sep)
    path_list = posixpath.abspath(path).split(posixpath.sep)

    # Work out how much of the filepath is shared by start and path.
    i = len(posixpath.commonprefix([start_list, path_list]))

    rel_list = [posixpath.pardir] * (len(start_list) - i) + path_list[i:]
    if not rel_list:
        return posixpath.curdir
    return posixpath.join(*rel_list)
1098496
def calculate_include_paths(targets, is_thrift_target):
  

  basedirs = set()
  def collect_paths(target):
    basedirs.add(target.target_base)

  for target in targets:
    target.walk(collect_paths, predicate=is_thrift_target)
  return basedirs
597825
def list(path, filename=None, start=None, stop=None, recursive=False, directories=False):
        
        path = uri_to_path(path)

        if not filename and recursive:
            return listrecursive(path)

        if filename:
            if os.path.isdir(path):
                path = os.path.join(path, filename)
            else:
                path = os.path.join(os.path.dirname(path), filename)
        else:
            if os.path.isdir(path) and not directories:
                path = os.path.join(path, "*")

        files = glob.glob(path)

        if not directories:
            files = [fpath for fpath in files if not os.path.isdir(fpath)]

        files.sort()
        files = select(files, start, stop)
        return files
421599
def exists(*paths):
    
    for path in paths:
        log(_("checking that {} exists...").format(path))
        if not os.path.exists(path):
            raise Failure(_("{} not found").format(path))
1369605
private FileStatusEntry[] doListPathsEntry(Path path, FileStatusEntry entry)
      throws IOException {
    final Path[] paths = listPaths(path);

    final FileStatusEntry[] children =
        paths.length > 0 ? new FileStatusEntry[paths.length] : FileStatusEntry.EMPTY_ENTRIES;
    for (int i = 0; i < paths.length; i++) {
      children[i] = createPathEntry(entry, paths[i]);
    }
    return children;
  }
368181
function(replace, count, callback) {
    return pathmap.replace(
      pathmap.chomp(this, pathmap.extname(this)), replace, callback);
  }
1242104
public long calculateRecordCount (Collection<Path> paths) throws IOException {
    long sum = 0;
    for (Path path: paths) {
      sum += inputRecordCountProvider.getRecordCount(DatasetHelper.getApplicableFilePaths(this.fs, path, Lists.newArrayList(AVRO)));
    }
    return sum;
  }
723950
def _AddPathSegments(self, path, ignore_list):
    
    path_segments = path.split(self._path_segment_separator)
    for path_segment_index, path_segment in enumerate(path_segments):
      if path_segment_index not in self.path_segments_per_index:
        self.path_segments_per_index[path_segment_index] = {}

      if path_segment_index not in ignore_list:
        path_segments = self.path_segments_per_index[path_segment_index]

        if path_segment not in path_segments:
          path_segments[path_segment] = []

        paths_per_segment_list = path_segments[path_segment]
        paths_per_segment_list.append(path)
1019828
def all_paths
      results = []
      paths = routes.map(&:path)
      paths.each do |p|
        sub_paths = []
        parts = p.split('/')
        until parts.empty?
          parts.pop
          sub_path = parts.join('/')
          sub_paths << sub_path unless sub_path == ''
        end
        results += sub_paths
      end
      @all_paths = (results + paths).sort.uniq
    end
673149
def update_paths(self):
        
        new_paths = []
        with self.lock:
            for path in expand_source_paths(iter_module_paths()):
                if path not in self.paths:
                    self.paths.add(path)
                    new_paths.append(path)
        if new_paths:
            self.watch_paths(new_paths)
300445
def _appendpath_unique(list_, path):
        """"""
        for p in list_:
            if p == path:
                return
        list_.append(path)
149481
def _list_files_in_path(path, pattern="*.stan"):
    

    results = []
    for dirname, subdirs, files in os.walk(path):
        for name in files:
            if fnmatch(name, pattern):
                results.append(os.path.join(dirname, name))
    return(results)