Return a list of simple index directories that should be searched
        for package indexes when compiling the main index page.
488336
def get_simple_dirs(self, simple_dir: Path) -> List[Path]:
        """"""
        if self.hash_index:
            # We are using index page directory hashing, so the directory
            # format is /simple/f/foo/.  We want to return a list of dirs
            # like "simple/f".
            subdirs = [simple_dir / x for x in simple_dir.iterdir() if x.is_dir()]
        else:
            # This is the traditional layout of /simple/foo/.  We should
            # return a single directory, "simple".
            subdirs = [simple_dir]
        return subdirs
348408
def list_():
    '''
    

    '''
    ret = []
    states_path = _states_path()
    if not os.path.isdir(states_path):
        return ret

    for state in os.listdir(states_path):
        if state.endswith(('-pkgs.yml', '-reps.yml')):
            # Remove the suffix, as both share the same size
            ret.append(state[:-9])
    return sorted(set(ret))
121187
def index(self):
        

        config_list = self.config
        layout = self.layout

        for (dirpath, dirnames, filenames) in os.walk(self.path):

            # If layout configuration file exists, delete it
            layout_file = self.layout.config_filename
            if layout_file in filenames:
                filenames.remove(layout_file)

            for f in filenames:

                abs_fn = os.path.join(self.path, f)

                # Skip files that fail validation, unless forcibly indexing
                if not self.force_index and not layout._validate_file(abs_fn):
                    continue

                bf = BIDSFile(abs_fn, self)

                # Extract entity values
                match_vals = {}
                for e in self.available_entities.values():
                    m = e.match_file(bf)
                    if m is None and e.mandatory:
                        break
                    if m is not None:
                        match_vals[e.name] = (e, m)

                # Create Entity <=> BIDSFile mappings
                if match_vals:
                    for name, (ent, val) in match_vals.items():
                        bf.entities[name] = val
                        ent.add_file(bf.path, val)

                self.files.append(bf)
                # Also add to the Layout's master list
                self.layout.files[bf.path] = bf

            root_node = self if self.root is None else self.root

            for d in dirnames:

                d = os.path.join(dirpath, d)

                # Derivative directories must always be added separately and
                # passed as their own root, so terminate if passed.
                if d.startswith(os.path.join(self.layout.root, 'derivatives')):
                    continue

                # Skip directories that fail validation, unless force_index
                # is defined, in which case we have to keep scanning, in the
                # event that a file somewhere below the current level matches.
                # Unfortunately we probably can't do much better than this
                # without a lot of additional work, because the elements of
                # .force_index can be SRE_Patterns that match files below in
                # unpredictable ways.
                if check_path_matches_patterns(d, self.layout.force_index):
                    self.force_index = True
                else:
                    valid_dir = layout._validate_dir(d)
                    # Note the difference between self.force_index and
                    # self.layout.force_index.
                    if not valid_dir and not self.layout.force_index:
                        continue

                child_class = self._get_child_class(d)
                # TODO: filter the config files based on include/exclude rules
                child = child_class(d, config_list, root_node, self,
                                    force_index=self.force_index)

                if self.force_index or valid_dir:
                    self.children.append(child)

            # prevent subdirectory traversal
            break
630058
def get_backends():
    
    IGNORE_DIRS = ["core", "tools", "utils"]

    global backends
    if backends is None:
        backends = {}
        i3pystatus_dir = os.path.dirname(i3pystatus.__file__)
        subdirs = [
            x
            for x in next(os.walk(i3pystatus_dir))[1]
            if not x.startswith("_") and x not in IGNORE_DIRS
        ]
        for subdir in subdirs:
            dirs = next(os.walk(os.path.join(i3pystatus_dir, subdir)))[2]
            backends.update(
                {
                    x[:-3]: "i3pystatus.%s.%s" % (subdir, x[:-3])
                    for x in dirs
                    if not x.startswith("_") and x.endswith(".py")
                }
            )
    return backends
881834
def directories(self):
        
        directories_description = [
            self.project_name,
            self.project_name + '/conf',
            self.project_name + '/static',
        ]
        return directories_description
1075327
def _get_all_indexes(self):
        """"""
        if self.parser:
            return [v.index for v in self.parser.get_volumes()] + [d.index for d in self.parser.disks]
        else:
            return None
991207
def pkg_list(self):
        
        options = [
            "-l",
            "--list"
        ]
        flag = ["--index", "--installed", "--name"]
        name = INDEX = installed = False
        for arg in self.args[2:]:
            if flag[0] == arg:
                INDEX = True
            if flag[1] in arg:
                installed = True
            if flag[2] == arg:
                name = True
            if arg not in flag:
                usage("")
                raise SystemExit()
        if (len(self.args) > 1 and len(self.args) <= 5 and
                self.args[0] in options):
            if self.args[1] in self.meta.repositories:
                PackageManager(binary=None).package_list(self.args[1],
                                                         name,
                                                         INDEX,
                                                         installed)
            else:
                usage(self.args[1])
        else:
            usage("")
1007751
def get_list(
        self,
        search='',
        start=0,
        limit=0,
        order_by='',
        order_by_dir='ASC',
        published_only=False,
        minimal=False
    ):
        

        parameters = {}
        args = ['search', 'start', 'limit', 'minimal']
        for arg in args:
            if arg in locals() and locals()[arg]:
                parameters[arg] = locals()[arg]
        if order_by:
            parameters['orderBy'] = order_by
        if order_by_dir:
            parameters['orderByDir'] = order_by_dir
        if published_only:
            parameters['publishedOnly'] = 'true'
        response = self._client.session.get(
            self.endpoint_url, params=parameters
        )
        return self.process_response(response)
251116
def checkout_dirs(self):
        """"""
        directories = [os.path.join(self.base_directory, d)
                       for d in os.listdir(self.base_directory)]
        return [d for d in directories if os.path.isdir(d)]
19070
def search_index_simple(self,index,key,search_term):
        '''
        
        '''
        request = self.session
        url = 'http://%s:%s/%s/_search?q=%s:%s' % (self.host,self.port,index,key,search_term)
        response = request.get(url)
        return response
1313261
def _get_package_data():
    
    from os import listdir as ls
    from os.path import join as jn

    x = 'init'
    b = jn('serv', x)
    dr = ['binaries', 'templates']
    return [jn(x, d, f) for d in ls(b) if d in dr for f in ls(jn(b, d))]
437864
def getIndex(folderPath=None):
    """"""
    try:    return cache.structure
    except AttributeError: pass # if it doesn't exist, generate and cache the map file data
    if folderPath == None:
        from sc2maptool.startup import setup
        folderPath = setup()
    ############################################################################
    def folderSearch(path, attrList=[]):
        ret = []
        for item in glob(os.path.join(path, '*')):
            if item == os.sep: continue
            itemName = os.path.basename(item)
            if   os.path.isdir(item):               ret += folderSearch(item, attrList + [itemName])
            elif itemName.endswith(c.SC2_MAP_EXT):  ret.append( MapRecord(itemName, item, attrList) )
        return ret
    ############################################################################
    cache.structure = folderSearch(folderPath)
    return cache.structure
308133
protected void buildIndexMap(RootDoc root)  {
        PackageDoc[] packages = root.specifiedPackages();
        ClassDoc[] classes = root.classes();
        if (!classesOnly) {
            if (packages.length == 0) {
                Set<PackageDoc> set = new HashSet<PackageDoc>();
                PackageDoc pd;
                for (int i = 0; i < classes.length; i++) {
                    pd = classes[i].containingPackage();
                    if (pd != null && pd.name().length() > 0) {
                        set.add(pd);
                    }
                }
                adjustIndexMap(set.toArray(packages));
            } else {
                adjustIndexMap(packages);
            }
        }
        adjustIndexMap(classes);
        if (!classesOnly) {
            for (int i = 0; i < classes.length; i++) {
                if (shouldAddToIndexMap(classes[i])) {
                    putMembersInIndexMap(classes[i]);
                }
            }
        }
        sortIndexMap();
    }
817998
def get_directories_re(
            self,
            directory_re,
            full_path=False,
            ignorecase=False):
        """"""
        if ignorecase:
            compiled_re = re.compile(directory_re, re.I)
        else:
            compiled_re = re.compile(directory_re)

        found = set()

        if self.handle:
            for member in self.handle.getmembers():
                # zipfiles only list directories => have to work around that
                if isinstance(member, ZipInfo):
                    to_match = os.path.dirname(member.name)
                # tarfiles => only match directories
                elif isinstance(member, TarInfo) and member.isdir():
                    to_match = member.name
                else:
                    to_match = None
                if to_match:
                    if ((full_path and compiled_re.search(to_match)) or (
                            not full_path and compiled_re.search(
                                os.path.basename(to_match)))):
                        found.add(to_match)

        return list(found)
1084184
def dirs(self, *args, **kwargs):
        
        return [p for p in self.listdir(*args, **kwargs) if p.isdir()]
571473
def get_filelist(run_module_names):
    
    # Prep search patterns
    spatterns = [{},{},{},{},{},{},{}]
    epatterns = [{}, {}]
    ignored_patterns = []
    for key, sps in config.sp.items():
        mod_name = key.split('/', 1)[0]
        if mod_name.lower() not in [m.lower() for m in run_module_names]:
            ignored_patterns.append(key)
            continue
        files[key] = list()
        if not isinstance(sps, list):
            sps = [sps]

        # Warn if we have any unrecognised search pattern keys
        expected_sp_keys = [
            'fn',
            'fn_re',
            'contents',
            'contents_re',
            'num_lines',
            'shared',
            'max_filesize',
            'exclude_fn',
            'exclude_fn_re',
            'exclude_contents',
            'exclude_contents_re'
        ]
        unrecognised_keys = [y for x in sps for y in x.keys() if y not in expected_sp_keys]
        if len(unrecognised_keys) > 0:
            logger.warn("Unrecognised search pattern keys for '{}': {}".format(key, ', '.join(unrecognised_keys)))

        # Split search patterns according to speed of execution.
        if any([x for x in sps if 'contents_re' in x]):
            if any([x for x in sps if 'num_lines' in x]):
                spatterns[4][key] = sps
            elif any([x for x in sps if 'max_filesize' in x]):
                spatterns[5][key] = sps
            else:
                spatterns[6][key] = sps
        elif any([x for x in sps if 'contents' in x]):
            if any([x for x in sps if 'num_lines' in x]):
                spatterns[1][key] = sps
            elif any([x for x in sps if 'max_filesize' in x]):
                spatterns[2][key] = sps
            else:
                spatterns[3][key] = sps
        else:
            spatterns[0][key] = sps

    if len(ignored_patterns) > 0:
        logger.debug("Ignored {} search patterns as didn't match running modules.".format(len(ignored_patterns)))

    def add_file(fn, root):
        """
        Function applied to each file found when walking the analysis
        directories. Runs through all search patterns and returns True
        if a match is found.
        """
        f = {'fn': fn, 'root': root}

        # Check that this is a file and not a pipe or anything weird
        if not os.path.isfile(os.path.join(root, fn)):
            return None

        # Check that we don't want to ignore this file
        i_matches = [n for n in config.fn_ignore_files if fnmatch.fnmatch(fn, n)]
        if len(i_matches) > 0:
            logger.debug("Ignoring file as matched an ignore pattern: {}".format(fn))
            return None

        # Limit search to small files, to avoid 30GB FastQ files etc.
        try:
            f['filesize'] = os.path.getsize(os.path.join(root,fn))
        except (IOError, OSError, ValueError, UnicodeDecodeError):
            logger.debug("Couldn't read file when checking filesize: {}".format(fn))
        else:
            if f['filesize'] > config.log_filesize_limit:
                return False

        # Test file for each search pattern
        for patterns in spatterns:
            for key, sps in patterns.items():
                for sp in sps:
                    if search_file (sp, f):
                        # Check that we shouldn't exclude this file
                        if not exclude_file(sp, f):
                            # Looks good! Remember this file
                            files[key].append(f)
                        # Don't keep searching this file for other modules
                        if not sp.get('shared', False):
                            return
                        # Don't look at other patterns for this module
                        else:
                            break

    # Go through the analysis directories and get file list
    for path in config.analysis_dir:
        if os.path.islink(path) and config.ignore_symlinks:
            continue
        elif os.path.isfile(path):
            searchfiles.append([os.path.basename(path), os.path.dirname(path)])
        elif os.path.isdir(path):
            for root, dirnames, filenames in os.walk(path, followlinks=(not config.ignore_symlinks), topdown=True):
                bname = os.path.basename(root)

                # Skip any sub-directories matching ignore params
                orig_dirnames = dirnames[:]
                for n in config.fn_ignore_dirs:
                    dirnames[:] = [d for d in dirnames if not fnmatch.fnmatch(d, n.rstrip(os.sep))]
                    if len(orig_dirnames) != len(dirnames):
                        removed_dirs = [os.path.join(root, d) for d in set(orig_dirnames).symmetric_difference(set(dirnames))]
                        logger.debug("Ignoring directory as matched fn_ignore_dirs: {}".format(", ".join(removed_dirs)))
                        orig_dirnames = dirnames[:]
                for n in config.fn_ignore_paths:
                    dirnames[:] = [d for d in dirnames if not fnmatch.fnmatch(os.path.join(root, d), n.rstrip(os.sep))]
                    if len(orig_dirnames) != len(dirnames):
                        removed_dirs = [os.path.join(root, d) for d in set(orig_dirnames).symmetric_difference(set(dirnames))]
                        logger.debug("Ignoring directory as matched fn_ignore_paths: {}".format(", ".join(removed_dirs)))

                # Skip *this* directory if matches ignore params
                d_matches = [n for n in config.fn_ignore_dirs if fnmatch.fnmatch(bname, n.rstrip(os.sep))]
                if len(d_matches) > 0:
                    logger.debug("Ignoring directory as matched fn_ignore_dirs: {}".format(bname))
                    continue
                p_matches = [n for n in config.fn_ignore_paths if fnmatch.fnmatch(root, n.rstrip(os.sep))]
                if len(p_matches) > 0:
                    logger.debug("Ignoring directory as matched fn_ignore_paths: {}".format(root))
                    continue
                # Search filenames in this directory
                for fn in filenames:
                    searchfiles.append([fn, root])
    # Search through collected files
    with click.progressbar(searchfiles, label="Searching {} files..".format(len(searchfiles))) as sfiles:
        for sf in sfiles:
            add_file(sf[0], sf[1])
1116259
def lib_directories(self):
        """"""
        if self._lib_directories is None:
            self._lib_directories = []
            app_path = os.getcwd()
            contents = os.listdir(app_path)
            for c in contents:
                # ensure content starts with lib, is directory, and is readable
                if c.startswith('lib') and os.path.isdir(c) and (os.access(c, os.R_OK)):
                    self._lib_directories.append(c)
        return sorted(self._lib_directories, reverse=True)