Extract OCLC numbers from, by default 035a's by known prefixes, then stripped
 just the num, and de-dup.
188760
def oclcnum(extract_fields = "035a")
      extractor = MarcExtractor.new(extract_fields, :separator => nil)

      lambda do |record, accumulator|
        list = extractor.extract(record).collect! do |o|
          Marc21Semantics.oclcnum_extract(o)
        end.compact

        accumulator.concat list.uniq if list
      end
    end
1103636
def _prune_entries(self, num):
        ""
        while num > 0:
            self.access_log_lock.acquire()
            p = self.access_log.pop()
            self.access_log_lock.release()

            if not p.is_valid:
                continue # Invalidated entry, skip

            dict.pop(self, p.key, None)
            self.access_lookup.pop(p.key, None)
            num -= 1
295392
def clean_decodes(ids, vocab_size, eos_id=1):
  
  ret = []
  for i in ids:
    if i == eos_id:
      break
    if i >= vocab_size:
      break
    ret.append(int(i))
  return ret
1006874
def prune_overridden(ansi_string):
    
    multi_seqs = set(p for p in RE_ANSI.findall(ansi_string) if ';' in p[1])  # Sequences with multiple color codes.

    for escape, codes in multi_seqs:
        r_codes = list(reversed(codes.split(';')))

        # Nuke everything before {/all}.
        try:
            r_codes = r_codes[:r_codes.index('0') + 1]
        except ValueError:
            pass

        # Thin out groups.
        for group in CODE_GROUPS:
            for pos in reversed([i for i, n in enumerate(r_codes) if n in group][1:]):
                r_codes.pop(pos)

        # Done.
        reduced_codes = ';'.join(sorted(r_codes, key=int))
        if codes != reduced_codes:
            ansi_string = ansi_string.replace(escape, '\033[' + reduced_codes + 'm')

    return ansi_string
626360
def scrub(value, scrub_text=_keep_whitespace, scrub_number=_scrub_number):
    
    return _scrub(value, set(), [], scrub_text=scrub_text, scrub_number=scrub_number)
972298
def _clean_data(data):
    '''
    
    '''
    for key in list(data):
        if key.startswith('__pub'):
            del data[key]
    return data
254249
def _cut(ver):
    ''''''
    ver = ver.split('.')
    for i, part in enumerate(ver):
        try:
            ver[i] = int(part)
        except:
            if part[-len('dev'):] == 'dev':
                ver[i] = int(part[:-len('dev')])
                ver.append(-3)
            else:
                ver[i] = int(part[:-len('a')])
                if part[-len('a'):] == 'a':
                    ver.append(-2)
                else:
                    ver.append(-1)
    return ver
657725
def simplify(self):
        
        expr = self.expr
        self.expr = _cancel_mul(expr, self.registry)
        return self
29667
def purge_catalogue(self, flag_vector):
        '''
        

        '''
        id0 = np.where(flag_vector)[0]
        self.select_catalogue_events(id0)
        self.get_number_events()
547741
def clean_doi(doi_string):
    
    regex = re.compile(r'\b(10[.][0-9]{3,}(?:[.][0-9]+)*/(?:(?!["&\'<>,])\S)+)\b')
    try:
        # Returns a list of matching strings
        m = re.findall(regex, doi_string)
    except TypeError as e:
        # If doi_string is None type, return empty list
        print("TypeError cleaning DOI: {}, {}".format(doi_string, e))
        m = []
    return m
1356661
def prune_creds_json(creds: dict, cred_ids: set) -> str:
    

    rv = deepcopy(creds)
    for key in ('attrs', 'predicates'):
        for attr_uuid, creds_by_uuid in rv[key].items():
            rv[key][attr_uuid] = [cred for cred in creds_by_uuid if cred['cred_info']['referent'] in cred_ids]

        empties = [attr_uuid for attr_uuid in rv[key] if not rv[key][attr_uuid]]
        for attr_uuid in empties:
            del rv[key][attr_uuid]

    return json.dumps(rv)
378704
def __trim_extensions_dot(exts):
  """"""
  if exts is None:
    return None
  res = []
  for i in range(0, len(exts)):
    if exts[i] == "":
      continue
    res.append(__trim_extension_dot(exts[i]))
  return res
1233245
def dedup_source_list(sources)
      sources = sources.uniq
      wild_sources = sources.select { |source| source =~ STAR_REGEXP }

      if wild_sources.any?
        sources.reject do |source|
          !wild_sources.include?(source) &&
            wild_sources.any? { |pattern| File.fnmatch(pattern, source) }
        end
      else
        sources
      end
    end
1198842
def clean(cls, cpf):
        
        """
        if isinstance(cpf, six.string_types):
            cpf = int(re.sub('[^0-9]', '', cpf))

        return '{0:011d}'.format(cpf)
503138
def _prune(self):
        """"""
        delkeys = [k for k in self.keys() if k not in self.__ringbuffer]
        for k in delkeys:  # necessary because dict is changed during iterations
            super(KRingbuffer,self).__delitem__(k)
128688
def remove_duplicates(seq):
    '''
    
    '''
    last_boundary = False
    for char in seq:
        if char == '\x00':
            if not last_boundary:
                last_boundary = True
                yield char
        else:
            last_boundary = False
            yield char
112368
private int dedup(Tag[] src, int ss, Tag[] dst, int ds, int len) {
    if (len == 0) {
      return ds;
    } else {
      dst[ds] = src[ss];
      String k = src[ss].key();
      int j = ds;
      final int e = ss + len;
      for (int i = ss + 1; i < e; ++i) {
        if (k.equals(src[i].key())) {
          dst[j] = src[i];
        } else {
          k = src[i].key();
          dst[++j] = src[i];
        }
      }
      return j + 1;
    }
  }