def stats(args):
    """
    cdstarcat stats

    Print summary statistics of bitstreams in the catalog to stdout.
    """
    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'))
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' ) )
cdstarcat stats

    Print summary statistics of bitstreams in the catalog to stdout.