Return print format for Grouper, which includes hdr1usr01 and num_usrgos.
15845
def get_prtfmt(self, key="fmta"):
        """"""
        prtfmt = self.sortobj.grprobj.gosubdag.prt_attr[key]
        prtfmt = prtfmt.replace("{NS}", "{NS} {num_usrgos:>4} uGOs")
        return "".join(['{hdr1usr01:2}', prtfmt, '\n'])
619994
def pprint(sequence, keys=None):
    
    if len(sequence) > 0:
        columns = calculate_columns(sequence)
        row_format = calculate_row_format(columns, keys)
        header = row_format % dict([(key, key.title()) for key in columns])
        separator = row_format % dict([(key, '-' * columns[key]) for key in columns])

        print(separator)
        print(header)
        print(separator)

        for row in sequence:
            print(row_format % row)

        print(separator)
77169
static String humanReadableUnits(long bytes, DecimalFormat df) {
    if (bytes / ONE_GB > 0) {
      return df.format((float) bytes / ONE_GB) + " GB";
    } else if (bytes / ONE_MB > 0) {
      return df.format((float) bytes / ONE_MB) + " MB";
    } else if (bytes / ONE_KB > 0) {
      return df.format((float) bytes / ONE_KB) + " KB";
    } else {
      return bytes + " bytes";
    }
  }
1313914
def pprint(self, num=10):
        

        def pprint_map(time_, rdd):
            print('>>> Time: {}'.format(time_))
            data = rdd.take(num + 1)
            for d in data[:num]:
                py_pprint.pprint(d)
            if len(data) > num:
                print('...')
            print('')

        self.foreachRDD(pprint_map)
1036664
def _get_prtfmt(self, objgowr, verbose):
        """"""
        prtfmt = objgowr.get_prtfmt('fmt')
        prtfmt = prtfmt.replace('# ', '')
        # print('PPPPPPPPPPP', prtfmt)
        if not verbose:
            prtfmt = prtfmt.replace('{hdr1usr01:2}', '')
            prtfmt = prtfmt.replace('{childcnt:3} L{level:02} ', '')
            prtfmt = prtfmt.replace('{num_usrgos:>4} uGOs ', '')
            prtfmt = prtfmt.replace('{D1:5} {REL} {rel}', '')
            prtfmt = prtfmt.replace('R{reldepth:02} ', '')
        # print('PPPPPPPPPPP', prtfmt)
        marks = ''.join(['{{{}}}'.format(nt.hdr) for nt in self.go_ntsets])
        return '{MARKS} {PRTFMT}'.format(MARKS=marks, PRTFMT=prtfmt)
1108324
def print_formatted(datas):
    
    if not datas:
        print("No data")
        exit(1)

    if isinstance(datas, list):
        # get all zones
        # API /zone without :identifier
        hr()
        print('%-20s %-8s %-12s'
              % ('name', 'type', 'notified_serial'))
        hr()
        for record in datas:

            # print 'NAME'
            utils.print_inline("%(name)-20s" % record)

            # print 'TYPE' of SOA record
            utils.print_inline("%(type)-8s" % record)

            if record.get('notified_serial'):
                print("%(notified_serial)s" % record)
            else:
                print('')

        exit(0)

    elif datas.get('records'):
        print("domain: %(name)s" % datas)

        if datas.get('type') == 'MASTER' and datas.get('notified_serial'):
            print("serial: %(notified_serial)s" % datas)

        print("DNS   : %(type)s" % datas)

        # print header
        hr()
        print('%-33s %-5s %-25s %-5s %-3s'
              % ('name', 'type', 'content', 'ttl', 'prio'))
        hr()

        for record in datas.get('records'):

            # print 'NAME'
            utils.print_inline("%(name)-33s" % record)

            # print 'TYPE' of SOA record
            if record.get('type') == 'SOA':
                print("%(type)-5s" % record)

            # print 'TYPE' of non SOA record
            else:
                utils.print_inline("%(type)-5s" % record)

            # print 'CONTENT' of non SOA
            if record.get('type') == 'SOA':
                utils.print_inline(">\t\t%(content)-25s " % record)

            # print 'CONTENT' of SOA record
            else:
                utils.print_inline("%(content)-25s" % record)

            # print TTL, and PRIORITY for MX, SRV record
            if record.get('priority'):
                utils.print_inline("%(ttl)5s" % record)
                print("%(priority)2s" % record)

            # print ttl for non SOA record
            else:
                print("%(ttl)5s " % record)

        hr()

    elif datas.get('identifier'):
        # for template
        print("identifier : %(identifier)s" % datas)
        print("description: %(description)s" % datas)
        hr()
        print('%-33s %-5s %-25s %-5s %-3s'
              % ('name', 'type', 'content', 'ttl', 'prio'))

        for record in datas.get('entries'):

            # print 'NAME'
            utils.print_inline("%(name)-33s" % record)

            # print 'TYPE' for SOA
            if record.get('type') == 'SOA':
                print("%(type)-5s" % record)

            # print 'TYPE' for non SOA
            else:
                utils.print_inline("%(type)-5s" % record)

            # print 'CONTENT' for SOA
            if record.get('type') == 'SOA':
                utils.print_inline("> %(content)-25s " % record)

            # print 'CONTENT' for non SOA
            else:
                utils.print_inline("%(content)-24s" % record)

            # print 'TTL', and 'PRIORITY'
            if record.get('priority') is not None:
                utils.print_inline("%(ttl)5s" % record)
                print("%(priority)2s" % record)

            # print
            else:
                print("%(ttl)5s " % record)
        hr()
    else:
        print("No match records")
453102
def get_go2txt(grprobj_cur, grp_go2color, grp_go2bordercolor):
        """"""
        goids_main = set(o.id for o in grprobj_cur.gosubdag.go2obj.values())
        hdrobj = grprobj_cur.hdrobj
        grprobj_all = Grouper("all",
                              grprobj_cur.usrgos.union(goids_main), hdrobj, grprobj_cur.gosubdag)
        # Adds section text to all GO terms in plot (misses middle GO terms)
        _secdflt = hdrobj.secdflt
        _hilight = set(grp_go2color.keys()).union(grp_go2bordercolor)
        ret_go2txt = {}
        # Keep sections text only if GO header, GO user, or not Misc.
        if hdrobj.sections:
            for goid, txt in grprobj_all.get_go2sectiontxt().items():
                if txt == 'broad':
                    continue
                if txt != _secdflt or goid in _hilight:
                    ret_go2txt[goid] = txt
        return ret_go2txt
269704
def GetFormatSpecification(cls):
    
    format_specification = specification.FormatSpecification(cls.NAME)
    format_specification.AddNewSignature(b'BAAD', offset=0)
    format_specification.AddNewSignature(b'FILE', offset=0)
    return format_specification
1010094
def get_hdr(self, goid, goobj):
        """'"""
        hdr = []
        ntgo = self.gosubdag.go2nt.get(goid)
        prt_flds = self._get_prtflds()
        # Add letter to depth-01 GO Node.
        if 'D1' in prt_flds and goobj.depth == 1:
            hdr.append("{ABC} ".format(ABC=ntgo.D1))
        hdr.append(self.str_fmthdr(goid, goobj))
        if 'level' in prt_flds:
            hdr.append("L{level}".format(level=goobj.level))
        if 'depth' in prt_flds:
            hdr.append("D{depth}".format(depth=goobj.depth))
        if 'reldepth' in prt_flds:
            hdr.append("R{reldepth}".format(reldepth=goobj.reldepth))
        # Print count of parents for this GO term
        if 'c2ps' in self.kws:
            self._add_parent_cnt(hdr, goobj, self.kws['c2ps'])
        # Print count of children for this GO term
        childcnt_str = self._get_hdr_childcnt(goobj, ntgo)
        if childcnt_str:
            hdr.append(childcnt_str)
        # Print count of all descendants down to the leaf-level for this GO term
        if 'dcnt' in prt_flds:
            hdr.append("d{N}".format(N=ntgo.dcnt))
        if 'tinfo' in prt_flds:
            hdr.append("i{I:4.02f}".format(I=ntgo.tinfo))
        if 'REL' in prt_flds:
            hdr.append("{R}".format(R=ntgo.REL_short))
        return " ".join(hdr)
1143356
def print_stats(self, stream=None):
        
        if not stream: # pragma: no cover
            stream = sys.stdout
        self.metadata.sort(key=lambda x: -x.size)
        stream.write('%-10s %8s %-12s %-46s\n' % ('id', 'size', 'type', 'representation'))
        for g in self.metadata:
            stream.write('0x%08x %8d %-12s %-46s\n' % (g.id, g.size, trunc(g.type, 12),
                trunc(g.str, 46)))
        stream.write('Garbage: %8d collected objects (%s in cycles): %12s\n' % \
            (self.count, self.num_in_cycles, pp(self.total_size)))
459716
def _print_returns_summary(self, ret):
        '''
        
        '''
        return_counter = 0
        not_return_counter = 0
        not_return_minions = []
        not_response_minions = []
        not_connected_minions = []
        failed_minions = []
        for each_minion in ret:
            minion_ret = ret[each_minion]
            if isinstance(minion_ret, dict) and 'ret' in minion_ret:
                minion_ret = ret[each_minion].get('ret')
            if (
                    isinstance(minion_ret, six.string_types)
                    and minion_ret.startswith("Minion did not return")
                    ):
                if "Not connected" in minion_ret:
                    not_connected_minions.append(each_minion)
                elif "No response" in minion_ret:
                    not_response_minions.append(each_minion)
                not_return_counter += 1
                not_return_minions.append(each_minion)
            else:
                return_counter += 1
                if self._get_retcode(ret[each_minion]):
                    failed_minions.append(each_minion)
        salt.utils.stringutils.print_cli('\n')
        salt.utils.stringutils.print_cli('-------------------------------------------')
        salt.utils.stringutils.print_cli('Summary')
        salt.utils.stringutils.print_cli('-------------------------------------------')
        salt.utils.stringutils.print_cli('# of minions targeted: {0}'.format(return_counter + not_return_counter))
        salt.utils.stringutils.print_cli('# of minions returned: {0}'.format(return_counter))
        salt.utils.stringutils.print_cli('# of minions that did not return: {0}'.format(not_return_counter))
        salt.utils.stringutils.print_cli('# of minions with errors: {0}'.format(len(failed_minions)))
        if self.options.verbose:
            if not_connected_minions:
                salt.utils.stringutils.print_cli('Minions not connected: {0}'.format(" ".join(not_connected_minions)))
            if not_response_minions:
                salt.utils.stringutils.print_cli('Minions not responding: {0}'.format(" ".join(not_response_minions)))
            if failed_minions:
                salt.utils.stringutils.print_cli('Minions with failures: {0}'.format(" ".join(failed_minions)))
        salt.utils.stringutils.print_cli('-------------------------------------------')
220212
def stats(args):
    
    cat = _catalog(args)
    print('Summary:')
    print('  {0:,} objects with {1:,} bitstreams of total size {2}'.format(
        len(cat), sum(len(obj.bitstreams) for obj in cat), cat.size_h))
    print('  {0} duplicate bitstreams'.format(
        sum(1 for objs in cat.md5_to_object.values() if len(objs) > 1)))
    print('  {0} objects with no bitstreams'.format(
        sum(1 for obj in cat if not obj.bitstreams)))

    print()
    types = Counter(chain(*[[bs.mimetype for bs in obj.bitstreams] for obj in cat]))
    table = Table('maintype', 'subtype', 'bitstreams')
    for maintype, items in groupby(
            sorted(types.items(), key=lambda p: (p[0].split('/')[0], -p[1])),
            lambda p: p[0].split('/')[0]):
        for k, v in items:
            table.append([maintype, k.split('/')[1], v])
    print(table.render(tablefmt='simple'))
877436
def print_num(num):
    '''  '''
    out('hex: 0x{0:08x}'.format(num))
    out('dec:   {0:d}'.format(num))
    out('oct: 0o{0:011o}'.format(num))
    out('bin: 0b{0:032b}'.format(num))
226846
def PythonPercentFormat(format_str):
  """"""

  if format_str.startswith('printf '):
    fmt = format_str[len('printf '):]
    return lambda value: fmt % value
  else:
    return None
715524
def grouper(n, iterable):
    
    return (iterable[i:i + n] for i in range(0, len(iterable), n))
629047
def toc_print(self):
        """"""
        res = self.toc()
        for n, k, v in res:
            logging.info('Batch: {:7d} {:30s} {:s}'.format(n, k, v))
577161
def pretty_print(self, show_datetime=True):
        
        if show_datetime:
            return u"[%s] %s %s%s: %s" % (
                self.severity,
                gf.object_to_unicode(self.time),
                u" " * self.indentation,
                self.tag,
                self.message
            )
        return u"[%s] %s%s: %s" % (
            self.severity,
            u" " * self.indentation,
            self.tag,
            self.message
        )