Print the rows as a summary.

    Keyword arguments:
    limit -- the maximum number of elements to be listed
    sort  -- sort elements by 'size', 'type', or '#'
    order -- sort 'ascending' or 'descending'
556659
def print_(rows, limit=15, sort='size', order='descending'):
    
    localrows = []
    for row in rows:
        localrows.append(list(row))
    # input validation
    sortby = ['type', '#', 'size']
    if sort not in sortby:
        raise ValueError("invalid sort, should be one of" + str(sortby))
    orders = ['ascending', 'descending']
    if order not in orders:
        raise ValueError("invalid order, should be one of" + str(orders))
    # sort rows
    if sortby.index(sort) == 0:
        if order == "ascending":
            localrows.sort(key=lambda x: _repr(x[0]))
        elif order == "descending":
            localrows.sort(key=lambda x: _repr(x[0]), reverse=True)
    else:
        if order == "ascending":
            localrows.sort(key=lambda x: x[sortby.index(sort)])
        elif order == "descending":
            localrows.sort(key=lambda x: x[sortby.index(sort)], reverse=True)
    # limit rows
    localrows = localrows[0:limit]
    for row in localrows:
        row[2] = stringutils.pp(row[2])
    # print rows
    localrows.insert(0,["types", "# objects", "total size"])
    _print_table(localrows)
449171
def items(self, limit=0):
        """"""
        i = ItemIterator(self.iterator)
        i.limit = limit
        return i
764276
def _print_result_info(traces, events):
    
    print_v('Returning %i traces:'%len(traces))
    for r in sorted(traces.keys()):
        x = traces[r]
        print_v('  %s (%s): %s -> %s (min: %s, max: %s, len: %i)'%(r, type(x), x[0],x[-1],min(x),max(x),len(x)))
    print_v('Returning %i events:'%len(events))
    for r in sorted(events.keys()):
        x = events[r]
        print_v('  %s: %s -> %s (len: %i)'%(r, x[0] if len(x)>0 else '-',x[-1] if len(x)>0 else '-',len(x)))
476935
def first(self, limit=1, columns=None):
        
        if not columns:
            columns = ['*']

        results = self.take(limit).get(columns)

        if len(results) > 0:
            return results[0]

        return
753452
def limit(self, limit):
        
        query = self._copy()
        query._limit = limit
        return query
178762
def limit(self, limit):
        
        if self._limit != limit:
            self.dirty = True
            self._limit = limit
        return self
1359716
def tail(self, n=None, **kwargs):
        
        if n is None:
            n = options.display.max_rows
        return self._handle_delay_call('execute', self, tail=n, **kwargs)
902156
def summarize(self):
        ''''''

        self.speak('Here is a brief summary of {}.'.format(self.nametag))
        s = '\n'+pprint.pformat(self.__dict__)
        print(s.replace('\n', '\n'+' '*(len(self._prefix)+1)) + '\n')
1134141
def init_limit(self, key, lower=None, upper=None, limit=False):
        
        above = agtb(self.__dict__[key], upper)
        for idx, item in enumerate(above):
            if item == 0.:
                continue
            maxval = upper[idx]
            self.log(
                '{0} <{1}.{2}> above its maximum of {3}.'.format(
                    self.name[idx], self._name, key, maxval), ERROR)
            if limit:
                self.__dict__[key][idx] = maxval

        below = altb(self.__dict__[key], lower)
        for idx, item in enumerate(below):
            if item == 0.:
                continue
            minval = lower[idx]
            self.log(
                '{0} <{1}.{2}> below its minimum of {3}.'.format(
                    self.name[idx], self._name, key, minval), ERROR)
            if limit:
                self.__dict__[key][idx] = minval
1254320
def preview(self, limit=None, width=None):
        
        heading = self.heading
        rel = self.proj(*heading.non_blobs)
        if limit is None:
            limit = config['display.limit']
        if width is None:
            width = config['display.width']
        tuples = rel.fetch(limit=limit+1, format="array")
        has_more = len(tuples) > limit
        tuples = tuples[:limit]
        columns = heading.names
        widths = {f: min(max([len(f)] +
            [len(str(e)) for e in tuples[f]] if f in tuples.dtype.names else [len('=BLOB=')]) + 4, width) for f in columns}
        templates = {f: '%%-%d.%ds' % (widths[f], widths[f]) for f in columns}
        return (
            ' '.join([templates[f] % ('*' + f if f in rel.primary_key else f) for f in columns]) + '\n' +
            ' '.join(['+' + '-' * (widths[column] - 2) + '+' for column in columns]) + '\n' +
            '\n'.join(' '.join(templates[f] % (tup[f] if f in tup.dtype.names else '=BLOB=')
                for f in columns) for tup in tuples) +
            ('\n   ...\n' if has_more else '\n') +
            (' (Total: %d)\n' % len(rel) if config['display.show_tuple_count'] else ''))
40584
def clean_limit(self):
        ""
        limit = self.cleaned_data.get('limit', None)
        if (settings.SELECTABLE_MAX_LIMIT is not None and
            (not limit or limit > settings.SELECTABLE_MAX_LIMIT)):
            limit = settings.SELECTABLE_MAX_LIMIT
        return limit
745552
def print_summary(self, stream=sys.stdout, indent=""):
        
        stream.write("%sTotal files      : %i\n" %
                     (indent, len(self.file_dict)))
        stream.write("%s  Input files    : %i\n" %
                     (indent, len(self.input_files)))
        stream.write("%s  Output files   : %i\n" %
                     (indent, len(self.output_files)))
        stream.write("%s  Internal files : %i\n" %
                     (indent, len(self.internal_files)))
        stream.write("%s  Temp files     : %i\n" %
                     (indent, len(self.temp_files)))
1291596
def _parse_limit(self, limit):
        
        if limit is None:
            return None

        limit_parsed = {
            "include": [],
            "exclude": []
        }
        elems = limit.split(":")
        for elem in elems:
            if elem.startswith('!'):
                limit_parsed['exclude'].append(elem[1:])
            else:
                limit_parsed['include'].append(elem)

        return limit_parsed
888757
def row_csv_limiter(rows, limits=None):
    

    limits = [None, None] if limits is None else limits

    if len(exclude_empty_values(limits)) == 2:
        upper_limit = limits[0]
        lower_limit = limits[1]
    elif len(exclude_empty_values(limits)) == 1:
        upper_limit = limits[0]
        lower_limit = row_iter_limiter(rows, 1, -1, 1)
    else:
        upper_limit = row_iter_limiter(rows, 0, 1, 0)
        lower_limit = row_iter_limiter(rows, 1, -1, 1)

    return rows[upper_limit: lower_limit]
716961
def _limit(lower, upper):
    """"""
    if ((lower < 0) or (upper <= 0) or (upper < lower)):
        raise Exception("Illegal argument to _limit")
    return unicod("{%d,%d}") % (lower, upper)
1340361
def _print_counts(self):
        
        print "#  ",
        for i in range(self.width):
            print "  %4d   "%i,
        print
        for L in ['A', 'C', 'T', 'G']:
            print "#%s "%L,
            for i in range(self.width):
                print  "%8.3f "%self.counts[i][L],
            print
276906
def limit_(self, r=5):
        
        try:
            return self._duplicate_(self.df[:r])
        except Exception as e:
            self.err(e, "Can not limit data")