Ejemplo n.º 1
0
def clean(pr):
    '''PlayRecord --> PlayRecord

    Clean up a record so it can be stored.
    Raise ValueError on incomplete data.

    '''
    # decompose
    title, artist, played = pr
    # construct
    pr = clean_string(title), clean_string(artist), int(played)
    # validate
    if all(pr):
        return pr
    else:
        raise ValueError('invalid PlayRecord {}'.format(pr))
Ejemplo n.º 2
0
 def song(render=json.dumps):
     song, artist = db.get_randsong()
     return render(dict(
         song=clean_string(song),
         artist=clean_string(artist),
     ))