Path: /sys/block directories starting with . or ram or dm- or loop
765001
def block(broker):
        """"""
        remove = (".", "ram", "dm-", "loop")
        tmp = "/dev/%s"
        return[(tmp % f) for f in os.listdir("/sys/block") if not f.startswith(remove)]
1293027
def get_path_directories():
    
    pth = os.environ['PATH']
    if sys.platform == 'win32' and os.environ.get("BASH"):
        # winbash has a bug..
        if pth[1] == ';':  # pragma: nocover
            pth = pth.replace(';', ':', 1)
    return [p.strip() for p in pth.split(os.pathsep) if p.strip()]
357966
def rmtree(path):
    """"""

    def onerror(func, path, exc_info):
        # Is the error an access error ?
        os.chmod(path, stat.S_IWUSR)

        try:
            func(path)  # Will scream if still not possible to delete.
        except Exception as ex:
            if HIDE_WINDOWS_KNOWN_ERRORS:
                raise SkipTest("FIXME: fails with: PermissionError\n  %s", ex)
            else:
                raise

    return shutil.rmtree(path, False, onerror)
518273
def _create_path(self):
        """"""

        if self.driver == 'sqlite' and 'memory' not in self.dsn and self.dsn != 'sqlite://':

            dir_ = os.path.dirname(self.path)

            if dir_ and not os.path.exists(dir_):
                try:
                    # Multiple process may try to make, so it could already
                    # exist
                    os.makedirs(dir_)
                except Exception:
                    pass

                if not os.path.exists(dir_):
                    raise Exception("Couldn't create directory " + dir_)
448540
def makedirs(d):
    """"""
    if sys.version_info[0] < 3:
        from distutils.dir_util import mkpath
        mkpath(d)
    else:
        os.makedirs(d, exist_ok=True)
281423
function initTmpDir (dirname, cb) {
  var dir = path.join(os.tmpDir(), dirname);

  rmrf(dir, function (err) {
    if (err) return cb(err);
    mkdir(dir, function (err) {
      if (err) return cb(err);
      cb(null, dir);
    });
  });
}
490869
def check_path(options, rootdir=None, candidates=None, code=None):
    
    if not candidates:
        candidates = []
        for path_ in options.paths:
            path = op.abspath(path_)
            if op.isdir(path):
                for root, _, files in walk(path):
                    candidates += [op.relpath(op.join(root, f), CURDIR)
                                   for f in files]
            else:
                candidates.append(path)

    if rootdir is None:
        rootdir = path if op.isdir(path) else op.dirname(path)

    paths = []
    for path in candidates:

        if not options.force and not any(l.allow(path)
                                         for _, l in options.linters):
            continue

        if not op.exists(path):
            continue

        paths.append(path)

    if options.concurrent:
        return check_async(paths, options, rootdir)

    errors = []
    for path in paths:
        errors += run(path=path, code=code, rootdir=rootdir, options=options)
    return errors
1151343
def create_prefix_dir(self, path, fmt):
        """"""
        create_prefix_dir(self._get_os_path(path.strip('/')), fmt)
1076173
def walkfiles(startdir, regex=None, recurse=True):
    """"""
    for r,_,fs in os.walk(startdir):
        if not recurse and startdir != r:
            return
        for f in fs:
            path = op.abspath(op.join(r,f))
            if regex and not _is_match(regex, path):
                    continue
            if op.isfile(path):
                yield path
9425
def find(dir_path, opts = {})
      regex = opts.key?(:regex) ? opts[:regex] : nil

      # We should always be doing GET because switching between methods is used
      # within this function.
      opts.delete(:head)

      begin
        exists = list_directory(dir_path, head: true).first
      rescue
        exists = false
      end

      return [] unless exists

      response = list_directory(dir_path, opts)
      listing = response.first

      listing.inject([]) do |memo, obj|
        if obj['type'] == 'directory'
          sub_dir = "#{dir_path}/#{obj['name']}"
          sub_search = find(sub_dir, regex: regex)
          memo.push(*sub_search)
        end

        if obj['type'] == 'object'
          file = "#{dir_path}/#{obj['name']}"

          if !regex || obj['name'].match(regex)
            memo.push file
          end
        end

        memo
      end
    end
885954
def temp_path():
    """"""
    path = [p for p in sys.path]
    try:
        yield
    finally:
        sys.path = [p for p in path]
348147
def os_path_relpath(path, start=os.path.curdir):
    """"""

    if not path:
        raise ValueError("no path specified")

    start_list = [x for x in os.path.abspath(start).split(os.path.sep) if x]
    path_list = [x for x in os.path.abspath(path).split(os.path.sep) if x]

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

    rel_list = [os.path.pardir] * (len(start_list)-i) + path_list[i:]
    if not rel_list:
        return os.path.curdir
    return os.path.join(*rel_list)
1193383
def path_for(self, *args):
        """"""
        if args and args[0].startswith(os.path.sep):
            return os.path.join(*args)
        return os.path.join(self._root_path or os.getcwd(), *args)
331075
def listdir(self, path):
        '''
        
        '''
        for f in os.listdir(path):
            if not f.startswith('.'):
                yield f
707127
def which(cmd, path="PATH"):
    """"""
    if os.path.exists(cmd):
        return cmd
    if cmd[0] == '/':
        return None
    for segment in os.getenv(path).split(":"):
        program = os.path.normpath(os.path.join(segment, cmd))
        if os.path.exists(program):
            return program
    return None
929095
def check_and_create_directories(paths):
    
    for path in paths:
        if os.path.exists(path):
            shutil.rmtree(path)
        os.mkdir(path)
652396
def find_in_paths(logical_path, &block)
        dirname, basename = File.split(logical_path)
        @paths.each do |base_path|
          match(File.expand_path(dirname, base_path), basename, &block)
        end
      end