0
    Manage the relations between triple patterns and collector functions
    :param tp:
    :param collector:
    :param args:
    :return:
494903
def add_triple_pattern(tp, collector, args):
    
    tp_parts = [part.strip() for part in tp.strip().split(' ')]
    tp = ' '.join(tp_parts)
    if tp not in __triple_patterns.keys():
        __triple_patterns[tp] = set([])
    if collector is not None:
        __triple_patterns[tp].add((collector, args))
1136980
def functional(self, *pattern, **kwargs):
        
        set_defaults(self._kwargs, kwargs)
        set_defaults(self._functional_defaults, kwargs)
        set_defaults(self._defaults, kwargs)
        pattern = self.rebulk.build_functional(*pattern, **kwargs)
        part = ChainPart(self, pattern)
        self.parts.append(part)
        return part
638122
def add(self, pattern):
        """"""
        def wrap(f):
            self.functions.append((f, pattern))
            return f

        return wrap
1026858
def mine_get(tgt, fun, tgt_type='glob', opts=None):
    '''
    
    '''
    ret = {}
    serial = salt.payload.Serial(opts)
    checker = CkMinions(opts)
    _res = checker.check_minions(
            tgt,
            tgt_type)
    minions = _res['minions']
    cache = salt.cache.factory(opts)

    if isinstance(fun, six.string_types):
        functions = list(set(fun.split(',')))
        _ret_dict = len(functions) > 1
    elif isinstance(fun, list):
        functions = fun
        _ret_dict = True
    else:
        return {}

    for minion in minions:
        mdata = cache.fetch('minions/{0}'.format(minion), 'mine')

        if not isinstance(mdata, dict):
            continue

        if not _ret_dict and functions and functions[0] in mdata:
            ret[minion] = mdata.get(functions)
        elif _ret_dict:
            for fun in functions:
                if fun in mdata:
                    ret.setdefault(fun, {})[minion] = mdata.get(fun)

    return ret
606675
def map_t(func):
    
    return Transformation('map({0})'.format(name(func)),
                          partial(map, func),
                          {ExecutionStrategies.PARALLEL})
176506
def remove_collector(collector_class)
      return collector_class.each { |c| remove_collector(c) } if collector_class.is_a? Array

      raise ArgumentError, "`collector_class' must be a class" unless collector_class.is_a? Class
      raise ArgumentError, "No collector found with class \“#{collector_class}\"" unless @collectors[collector_class]

      @collectors.delete(collector_class)

      sort_collectors!
    end
847215
def multi_iter(iterable, count=2):
    """"""
    # no need to special-case re-usable, container-like iterables
    if not isinstance(
            iterable,
            (
                    list, tuple, set,
                    FutureChainResults,
                    collections.Sequence, collections.Set, collections.Mapping, collections.MappingView
            )):
        iterable = SafeTee(iterable, n=count)
    return (iter(iterable) for _ in range(count))
736505
def _iter_metadata_triples(cls, metadata_archive_path):
        
        pg_rdf_regex = re.compile(r'pg\d+.rdf$')
        with closing(tarfile.open(metadata_archive_path)) as metadata_archive:
            for item in metadata_archive:
                if pg_rdf_regex.search(item.name):
                    with disable_logging():
                        extracted = metadata_archive.extractfile(item)
                        graph = Graph().parse(extracted)
                    for fact in graph:
                        if cls._metadata_is_invalid(fact):
                            logging.info('skipping invalid triple %s', fact)
                        else:
                            yield fact
1104566
def addpattern(base_func):
    """"""
    def pattern_adder(func):
        @_coconut.functools.wraps(func)
        @_coconut_tco
        def add_pattern_func(*args, **kwargs):
            try:
                return base_func(*args, **kwargs)
            except _coconut_MatchError:
                raise _coconut_tail_call(func, *args, **kwargs)
        return add_pattern_func
    return pattern_adder
923625
def store_relation(self, src, name, dst):
        '''  '''
        self.__require_string__(name)
        #print('storing relation', src, name, dst)
        # make sure both items are stored
        self.store_item(src).link(name, self.store_item(dst))
1111630
def combine_middlewares(middlewares, web3, provider_request_fn):
    
    return functools.reduce(
        lambda request_fn, middleware: middleware(request_fn, web3),
        reversed(middlewares),
        provider_request_fn,
    )
403684
def compile_pattern(self):
        
        if self.PATTERN is not None:
            PC = PatternCompiler()
            self.pattern, self.pattern_tree = PC.compile_pattern(self.PATTERN,
                                                                 with_tree=True)
1171161
private void replacePattern(
      NodeTraversal t, Node pattern, Node rhs, Node parent, Node nodeToDetach) {
    checkArgument(NodeUtil.isStatement(nodeToDetach), nodeToDetach);
    switch (pattern.getToken()) {
      case ARRAY_PATTERN:
        replaceArrayPattern(t, pattern, rhs, parent, nodeToDetach);
        break;
      case OBJECT_PATTERN:
        replaceObjectPattern(t, pattern, rhs, parent, nodeToDetach);
        break;
      default:
        throw new IllegalStateException("unexpected");
    }
  }
632409
def add_filter_by_pattern(self, pattern, filter_type=DefaultFilterType):
        
        self.add_filter(FilterPattern(pattern), filter_type)
        return self
866317
def relate_to(self, part, reltype):
        
        rel = self.rels.get_or_add(reltype, part)
        return rel.rId
1126471
def tpf(args):
    
    p = OptionParser(tpf.__doc__)
    p.add_option("--noversion", default=False, action="store_true",
            help="Remove trailing accession versions [default: %default]")
    p.add_option("--gaps", default=False, action="store_true",
            help="Include gaps in the output [default: %default]")
    opts, args = p.parse_args(args)

    if len(args) != 1:
        sys.exit(not p.print_help())

    agpfile, = args
    agp = AGP(agpfile)
    for a in agp:
        object = a.object
        if a.is_gap:
            if opts.gaps and a.isCloneGap:
                print("\t".join((a.gap_type, object, "na")))
            continue

        component_id = a.component_id
        orientation = a.orientation

        if opts.noversion:
            component_id = component_id.rsplit(".", 1)[0]

        print("\t".join((component_id, object, orientation)))
1208831
def resolve_pattern(pattern):
    ''''''
    if os.path.exists(pattern) and os.path.isdir(pattern):
        pattern = os.path.join(pattern, '**/*.bench.py')
    return recursive_glob(pattern)