~linaro-toolchain-dev/cortex-strings/trunk

« back to all changes in this revision

Viewing changes to scripts/libplot.py

  • Committer: Michael Hope
  • Date: 2011-09-02 00:18:24 UTC
  • Revision ID: michael.hope@linaro.org-20110902001824-rklwpoiungg4u2bs
Various plotting updates.

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
 
20
20
def unique(records, name, prefer=''):
21
21
    """Return the unique values of a column in the records"""
22
 
    values = set(getattr(x, name) for x in records)
23
 
 
24
 
    return sorted(values, key=lambda x: '%d|%s' % (-prefer.find(x), x))
25
 
 
 
22
    values = list(set(getattr(x, name) for x in records))
 
23
 
 
24
    if not values:
 
25
        return values
 
26
    elif type(values[0]) == str:
 
27
        keys = ['%06d|%s' % (-prefer.find(x), x) for x in values]
 
28
        print keys, prefer
 
29
        return sorted(values, key=lambda x: '%-06d|%s' % (-prefer.find(x), x))
 
30
    else:
 
31
        return sorted(values)
26
32
 
27
33
def parse():
28
34
    """Parse a record file into named tuples, correcting for loop