def list_descrs(exps):

    # sort and group experiments
    exps.sort(lambda x, y: cmp(y['date'], x['date']))
    
    exp_groups = []
    while exps:
        matches = [e for e in exps
                   if e['description'] == exps[0]['description']]

        exp_groups.append(matches)
        for exp in matches:
            exps.remove(exp)
            
    for exp_group in exp_groups:

        print '{:32}  {:4} experiments  last: {}'.format(
                util.trunc(exp_group[0]['description'], 30),
                len(exp_group),
                time.ctime(exp_group[0]['date']))
        print '  last command:', exp_group[0]['command']
        commits = {e['commit'] for e in exp_group}
        
        code = ' '.join([util.trunc(hsh, 6) for hsh in commits])

        has_params = filter(lambda e: 'params' in e and e['params'] is not None,
                            exp_group)
        params = sum([e['params'].keys() for e in has_params], [])

        params_dict = dict((k, [e['params'][k] for e in exp_group]) for k in params)

        print '  code: {}  params: {}'.format(code, params_dict)
def fill_last_args(args):
    """Fill in missing args using the ones from the last
    experiment of the same description"""

    # maybe we don't need to pull up the last experiment at all...
    if args.commit and args.command:
        return args

    last_exps = find_latest(args.description)

    if not last_exps:
        return args

    if not args.commit:
        args.commit = last_exps[0]['commit']
        print 'Filling in previous commit', util.trunc(args.commit, 6)

    if not args.command:
        args.command = last_exps[0]['command']
        print 'Filling in previous command', util.trunc(args.command, 30)

    return args
コード例 #3
0
ファイル: pmcli.py プロジェクト: krispharper/pmcli
def display():
    """Update the main window with some content."""
    main.erase()
    y, i = 0, 1  # y coordinate in main window, current item index.
    (index_chars, name_chars, artist_chars, album_chars, name_start,
     artist_start, album_start) = measure_fields(main.getmaxyx()[1])

    if 'songs' in content and content['songs']:  # Write songs header.
        main.addstr(y, 0, '#',
                    crs.color_pair(2) if colour else crs.A_UNDERLINE)
        main.addstr(y, name_start, trunc('Title', name_chars),
                    crs.color_pair(2) if colour else crs.A_UNDERLINE)
        main.addstr(y, artist_start, trunc('Artist', artist_chars),
                    crs.color_pair(2) if colour else crs.A_UNDERLINE)
        main.addstr(y, album_start, trunc('Album', album_chars),
                    crs.color_pair(2) if colour else crs.A_UNDERLINE)
        y += 1

        for song in content['songs']:  # Write each song.
            main.addstr(
                y, 0,
                str(i).zfill(2),
                crs.color_pair(3 if y % 2 == 0 else 4) if colour else 0)
            main.addstr(
                y, name_start, trunc(song['name'], name_chars),
                crs.color_pair(3 if y % 2 == 0 else 4) if colour else 0)
            main.addstr(
                y, artist_start, trunc(song['artist'], artist_chars),
                crs.color_pair(3 if y % 2 == 0 else 4) if colour else 0)
            main.addstr(
                y, album_start, trunc(song['album'], album_chars),
                crs.color_pair(3 if y % 2 == 0 else 4) if colour else 0)
            y += 1
            i += 1

    if 'artists' in content and content['artists']:  # Write artists header.
        main.addstr(y, 0, '#',
                    crs.color_pair(2) if colour else crs.A_UNDERLINE)
        main.addstr(y, name_start, trunc('Artist', name_chars),
                    crs.color_pair(2) if colour else crs.A_UNDERLINE)
        y += 1

        for artist in content['artists']:  # Write each artist.
            main.addstr(
                y, 0,
                str(i).zfill(2),
                crs.color_pair(3 if y % 2 == 0 else 4) if colour else 0)
            main.addstr(
                y, name_start, trunc(artist['name'], name_chars),
                crs.color_pair(3 if y % 2 == 0 else 4) if colour else 0)
            y += 1
            i += 1

    if 'albums' in content and content['albums']:  # Write albums header.
        main.addstr(y, 0, '#',
                    crs.color_pair(2) if colour else crs.A_UNDERLINE)
        main.addstr(y, name_start, trunc('Album', name_chars),
                    crs.color_pair(2) if colour else crs.A_UNDERLINE)
        main.addstr(y, artist_start, trunc('Artist', artist_chars),
                    crs.color_pair(2) if colour else crs.A_UNDERLINE)
        y += 1

        for album in content['albums']:  # Write each album.
            main.addstr(
                y, 0,
                str(i).zfill(2),
                crs.color_pair(3 if y % 2 == 0 else 4) if colour else 0)
            main.addstr(
                y, name_start, trunc(album['name'], name_chars),
                crs.color_pair(3 if y % 2 == 0 else 4) if colour else 0)
            main.addstr(
                y, artist_start, trunc(album['artist'], artist_chars),
                crs.color_pair(3 if y % 2 == 0 else 4) if colour else 0)
            y += 1
            i += 1

    main.refresh()
コード例 #4
0
ファイル: db.py プロジェクト: Emberwalker/Arke
 def __repr__(self):
     return 'Vote<{}/{}>'.format(self.submitter, trunc(self.question, 20))