Returns a new FmtStr with the same content but new formatting
773085
def copy_with_new_atts(self, **attributes):
        """"""
        return FmtStr(*[Chunk(bfs.s, bfs.atts.extend(attributes))
                        for bfs in self.chunks])
675126
def format_label(sl, fmt=None):
    
    if isinstance(sl, str):
        # Already is a string.
        return sl

    if fmt:
        return fmt.format(*sl)

    return ' '.join(str(s) for s in sl)
459704
def readfmt(stream, fmt):
    """"""
    size = struct.calcsize(fmt)
    blob = stream.read(size)
    return struct.unpack(fmt, blob)
765676
def readline(self, fmt=None):
        
        prefix_size = self._fix()

        if fmt is None:
            content = self.read(prefix_size)
        else:
            fmt = self.endian + fmt
            fmt = _replace_star(fmt, prefix_size)
            content = struct.unpack(fmt, self.read(prefix_size))

        try:
            suffix_size = self._fix()
        except EOFError:
            # when endian is invalid and prefix_size > total file size
            suffix_size = -1

        if prefix_size != suffix_size:
            raise IOError(_FIX_ERROR)

        return content
237418
def detect_format(program, attributes) -> str:
    '''
        
    '''

    def fmt(attr):
        '''
            For internal use only.
        '''

        return attr.array_length * attr.dimension, attr.shape

    return ' '.join('%d%s' % fmt(program[a]) for a in attributes)
863897
def floatformat(fmt_string):
    
    fmt_defaults = scientificformat.__defaults__
    scientificformat.__defaults__ = (fmt_string,) + fmt_defaults[1:]
    try:
        yield
    finally:
        scientificformat.__defaults__ = fmt_defaults
833736
public void format(StringBuffer fmt, Set done, Set todo, int indent) {
    formatName(fmt, indent);
    fmt.append("{\n");
    for (int i = 0; i < cases.length; i++) {
      if (i > 0)
        fmt.append(" |\n");
      cases[i].format(fmt, done, todo, indent + 2);
    }
    fmt.append("\n");
    indent(fmt, indent);
    fmt.append("}");
  }
395936
def addstrf(self, format, *args):
        
        return lib.zmsg_addstrf(self._as_parameter_, format, *args)
139195
def fmt(self):
        
        val = str(self.year)
        if self.month is not None:
            val += ' ' + str(self.month)
            if self.day is not None:
                val += ' ' + str(self.day)
        return val
1273074
String unformattedContents() {
    switch(currentCell.getType()) {
      case "s":           //string stored in shared table
        if (!lastContents.isEmpty()) {
            int idx = Integer.parseInt(lastContents);
            return new XSSFRichTextString(sst.getEntryAt(idx)).toString();
        }
        return lastContents;
      case "inlineStr":   //inline string (not in sst)
        return new XSSFRichTextString(lastContents).toString();
      default:
        return lastContents;
    }
  }
439903
def _format_table(fmt, headers, rows, colwidths, colaligns, is_multiline):
    """"""
    lines = []
    hidden = fmt.with_header_hide if (headers and fmt.with_header_hide) else []
    pad = fmt.padding
    headerrow = fmt.headerrow

    padded_widths = [(w + 2 * pad) for w in colwidths]
    if is_multiline:
        pad_row = lambda row, _: row  # do it later, in _append_multiline_row
        append_row = partial(_append_multiline_row, pad=pad)
    else:
        pad_row = _pad_row
        append_row = _append_basic_row

    padded_headers = pad_row(headers, pad)
    padded_rows = [pad_row(row, pad) for row in rows]

    if fmt.lineabove and "lineabove" not in hidden:
        _append_line(lines, padded_widths, colaligns, fmt.lineabove)

    if padded_headers:
        append_row(lines, padded_headers, padded_widths, colaligns, headerrow)
        if fmt.linebelowheader and "linebelowheader" not in hidden:
            _append_line(lines, padded_widths, colaligns, fmt.linebelowheader)

    if padded_rows and fmt.linebetweenrows and "linebetweenrows" not in hidden:
        # initial rows with a line below
        for row in padded_rows[:-1]:
            append_row(lines, row, padded_widths, colaligns, fmt.datarow)
            _append_line(lines, padded_widths, colaligns, fmt.linebetweenrows)
        # the last row without a line below
        append_row(lines, padded_rows[-1], padded_widths, colaligns, fmt.datarow)
    else:
        for row in padded_rows:
            append_row(lines, row, padded_widths, colaligns, fmt.datarow)

    if fmt.linebelow and "linebelow" not in hidden:
        _append_line(lines, padded_widths, colaligns, fmt.linebelow)

    return "\n".join(lines)
992940
def fsliceafter(astr, sub):
    """"""
    findex = astr.find(sub)
    return astr[findex + len(sub):]
1091441
@javax.annotation.Nonnull
  public String format(@javax.annotation.Nonnull String fmt, @javax.annotation.Nonnull Object... args) {
    return 0 == args.length ? fmt : String.format(fmt, args);
  }
211629
def _get_fmt(self, fmt):
        

        # iterate over the format string looking for format specifiers
        components = [ ]
        i = 0
        while i < len(fmt):
            if type(fmt[i]) is bytes and fmt[i] == b"%":
                # Note that we only support concrete format specifiers
                # grab the specifier
                # go to the space
                specifier = b""
                for c in fmt[i+1:]:
                    if type(c) is bytes:
                        specifier += c
                    else:
                        break

                specifier = self._match_spec(specifier)
                if specifier is not None:
                    i += len(specifier)
                    components.append(specifier)
                else:
                    # if we get here we didn't match any specs, the first char will be thrown away
                    # and we'll add the percent
                    i += 1
                    components.append(b'%')
            else:
                # claripy ASTs, which are usually symbolic variables
                # They will be kept as they are - even if those chars can be evaluated to "%"
                components.append(fmt[i])
            i += 1

        return FormatString(self, components)
1090672
def shared_atts(self):
        """"""
        #TODO cache this, could get ugly for large FmtStrs
        atts = {}
        first = self.chunks[0]
        for att in sorted(first.atts):
            #TODO how to write this without the '???'?
            if all(fs.atts.get(att, '???') == first.atts[att] for fs in self.chunks if len(fs) > 0):
                atts[att] = first.atts[att]
        return atts
445455
def read_fmt(fmt, fp):
    
    fmt = str(">" + fmt)
    fmt_size = struct.calcsize(fmt)
    data = fp.read(fmt_size)
    assert len(data) == fmt_size, 'read=%d, expected=%d' % (
        len(data), fmt_size
    )
    return struct.unpack(fmt, data)
397211
def FromString(cls, indata):
        

        lines = [x.strip() for x in indata.split("\n") if not x.startswith('#') and not x.strip() == ""]

        if len(lines) < 3:
            raise DataError("Invalid CommandFile string that did not contain 3 header lines", lines=lines)

        fmt_line, version_line, ascii_line = lines[:3]

        if not version_line.startswith("Format: "):
            raise DataError("Invalid format version that did not start with 'Format: '", line=version_line)

        version = version_line[8:]

        if ascii_line != "Type: ASCII":
            raise DataError("Unknown file type line (expected Type: ASCII)", line=ascii_line)

        cmds = [cls.decode(x) for x in lines[3:]]
        return CommandFile(fmt_line, version, cmds)