Skip to content

Commit

Permalink
py2 support through six and i/o writing stuffs
Browse files Browse the repository at this point in the history
  • Loading branch information
donniebishop committed May 4, 2016
1 parent bac8b8b commit 1185bea
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
5 changes: 3 additions & 2 deletions g_lyrics_funcs.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/usr/bin/env python

import six
import lxml
import requests
import subprocess
Expand Down Expand Up @@ -67,14 +68,14 @@ def pick_from_search(results_array):
for n in range(len(results_array)):
Current = results_array[n]
result_line = '[{}] {} - {}'.format(n+1, Current.artist, Current.title)
print(result_line)
six.print_(result_line)

choice = -1
while choice <= 0 or choice > len(results_array):
try:
choice = int(input('\nPlease select a song number: '))
except ValueError:
print('[!] Please enter a number.')
six.print_('[!] Please enter a number.')
choice = -1

actual_choice = choice - 1
Expand Down
9 changes: 6 additions & 3 deletions genius_lyrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,14 @@
all_together_now = TopResult.form_output()

if args.print_lyrics is True:
print('\n' + all_together_now,)
six.print_('\n' + all_together_now,)
else:
with tempfile.NamedTemporaryFile(prefix='glyrics_', dir='/tmp') as t:
t.write(bytes(all_together_now, 'UTF-8'))
try:
t.write(bytes(all_together_now, 'UTF-8'))
except TypeError:
t.write(bytes(all_together_now))
t.seek(0)
command_list = ['/bin/less', t.name]
subprocess.call(command_list)
print()
six.print_()

0 comments on commit 1185bea

Please sign in to comment.