Feature added: sp piece_number shows movements

This commit is contained in:
2023-11-08 12:09:07 +01:00
parent 626dfc25fc
commit 488a97f3f6
2 changed files with 11 additions and 2 deletions

View File

@@ -19,7 +19,7 @@ At the moment, an alpha version is undertaken, with these features:
- Show the pieces stored in the database (`s`)
- Mark pieces as mastered for the active user (`m number_of_work`)
- Show pieces by composer (`sc` shows composers, `c number_of_composer` shows pieces)
- (planned) Show movements through pieces
- Show movements through pieces (`sp piece_number`)
- (planned) Mark movement as mastered for active user
- (planned) Save recordings per movement in db
- (planned) Listen to saved recordings

View File

@@ -40,6 +40,8 @@ class Session:
self.resultstring += self.show_works()
elif command == 'sc':
self.resultstring += self.show_works(restraint=f'comp_id = {arguments[0]}')
elif command == 'sp':
self.resultstring += self.show_movements(arguments[0])
elif command == 'su':
self.resultstring += self.show_users()
elif command == 'q':
@@ -69,6 +71,13 @@ class Session:
fun_resultstring += f'{item[0]}: {item[2]}, {item[1]}\n'
return fun_resultstring
def show_movements(self, work_id):
work = work_under_id(work_id, self.db_agent)
fun_resultstring = ''
for mov_number in work.values['movements'].keys():
fun_resultstring += f'{mov_number}. {work.pretty_mov(mov_number)}\n'
return fun_resultstring
def show_users(self):
sql_command = '''
SELECT * FROM pianist;
@@ -220,7 +229,7 @@ class work_under_id:
def parse_user_input(user_in):
split_user_in = user_in.split()
command = split_user_in[0]
if command in ('a', 'c', 'm', 'n', 'q', 's', 'sc', 'su'):
if command in ('a', 'c', 'm', 'n', 'q', 's', 'sc', 'sp', 'su'):
arguments = split_user_in[1:]
return (command, arguments)
else: