Format preconditions as reST.

    :param preconditions: preconditions of a function
    :param prefix: prefix of the ``:requires:`` and ``:requires else:`` directive
    :return: list of lines
763515
def _format_preconditions(preconditions: List[List[icontract._Contract]], prefix: Optional[str] = None) -> List[str]:
    
    if not preconditions:
        return []

    result = []  # type: List[str]
    for i, group in enumerate(preconditions):
        if i == 0:
            if prefix is not None:
                result.append(":{} requires:".format(prefix))
            else:
                result.append(":requires:")
        else:
            if prefix is not None:
                result.append(":{} requires else:".format(prefix))
            else:
                result.append(":requires else:")

        for precondition in group:
            result.append("    * {}".format(_format_contract(contract=precondition)))

    return result
767747
def _clause_formatter(self, cond):
        '''
        '''

        if len(cond) == 2 :
            cond = ' '.join(cond)
            return cond

        if 'in' in cond[1].lower() :
            if not isinstance(cond[2], (tuple, list)):
                    raise TypeError('("{0}") must be of type <type tuple> or <type list>'.format(cond[2]))

            if 'select' not in cond[2][0].lower() :
                cond[2] = "({0})".format(','.join(map(str,["'{0}'".format(e) for e in cond[2]])))
            else:
                cond[2] = "({0})".format(','.join(map(str,["{0}".format(e) for e in cond[2]])))

            cond = " ".join(cond)
        else: 
            #if isinstance(cond[2], str):
            #    var = re.match('^@(\w+)$', cond[2])
            #else:
            #    var = None
            #if var :
            if isinstance(cond[2], str) and cond[2].startswith('@'):
                cond[2] = "{0}".format(cond[2])
            else :
                cond[2] = "'{0}'".format(cond[2])
            cond = ' '.join(cond)

        return cond
1277584
def parse_headers(buff):
    
    preamble_lines = list(map(
        lambda x: six.u(x).decode(),
        iter(lambda: buff.readline().strip(), b''))
    )
    if not preamble_lines:
        raise EmptyBuffer()
    return preamble_lines[0], OrderedDict([l.split(':') for l in preamble_lines[1:]])
413622
function prefixBlock(prefix, block, skipEmpty) {
    var lines = block.split('\n');
    for (var i =0; i<lines.length; i++) {
      // Do not prefix empty lines
      if (lines[i].length === 0 && skipEmpty === true)
        continue;
      else
        lines[i] = prefix + lines[i];
    }
    return lines.join('\n');
  }
257601
def format_commands(self, ctx, formatter):
        
        commands = []
        for subcommand in self.list_commands(ctx):
            cmd = self.get_command(ctx, subcommand)
            # What is this, the tool lied about a command.  Ignore it
            if cmd is None:
                continue
            if cmd.hidden:
                continue

            commands.append((subcommand, cmd))

        # allow for 3 times the default spacing
        if len(commands):
            limit = formatter.width - 6 - max(len(cmd[0]) for cmd in commands)

            rows = []
            for subcommand, cmd in commands:
                help = cmd.get_short_help_str(limit)
                rows.append((subcommand, help))

            if rows:
                with formatter.section('Commands'):
                    formatter.write_dl(rows)
724256
function format(answers) {
  // parentheses are only needed when a scope is present
  const scope = answers.scope ? '(' + answers.scope.trim() + ') ' : ''

  // build head line and limit it to 100
  const head = truncate(answers.type + ' ' + scope + answers.subject.trim(), 100)

  // wrap body at 100
  const body = wrap(answers.body, 100)

  const footer = (answers.issues.match(/#\d+/g) || [])
    .map(issue => `Closes ${issue}`)
    .join('\n')

  return [head, body, footer]
    .join('\n\n')
    .trim()
}
14106
public function compileConditions()
    {
        // Find if-s
        $this->prepared = preg_replace('/@if\s?(.+)/', '<?php if($1) { ?>', $this->prepared);

        // Find elseif-s
        $this->prepared = preg_replace('/@elseif\s?(.+)/', '<?php } elseif($1) { ?>', $this->prepared);

        // Find else-s
        $this->prepared = preg_replace('/@else/', '<?php } else { ?>', $this->prepared);

        // Find endif-s
        $this->prepared = preg_replace('/@endif/', '<?php } ?>', $this->prepared);
    }
1312402
def handle_preconditions(id_generator)
      # Nest multiple preconditions under a single root precondition
      @preconditions = @entry.xpath('./*/cda:precondition[not(@nullFlavor)]', HQMF2::Document::NAMESPACES)
                       .collect do |pre|
        precondition = Precondition.parse(pre, @doc, id_generator)
        precondition.reference.nil? && precondition.preconditions.empty? ? nil : precondition
      end
      # Remove uneeded nils from the array
      @preconditions.compact!
    end
1223250
def _pre_suf_fix_filter(t: List, prefix: str, suffix: str) -> bool:
        

        if prefix:
            for a_token in t:
                if a_token._.n_prefix(len(prefix)) != prefix:
                    return False
        if suffix:
            for a_token in t:
                if a_token._.n_suffix(len(suffix)) != suffix:
                    return False

        return True
664791
protected String concatPredicates(List<Predicate> predicateList) {
    List<String> conditions = new ArrayList<>();
    for (Predicate predicate : predicateList) {
      conditions.add(predicate.getCondition());
    }
    return Joiner.on(" and ").skipNulls().join(conditions);
  }
1250583
function getConditions (req) {
  if (req.baucis.conditions === undefined) {
    req.baucis.conditions = {};
    req.baucis.conditions[this.findBy()] = req.params.id;
  }
  return req.baucis.conditions;
}
198918
def concat_expr(operator, conditions):
    
    expr = " {0} ".format(operator).join(conditions)
    return ["({0})".format(expr)] if expr else []
774267
def format_requirement(ireq):
    

    if ireq.editable:
        line = "-e {}".format(ireq.link)
    else:
        line = _requirement_to_str_lowercase_name(ireq.req)

    if str(ireq.req.marker) != str(ireq.markers):
        if not ireq.req.marker:
            line = "{}; {}".format(line, ireq.markers)
        else:
            name, markers = line.split(";", 1)
            markers = markers.strip()
            line = "{}; ({}) and ({})".format(name, markers, ireq.markers)

    return line
388076
def _CheckConditionsShortCircuit(content_conditions, pathspec):
  """"""
  matches = []
  for cond in content_conditions:
    with vfs.VFSOpen(pathspec) as vfs_file:
      cur_matches = list(cond.Search(vfs_file))
    if cur_matches:
      matches.extend(cur_matches)
    else:  # As soon as one condition does not match, we skip the file.
      return []  # Return no matches to indicate skipping this file.
  return matches
197566
private List<String> preparePrefixes() {
        // Prepare prefixes for all schemas
        List<String> prefixes = new ArrayList<String>(Schema.values().length + (local ? 3 : 0));
        for (Schema schema : Schema.values()) {
            prefixes.add(schema.getPrefix());
        }

        // For local URls prefixes are "./", "../", "/"
        if (local) {
            Collections.addAll(prefixes, LOCAL_PREFIXES);
        }
        return prefixes;
    }
455938
public void addPreEditorConditionDefinition(I_CmsPreEditorActionDefinition preEditorCondition) {

        m_preEditorConditionDefinitions.add(preEditorCondition);
        if (CmsLog.INIT.isInfoEnabled()) {
            CmsLog.INIT.info(
                Messages.get().getBundle().key(
                    Messages.INIT_EDITOR_PRE_ACTION_2,
                    preEditorCondition.getClass().getName(),
                    preEditorCondition.getResourceTypeName()));
        }
    }
396191
private void searchPrefixes(int depth, int[] choices, 
                              List<int[]> prefixes) {
    if (depth == 0) {
      prefixes.add(choices.clone());
    } else {
      ColumnHeader<ColumnName> col = findBestColumn();
      if (col.size > 0) {
        coverColumn(col);
        Node<ColumnName> row = col.down;
        int rowId = 0;
        while (row != col) {
          Node<ColumnName> node = row.right;
          while (node != row) {
            coverColumn(node.head);
            node = node.right;
          }
          choices[choices.length - depth] = rowId;
          searchPrefixes(depth - 1, choices, prefixes);
          node = row.left;
          while (node != row) {
            uncoverColumn(node.head);
            node = node.left;
          }
          row = row.down;
          rowId += 1;
        }
        uncoverColumn(col);
      }
    }
  }