Check path.

    :param rootdir: Root directory (for making relative file paths)
    :param options: Parsed pylama options (from pylama.config.parse_options)

    :returns: (list) Errors list
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
1310944
def _ensure_tree(path):
    
    try:
        os.makedirs(path)
    except OSError as e:
        if e.errno == errno.EEXIST:
            if not os.path.isdir(path):
                raise
            else:
                return False
        elif e.errno == errno.EISDIR:
            return False
        else:
            raise
    else:
        return True
1075168
def _walk_directory(root_directory):
        

        paths = [os.path.join(root, name)
                 for root, dirs, files in os.walk(root_directory)  # noqa
                 for name in files]
        paths.sort()
        return paths
1253649
private void validateRootFolder() {
        File rootDir = new File(m_config.root);
        if (!rootDir.exists()) {
            logErrorThrow("Root directory does not exist: {}", m_config.root);
        } else if (!rootDir.isDirectory()) {
            logErrorThrow("Root directory must be a folder: {}", m_config.root);
        } else if (!m_config.root.endsWith(File.separator)) {
            m_config.root = m_config.root + File.separator;
        }
    }
711953
def isdir(path, message):
    
    if not os.path.isdir(path):
        raise FileNotFoundError(
            errno.ENOENT,
            "{}: {}".format(message, os.strerror(errno.ENOENT)), path)
556016
def main(self, *directories):
        
        if not self.git and len(directories) == 0:
            print ("ERROR: At least one directory must be provided (or the "
                   "--git-precommit flag must be passed.\n")
            self.help()
            return

        if len(directories) > 0:
            find = local['find']
            files = []
            for directory in directories:
                real = os.path.expanduser(directory)
                if not os.path.exists(real):
                    raise ValueError("{0} does not exist".format(directory))
                files.extend(find(real, '-name', '*.py').strip().split('\n'))
            if len(files) > 0:
                print "Linting {0} python files.\n".format(len(files))
                lint(files)
            else:
                print "No python files found to lint.\n"

        else:
            status = local['git']('status', '--porcelain', '-uno')
            root = local['git']('rev-parse', '--show-toplevel').strip()

            # get all modified or added python files
            modified = re.findall(r"^[AM]\s+\S+\.py$", status, re.MULTILINE)

            # now just get the path part, which all should be relative to the
            # root
            files = [os.path.join(root, line.split(' ', 1)[-1].strip())
                     for line in modified]
            if len(files) > 0:
                lint(files)
429665
def scan_directory_for_bot_configs(root_dir) -> Set[BotConfigBundle]:
    

    configs = set()

    for filename in glob.iglob(os.path.join(root_dir, '**/*.cfg'), recursive=True):
        try:
            bundle = get_bot_config_bundle(filename)
            configs.add(bundle)
        except (NoSectionError, MissingSectionHeaderError, NoOptionError, AttributeError, ParsingError, FileNotFoundError):
            pass

    return configs
410399
def list_path(root_dir):
    
    res = []
    if os.path.isdir(root_dir):
        for name in os.listdir(root_dir):
            res.append(name)
    return res
34849
def handle_basic_container_args(options, parser=None):
    
    dir_modes = {}
    error_fn = parser.error if parser else sys.exit

    def handle_dir_mode(path, mode):
        path = os.path.abspath(path)
        if not os.path.isdir(path):
            error_fn(
                "Cannot specify directory mode for '{}' because it does not exist or is no directory."
                .format(path))
        if path in dir_modes:
            error_fn("Cannot specify multiple directory modes for '{}'.".format(path))
        dir_modes[path] = mode

    for path in options.hidden_dir:
        handle_dir_mode(path, DIR_HIDDEN)
    for path in options.read_only_dir:
        handle_dir_mode(path, DIR_READ_ONLY)
    for path in options.overlay_dir:
        handle_dir_mode(path, DIR_OVERLAY)
    for path in options.full_access_dir:
        handle_dir_mode(path, DIR_FULL_ACCESS)

    if options.keep_tmp:
        if "/tmp" in dir_modes and not dir_modes["/tmp"] == DIR_FULL_ACCESS:
            error_fn("Cannot specify both --keep-tmp and --hidden-dir /tmp.")
        dir_modes["/tmp"] = DIR_FULL_ACCESS
    elif not "/tmp" in dir_modes:
        dir_modes["/tmp"] = DIR_HIDDEN

    if not "/" in dir_modes:
        dir_modes["/"] = DIR_OVERLAY
    if not "/run" in dir_modes:
        dir_modes["/run"] = DIR_HIDDEN

    if options.container_system_config:
        if options.network_access:
            logging.warning("The container configuration disables DNS, "
                "host lookups will fail despite --network-access. "
                "Consider using --keep-system-config.")
    else:
        # /etc/resolv.conf is necessary for DNS lookups and on many systems is a symlink
        # to either /run/resolvconf/resolv.conf or /run/systemd/resolve/sub-resolve.conf,
        # so we keep that directory accessible as well.
        if not "/run/resolvconf" in dir_modes and os.path.isdir("/run/resolvconf"):
            dir_modes["/run/resolvconf"] = DIR_READ_ONLY
        if not "/run/systemd/resolve" in dir_modes and os.path.isdir("/run/systemd/resolve"):
            dir_modes["/run/systemd/resolve"] = DIR_READ_ONLY

    return {
        'network_access': options.network_access,
        'container_tmpfs': options.tmpfs,
        'container_system_config': options.container_system_config,
        'dir_modes': dir_modes,
        }
472264
def get_root_path(self, language):
        
        path = None

        # Get path of the current project
        if self.main and self.main.projects:
            path = self.main.projects.get_active_project_path()

        # If there's no project, use the output of getcwd_or_home.
        if not path:
            # We can't use getcwd_or_home for Python because if it
            # returns home and you have a lot of Python files on it
            # then computing Rope completions takes a long time
            # and blocks the PyLS server.
            # Instead we use an empty directory inside our config one,
            # just like we did for Rope in Spyder 3.
            if language == 'python':
                path = get_conf_path('lsp_root_path')
                if not osp.exists(path):
                    os.mkdir(path)
            else:
                path = getcwd_or_home()

        return path
1261143
def PathIsDir(self, key, val, env):
        """"""
        if not os.path.isdir(val):
            if os.path.isfile(val):
                m = 'Directory path for option %s is a file: %s'
            else:
                m = 'Directory path for option %s does not exist: %s'
            raise SCons.Errors.UserError(m % (key, val))
296395
def paths_in_directory(input_directory):
    
    paths = []
    for base_path, directories, filenames in os.walk(input_directory):
        relative_path = os.path.relpath(base_path, input_directory)
        path_components = relative_path.split(os.sep)
        if path_components[0] == ".":
            path_components = path_components[1:]
        if path_components and path_components[0].startswith("."):
            # hidden dir
            continue
        path_components = filter(bool, path_components)  # remove empty components
        for filename in filenames:
            if filename.startswith("."):
                # hidden file
                continue
            paths.append(path_components + [filename])
    return paths
709640
def groot(path=''):
    ""

    def check_filelist(l):
        if ('README.md' in l) or ('README' in l):
            return True
        else:
            return False

    import os, copy
    cwd = os.getcwd()  # initial dir
    cwd0 = copy.copy(cwd)
    cwd_init = copy.copy(cwd)

    found = False
    sysroot = False

    while not found and not sysroot:
        found = check_filelist(os.listdir())
        if not found:
            os.chdir(os.path.join(cwd, os.pardir))
            cwd = os.getcwd()
            if cwd == cwd0:
                sysroot = True
            else:
                cwd0 = cwd
        else:
            os.chdir(os.path.join(cwd0, path))

    if sysroot:
        os.chdir(cwd_init)
        raise Exception("Root directory not found.")
591817
def _root(path, root):
    '''
    
    '''
    if root:
        return os.path.join(root, os.path.relpath(path, os.path.sep))
    else:
        return path
446782
def root_folders
        @root_folders ||= Dir.glob("#{Dir.pwd}/*", File::FNM_DOTMATCH).collect do |f|
          File.basename(f) if File.directory?(f)
        end.reject { |dir| %w(. ..).include?(dir) }.compact!
      end
587303
def _check_path(self):
        ""
        if not path.isdir(self._path or '/'):
            raise OSError('Path {!r} is not a directory'.format(self._path))
787318
def _fix_paths(self, options):
        
        for k in ('template_path', 'static_path'):
            if k in options:
                v = options.pop(k)
                if v is None:
                    continue
                if not os.path.isabs(v):
                    v = os.path.abspath(
                        os.path.join(self.root_path, v))
                    app_log.debug('Fix %s to be absolute: %s' % (k, v))
                options[k] = v