Process lists of pairs (e.g. PATTERN block)
760550
def format_pair_list(self, key, pair_list, level):
        

        lines = [self.add_start_line(key, level)]

        list_spacer = self.spacer * (level + 2)
        pairs = ["{}{} {}".format(list_spacer, p[0], p[1]) for p in pair_list]
        lines += pairs

        lines.append(self.add_end_line(level, 1, key))

        return lines
270008
def process_options(opts):
    """"""
    # Convert match and exclude args into pattern lists
    match = opts.get("match")
    if match and type(match) is str:
        opts["match"] = [pat.strip() for pat in match.split(",")]
    elif match:
        assert type(match) is list
    else:
        opts["match"] = []

    exclude = opts.get("exclude")
    if exclude and type(exclude) is str:
        opts["exclude"] = [pat.strip() for pat in exclude.split(",")]
    elif exclude:
        assert type(exclude) is list
    else:
        # opts["exclude"] = DEFAULT_OMIT
        opts["exclude"] = []
635040
async def _process_lines(self, pattern: Optional[str] = None) -> None:
        """"""
        if pattern is not None:
            cmp = re.compile(pattern)

        _LOGGER.debug("Start working with pattern '%s'.", pattern)

        # read lines
        while self.is_running:
            try:
                line = await self._input.readline()
                if not line:
                    break
                line = line.decode()
            except Exception:  # pylint: disable=broad-except
                break

            match = True if pattern is None else cmp.search(line)
            if match:
                _LOGGER.debug("Process: %s", line)
                await self._que.put(line)

        try:
            await self._loop.run_in_executor(None, self._proc.wait)
        finally:
            await self._que.put(None)
            _LOGGER.debug("Close read ffmpeg output.")
779257
private void processBlock(List<GenericCriteria> list, byte[] block)
   {
      if (block != null)
      {
         if (MPPUtility.getShort(block, 0) > 0x3E6)
         {
            addCriteria(list, block);
         }
         else
         {
            switch (block[0])
            {
               case (byte) 0x0B:
               {
                  processBlock(list, getChildBlock(block));
                  break;
               }

               case (byte) 0x06:
               {
                  processBlock(list, getListNextBlock(block));
                  break;
               }

               case (byte) 0xED: // EQUALS
               {
                  addCriteria(list, block);
                  break;
               }

               case (byte) 0x19: // AND
               case (byte) 0x1B:
               {
                  addBlock(list, block, TestOperator.AND);
                  break;
               }

               case (byte) 0x1A: // OR
               case (byte) 0x1C:
               {
                  addBlock(list, block, TestOperator.OR);
                  break;
               }
            }
         }
      }
   }
792189
protected void processElement(List<PatternToken> patternTokens) {
    int counter = 0;
    for (PatternToken pToken : patternTokens) {
        if (pToken.getPhraseName() != null && counter > 0 && pToken.isReferenceElement()) {
            int tokRef = pToken.getMatch().getTokenRef();
            pToken.getMatch().setTokenRef(tokRef + counter - 1);
            String offsetToken = pToken.getString().replace("\\" + tokRef,
                    "\\" + (tokRef + counter - 1));
            pToken.setStringElement(offsetToken);
        }
      counter++;
    }
  }
1074564
def process(self, sourcewords, debug=False):
        """"""

        if isinstance( sourcewords, list ) or isinstance( sourcewords, tuple ):
            sourcewords_s = " ".join(sourcewords)            
        else:
            sourcewords_s = sourcewords
            sourcewords = sourcewords.split(' ')
        
        self.socket.sendall(sourcewords_s.encode(self.encoding) +'\n\0')
        if debug: print("Sent:",sourcewords_s.encode(self.encoding),file=sys.stderr)
        
        results = []
        done = False
        while not done:    
            data = b""
            while not data:
                buffer = self.socket.recv(self.BUFSIZE)
                if debug: print("Buffer: ["+repr(buffer)+"]",file=sys.stderr)
                if buffer[-1] == '\0':
                    data += buffer[:-1]
                    done = True
                    break
                else:
                    data += buffer

            
            data = u(data,self.encoding)
            if debug: print("Received:",data,file=sys.stderr) 

            for i, line in enumerate(data.strip(' \t\0\r\n').split('\n')):
                if not line.strip():
                    done = True
                    break
                else:
                    cols = line.split(" ")
                    subwords = cols[0].lower().split("_")
                    if len(cols) > 2: #this seems a bit odd?
                        for word in subwords: #split multiword expressions
                            results.append( (word, cols[1], cols[2], i, len(subwords) > 1 ) ) #word, lemma, pos, index, multiword?

        sourcewords = [ w.lower() for w in sourcewords ]          

        alignment = []
        for i, sourceword in enumerate(sourcewords):
            found = False
            best = 0  
            distance = 999999          
            for j, (targetword, lemma, pos, index, multiword) in enumerate(results):
                if sourceword == targetword and abs(i-j) < distance:
                    found = True
                    best = j
                    distance = abs(i-j)

            if found:
                alignment.append(results[best])
            else:                
                alignment.append((None,None,None,None,False)) #no alignment found
        return alignment
488426
def gather_blocks_2d(x, indices):
  """"""
  x_shape = common_layers.shape_list(x)
  x = reshape_range(x, 2, 4, [tf.reduce_prod(x_shape[2:4])])
  # [length, batch, heads, dim]
  x_t = tf.transpose(x, [2, 0, 1, 3])
  x_new = tf.gather(x_t, indices)
  # returns [batch, heads, num_blocks, block_length ** 2, dim]
  return tf.transpose(x_new, [2, 3, 0, 1, 4])
379262
def process_line(self, record):
        ""
        cleaned = []

        for key in self.vcf_fields:
            out = self.process_column(key, getattr(record, key))
            if isinstance(out, (list, tuple)):
                cleaned.extend(out)
            else:
                cleaned.append(out)

        for key in self.info_fields:
            out = self.process_column(key, record.INFO.get(key, None))
            if isinstance(out, (list, tuple)):
                cleaned.extend(out)
            else:
                cleaned.append(out)

        return cleaned
293093
def chunk_list(l, n):
    """"""
    return [l[i:i + n] for i in range(0, len(l), n)]
560388
def process_repeated_list(self, key, lst, level):
        
        lines = []

        for v in lst:
            k = key.upper()
            v = self.quoter.add_quotes(v)
            lines.append(self.__format_line(self.whitespace(level, 1), k, v))

        return lines
920305
def _process_layout(self, layout):
        """"""
        # Here we just group text into paragraphs
        elements = []
        for lt_obj in layout:
            if isinstance(lt_obj, LTTextBox) or isinstance(lt_obj, LTTextLine):
                elements.append(Paragraph(lt_obj.get_text().strip()))
            elif isinstance(lt_obj, LTFigure):
                # Recursive...
                elements.extend(self._process_layout(lt_obj))
        return elements
204769
def merge!(pairs, options = {})
      hash =
        if block_given?
          keys = pairs.map { |k, _| k }
          old_pairs = Hash[slice(*keys)]
          Hash[pairs.map do |key, new_value|
            new_value = yield(key, old_pairs[key], new_value) if old_pairs.key?(key)
            [key, new_value]
          end.to_a]
        else
          Hash === pairs ? pairs : Hash[pairs.to_a]
        end

      @backend.update(hash)
      self
    end
251713
function processInline(tokens) {
  if (tokens[0] && (tokens[0].type === 'header' ||
      tokens[0].type === 'list' || tokens[0].type === 'ordered-list' ||
      tokens[0].type === 'blockquote')) {
    tokens[0].content = processEmphasis(tokens[0].content);
    tokens[0].length = getTokensLength(tokens[0].content);
    delete tokens[0].markup;
  } else if (Array.isArray(tokens)) {
    tokens = processEmphasis(tokens);
  }

  return tokens;
}
415920
def process(inputLines: List[str]) -> str:
    """"""
    lines = separate_trailing_comments(inputLines)
    merge_continued_lines(lines)
    (lines, comments) = extract_comments(lines)
    actual_lines = [
        line[1]
        for line in lines
        if line[1] is not None and "i_g_n_o_r_e___m_e_" not in line[1]
    ]
    return "".join(actual_lines)
118795
protected boolean runFirstMatch(List /* <PatternPair> */ pairs) throws Exception {
        MatchResult firstResult = null;
        PatternPair firstPair = null;
        int pairIndex = -1;

        ListIterator iter = pairs.listIterator();
        while (iter.hasNext()) {
            PatternPair pair = (PatternPair) iter.next();
            Pattern pattern = pair.getPattern();

            // reset input to begining
            input.setCurrentOffset(input.getBeginOffset());

            if (matcher.contains(input, pattern)) {
                MatchResult result = matcher.getMatch();
                if (firstResult == null || result.beginOffset(0) < firstResult.beginOffset(0)) {
                    firstResult = result;
                    firstPair = pair;
                    pairIndex = iter.previousIndex(); // TODO confirm this
                }
            }
        }

        if (firstResult == null)
            return false; // didn't find anything

        // Found something
        //input's offset are illegal at this phase
        //input.setCurrentOffset(input.getBeginOffset());
        logger.trace("Using a result for " + firstPair.getPattern().getPattern());
        ExpectState state = prepareClosure(pairIndex, firstResult);
        Closure closure = firstPair.getClosure();

        try {
            if (closure != null)
                closure.run(state);
        } catch (Exception e) {
            throw e;
        } finally {
            g_state = state;
        }
        return true;
    }
659165
def resolve(items, run_parallel):
    
    out = []
    to_process = collections.defaultdict(list)
    for data in [x[0] for x in items]:
        if "disambiguate" in data:
            split_part = tuple([int(x) for x in data["align_split"].split("-")]) if data.get("combine") else None
            to_process[(dd.get_sample_name(data), split_part)].append(data)
        else:
            out.append([data])
    if len(to_process) > 0:
        dis1 = run_parallel("run_disambiguate",
                            [(xs, xs[0]["config"]) for xs in to_process.values()])
        disambigs_by_name = collections.defaultdict(list)
        print(len(dis1))
        for xs in dis1:
            assert len(xs) == 1
            data = xs[0]
            disambigs_by_name[dd.get_sample_name(data)].append(data)
        dis2 = run_parallel("disambiguate_merge_extras",
                            [(xs, xs[0]["config"]) for xs in disambigs_by_name.values()])
    else:
        dis2 = []
    return out + dis2
636490
def sort_string_by_pairs(strings):
    """"""
    assert len(strings) % 2 == 0
    pairs = []
    strings = list(strings) # This shallow copies the list
    while strings:
        template = strings.pop()
        for i, candidate in enumerate(strings):
            if count_string_diff(template, candidate) == 1:
                pair = [template, strings.pop(i)]
                pair.sort()
                pairs.append(pair)
                break
    return pairs