Filters from a set of paths based on acceptable patterns and
    ignorable patterns.
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
1364897
def _filter_path(self, path):
        
        if self._is_videofile(path):
            return [path, ]

        if os.path.isdir(path):
            result = []
            for root, dirs, files in os.walk(path):
                result.extend(filter(self._is_videofile, map(
                    lambda f: os.path.join(root, f), files)))
            return result
        else:
            return []
1270870
def greedy_trails(subg, odds, verbose):
    ''''''
    if verbose:
        print('\tCreating edge map')

    edges = defaultdict(list)

    for x,y in subg.edges():
        edges[x].append(y)
        edges[y].append(x)

    if verbose:
        print('\tSelecting trails')

    trails = []
    for x in subg.nodes():
        if verbose > 2:
            print('\t\tNode {0}'.format(x))

        while len(edges[x]) > 0:
            y = edges[x][0]
            trail = [(x,y)]
            edges[x].remove(y)
            edges[y].remove(x)
            while len(edges[y]) > 0:
                x = y
                y = edges[y][0]
                trail.append((x,y))
                edges[x].remove(y)
                edges[y].remove(x)
            trails.append(trail)
    return trails
891207
def filter_req_paths(paths, func):
    """"""
    if not isinstance(paths, list):
        raise ValueError("Paths must be a list of paths.")

    libs = set()
    junk = set(['\n'])
    for p in paths:
        with p.open(mode='r') as reqs:
            lines = set([line for line in reqs if func(line)])
            libs.update(lines)

    return list(libs - junk)
100364
def _filtered_walk(path, file_filter):
		
		for root, dirs, files in os.walk(path):
			log.debug('looking in %s', root)
			log.debug('files is %s', files)
			file_filter.set_root(root)
			files = filter(file_filter, files)
			log.debug('filtered files is %s', files)
			yield (root, dirs, files)
1186545
def match_filters(self, path):
        
        # indicate if all required filters were matched
        all_required_match = True

        # iterate over filters to match files
        for filt, ftype in self.__filters:

            # handle "Required" filters:
            if all_required_match and ftype == self.FilterType.Required and not filt.match(path):
                all_required_match = False

            # handle "Include" filters:
            elif ftype == self.FilterType.Include and filt.match(path):
                return True

            # handle "Exclude" filters:
            elif ftype == self.FilterType.Exclude and filt.match(path):
                return False

        # if got here it means we processed all filters, and no include/exclude filter was matched.
        # return if all required were matched
        return all_required_match
681690
def select_paths(cls, dataset, selection):
        
        return [s[0] for s in np.array([{0: p} for p in dataset.data])[selection]]
1374998
def map_over_glob(fn, path, pattern):
    """"""
    return [fn(x) for x in glob.glob(os.path.join(path, pattern))]
141135
def get_filter_ngrams_pattern(filter_ngrams):
        
        return re.compile('|'.join([re.escape(ngram) for ngram in
                                    filter_ngrams]))
824283
def _path_factory(check):
    """"""

    @functools.wraps(check)
    def validator(paths):
        if isinstance(paths, str):
            check(paths)
        elif isinstance(paths, collections.Sequence):
            for path in paths:
                check(path)
        else:
            raise Exception('expected either basestr or sequenc of basstr')

    return validator
1217483
def match_patterns(pathname, patterns):
    """"""
    for pattern in patterns:
        if fnmatch(pathname, pattern):
            return True
    return False
424835
public boolean isAllowed(String path) {
    for (String filter : STARTS_WITH_FILTER) {
      if (path.startsWith(filter)) {
        return false;
      }
    }
    for (String filter : CONTAINS_FILTER) {
      if (path.contains(filter)) {
        return false;
      }
    }
    return true;
  }
1373304
def filter(self, filter):
        """"""
        if hasattr(filter, '__call__'):
            return [entry for entry in self.entries if filter(entry)]
        else:
            pattern = re.compile(filter, re.IGNORECASE)
            return [entry for entry in self.entries if pattern.match(entry)]
484904
def build_patterns(fnames):
    """"""
    patterns = []
    for fn in fnames:
        et = ET.parse(fn)
        res = et.findall('CC') + et.findall('EVENT')
        for event in res:
            G = networkx.DiGraph()
            build_event_graph(G, et, event)
            add_graph(patterns, G)
    patterns = sorted(patterns, key=lambda x: len(x[0]), reverse=True)
    return patterns
83661
def unstructured_mappers(self):
        
        return filter(lambda m: path_type.UNSTRUCTURED in m.path_types, self.mappers)
956073
function filter(patterns) {
  if (typeof patterns === 'function') {
    return patterns;
  }

  return function(str) {
    var arr = ['\\[\\!\\[', '{%', '<%'].concat(patterns || []);
    var re = new RegExp(arr.join('|'));
    return !re.test(str);
  };
}
1202895
function (runtime, path, rules) {
            var mappedRules = rules ||
                    runtime.Config.mappedRules ||
                    [],
                i,
                m,
                rule;
            for (i = 0; i < mappedRules.length; i++) {
                rule = mappedRules[i];
                if (m = path.match(rule[0])) {
                    return path.replace(rule[0], rule[1]);
                }
            }
            return path;
        }