From 10894187b23c712655288dc7b57adaf61ecf025c Mon Sep 17 00:00:00 2001 From: Jan Bertram Date: Thu, 19 Oct 2023 20:35:12 +0200 Subject: [PATCH] new feature show works --- README.md | 4 +++- rep_cli.py | 31 ++++++++++++++++++++++++++----- 2 files changed, 29 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index bcb5fa5..ce39975 100644 --- a/README.md +++ b/README.md @@ -15,8 +15,10 @@ At the moment, an alpha version is undertaken, with these features: - Create new users - Set an active user -- (planned) Show the pieces stored in the database +- Show the pieces stored in the database - (planned) Mark pieces as masterd for the active user +- (planned) Show pieces by composer +- (planned) Show movements throug pieces ## Requirements diff --git a/rep_cli.py b/rep_cli.py index c586ddc..fc71581 100644 --- a/rep_cli.py +++ b/rep_cli.py @@ -68,12 +68,18 @@ class Session: ''' list_of_work_ids = self.db_agent.execute(sql_command).fetchall() # GET WORKS OUT! - return '' + list_of_works = list() + for item in list_of_work_ids: + list_of_works.append(work_under_id(item[0], self.db_agent)) + fun_resultstring = '' + for work in list_of_works: + fun_resultstring += f'{work.id()}: {work.pretty_string()}\n' + return fun_resultstring # End session -class Werk_unter_id: +class work_under_id: # con = sqlite3.connect('repertoire.db') # reader = con.cursor() @@ -113,7 +119,7 @@ class Werk_unter_id: saetze[satz[1]] = satz[2], satz[3], satz[4] if not satz[2] is None: nummern.add(satz[2]) - self.values['Sätze'] = saetze + self.values['movements'] = saetze if len(nummern) == 1: self.sätze_unter_nummer = True self.values['numb'] = nummern.pop() @@ -127,6 +133,22 @@ class Werk_unter_id: else: return sammlung + def id(self): + return self.values['id'] + + def pretty_string(self): + ret_str = '' + for key in ['first_name', 'name', + 'title', 'opus', + 'main_key', 'alias', + 'work_directory','wd_number']: + if not self.values[key] is None: + if key == 'opus': + ret_str += f'op. {self.values[key]} ' + else: + ret_str += f'{self.values[key]} ' + return ret_str + def __str__(self): ret_str = '' for key, value in self.values.items(): @@ -134,7 +156,7 @@ class Werk_unter_id: ret_str += f'{key}: {value}\n' return ret_str -# End Werk_unter_id +# End work_under_id def parse_user_input(user_in): split_user_in = user_in.split() @@ -164,6 +186,5 @@ def main(): con.close() print('db-connection closed. Bye-bye!') - if __name__ == '__main__': main() \ No newline at end of file