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))
def song(render=json.dumps): song, artist = db.get_randsong() return render(dict( song=clean_string(song), artist=clean_string(artist), ))