|
|
|
@ -1,15 +1,17 @@
|
|
|
|
|
#!/usr/bin/env python |
|
|
|
|
# -*- encoding: utf-8 -*- |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import yaml |
|
|
|
|
import random |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def work(message): |
|
|
|
|
print '>>>', message, '...' |
|
|
|
|
print u'>>>', message, u'...' |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def title(message): |
|
|
|
|
print "\n{0}\n".format(message) |
|
|
|
|
print u"\n{0}\n".format(message) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def display(message): |
|
|
|
@ -17,7 +19,7 @@ def display(message):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_songs(): |
|
|
|
|
work('Getting content') |
|
|
|
|
work(u'Getting content') |
|
|
|
|
result = None |
|
|
|
|
with open('lyrics.yaml') as content: |
|
|
|
|
result = yaml.load(content) |
|
|
|
@ -25,12 +27,12 @@ def get_songs():
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def pick_song(songs): |
|
|
|
|
work('Picking a song') |
|
|
|
|
work(u'Picking a song') |
|
|
|
|
song = random.choice(songs) |
|
|
|
|
|
|
|
|
|
while song['done']: |
|
|
|
|
work('Song "{0}" was already picked, getting a new ' |
|
|
|
|
'one'.format(song['song'])) |
|
|
|
|
work(u'Song "{0}" was already picked, getting a new ' |
|
|
|
|
u'one'.format(song['song'])) |
|
|
|
|
song = random.choice(songs) |
|
|
|
|
|
|
|
|
|
return song |
|
|
|
@ -44,23 +46,23 @@ def firstialize(string):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def show_hints(song): |
|
|
|
|
display('Artist: {0}'.format(firstialize(song['artist']))) |
|
|
|
|
display('Song: {0}'.format(firstialize(song['song']))) |
|
|
|
|
display(u'Artist: {0}'.format(firstialize(song['artist']))) |
|
|
|
|
display(u'Song: {0}'.format(firstialize(song['song']))) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def show_info(song): |
|
|
|
|
display('Artist: {0}'.format(song['artist'])) |
|
|
|
|
display('Song: {0}'.format(song['song'])) |
|
|
|
|
display(u'Artist: {0}'.format(song['artist'])) |
|
|
|
|
display(u'Song: {0}'.format(song['song'])) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def show_song(song): |
|
|
|
|
title('Song picked, here it is:') |
|
|
|
|
title(u'Song picked, here it is:') |
|
|
|
|
display(song['lyrics']) |
|
|
|
|
display('') |
|
|
|
|
display(u'') |
|
|
|
|
|
|
|
|
|
show_hints(song) |
|
|
|
|
|
|
|
|
|
raw_input('Press enter to display the answer:') |
|
|
|
|
raw_input(u'Press enter to display the answer:') |
|
|
|
|
|
|
|
|
|
show_info(song) |
|
|
|
|
|
|
|
|
|