Compute the total size per group and total number of files. Useful to check that everything is OK.
773843
def grouped_count_sizes(fileslist, fgrouped):  # pragma: no cover
    ''''''
    fsizes = {}
    total_files = 0
    allitems = None
    if isinstance(fgrouped, dict):
        allitems = fgrouped.iteritems()
    elif isinstance(fgrouped, list):
        allitems = enumerate(fgrouped)
    for fkey, cluster in allitems:
        fsizes[fkey] = []
        for subcluster in cluster:
            tot = 0
            if subcluster is not None:
                for fname in subcluster:
                    tot += fileslist[fname]
                    total_files += 1
            fsizes[fkey].append(tot)
    return fsizes, total_files
823047
def size(args):
    
    p = OptionParser(size.__doc__)
    opts, args = p.parse_args(args)

    if len(args) < 1:
        sys.exit(not p.print_help())

    total_size = total_numrecords = 0
    for f in args:
        cur_size = cur_numrecords = 0
        for rec in iter_fastq(f):
            if not rec:
                break
            cur_numrecords += 1
            cur_size += len(rec)

        print(" ".join(str(x) for x in \
                (op.basename(f), cur_numrecords, cur_size)))
        total_numrecords += cur_numrecords
        total_size += cur_size

    if len(args) > 1:
        print(" ".join(str(x) for x in \
                ("Total", total_numrecords, total_size)))
625973
def folder_size(pth, ignore=None):
    
    if not os.path.isdir(pth):
        raise exc.FolderNotFound

    ignore = coerce_to_list(ignore)

    total = 0
    for root, _, names in os.walk(pth):
        paths = [os.path.realpath(os.path.join(root, nm)) for nm in names]
        for pth in paths[::-1]:
            if not os.path.exists(pth):
                paths.remove(pth)
            elif match_pattern(pth, ignore):
                paths.remove(pth)
        total += sum(os.stat(pth).st_size for pth in paths)

    return total
132120
def size(filename, format='decimal'):
    '''
    

    '''
    if isinstance(filename, file):
        filename = filename.name

    return filesize(os.stat(filename)[stat.ST_SIZE], format)
1207752
def size(self):
        

        size = 0
        try:
            tip = self.get_changeset()
            for topnode, dirs, files in tip.walk('/'):
                for f in files:
                    size += tip.get_file_size(f.path)
                for dir in dirs:
                    for f in files:
                        size += tip.get_file_size(f.path)

        except RepositoryError:
            pass
        return size
299702
def calc_piece_size(size, min_piece_size=20, max_piece_size=29, max_piece_count=1000):
    
    logger.debug('Calculating piece size for %i' % size)

    for i in range(min_piece_size, max_piece_size): # 20 = 1MB
        if size / (2**i) < max_piece_count:
            break
    return 2**i
1278465
def filesize(self):
        
        if self.from_stdin:
            return None
        if not self._filesize:
            self._calculate_bounds()
        return self._filesize
549747
def check_size_all(self):
        
        result = self.rpc_srv.get_all_account(self.token)
        print "debug: %s" % result
        for it in result:
            size = getFolderSize(it["path"])
            result = self.rpc_srv.set_account_size(self.token, it["id"], size)
473247
def filesize(self):
        """"""
        if self.kind == 'data':
            return len(self._data.data)
        return self._data.filesize
313851
def total_size(self):
        
        if self.inst.is_array:
            # Total size of arrays is technically supposed to be:
            #   self.inst.array_stride * (self.inst.n_elements-1) + self.size
            # However this opens up a whole slew of ugly corner cases that the
            # spec designers may not have anticipated.
            # Using a simplified calculation for now until someone actually cares
            return self.inst.array_stride * self.inst.n_elements

        else:
            return self.size
1174234
def size(self):
        
        if self._instrs is []:
            return None

        return sum([instr.size for instr in self._instrs])
149568
def _compute_all_files(self):
        """"""
        self._all_files = any(pat.all_files() for pat in self.patterns)
210418
def _calc_dir_size(path):
    
    dir_size = 0
    for (root, dirs, files) in os.walk(path):
        for fn in files:
            full_fn = os.path.join(root, fn)
            dir_size += os.path.getsize(full_fn)

    return dir_size
678946
def getsizeof(o, ids=None):
    '''
    
    '''
    ids = ids or set()
    if id(o) in ids:
        return 0

    nbytes = sys.getsizeof(o)
    ids.add(id(o))

    if isinstance(o, Mapping):
        return nbytes + sum(getsizeof(k, ids) + getsizeof(v, ids)
                            for k, v in o.items())
    elif isinstance(o, Container):
        return nbytes + sum(getsizeof(x, ids) for x in o)

    return nbytes
1133715
def safe_size_check(checked_path, error_detail, max_bytes=500000000):
    """"""
    actual_size = 0
    for dirpath, dirnames, filenames in os.walk(checked_path):
        for f in filenames:
            fp = os.path.join(dirpath, f)
            actual_size += os.path.getsize(fp)

    assert actual_size <= max_bytes, "Path {} size of {} >= {} bytes. {}".format(
        checked_path, actual_size, max_bytes, error_detail)
357397
static long getTotalSize(Collection<Allocation> allocations) {
    long totalSize = 0;
    for (Allocation allocation : allocations) {
      totalSize += allocation.size;
    }
    return totalSize;
  }
806874
def is_valid_size(size, chunk_size):
        """"""
        min_csize = current_app.config['FILES_REST_MULTIPART_CHUNKSIZE_MIN']
        max_size = \
            chunk_size * current_app.config['FILES_REST_MULTIPART_MAX_PARTS']
        return size > min_csize and size <= max_size