Compare commits
3 Commits
f446120184
...
8c311ea739
| Author | SHA1 | Date | |
|---|---|---|---|
| 8c311ea739 | |||
| a75a241f30 | |||
| 10894187b2 |
18
README.md
18
README.md
@@ -11,14 +11,22 @@ At the moment, an alpha version is undertaken, with these features:
|
|||||||
- The sqlite-database holds a growing number of piano-solo pieces, together with their exact catalogue-numbers and composers.
|
- The sqlite-database holds a growing number of piano-solo pieces, together with their exact catalogue-numbers and composers.
|
||||||
- Prepared in this database is a table for users (pianists), that marks which of the pieces can be played.
|
- Prepared in this database is a table for users (pianists), that marks which of the pieces can be played.
|
||||||
|
|
||||||
### Application
|
### Application and usage
|
||||||
|
|
||||||
- Create new users
|
- Create new users (`n username`)
|
||||||
- Set an active user
|
- Show users (`su`)
|
||||||
- (planned) Show the pieces stored in the database
|
- Set an active user (`a number_of_user`)
|
||||||
- (planned) Mark pieces as masterd for the active user
|
- Show the pieces stored in the database (`s`)
|
||||||
|
- Mark pieces as mastered for the active user (`m number_of_work`)
|
||||||
|
- (planned) Show pieces by composer
|
||||||
|
- (planned) Show movements through pieces
|
||||||
|
|
||||||
## Requirements
|
## Requirements
|
||||||
|
|
||||||
- Python 3.9 or higher
|
- Python 3.9 or higher
|
||||||
- Enough disk space to hold the database
|
- Enough disk space to hold the database
|
||||||
|
- run `python builddb.py` to build the SQLite-database-file before running `python rep_cli.py`
|
||||||
|
|
||||||
|
## Known Bugs
|
||||||
|
|
||||||
|
- Marking a piece as mastered the second time, the database won’t insert the entry and the program will crash
|
||||||
75
rep_cli.py
75
rep_cli.py
@@ -29,6 +29,8 @@ class Session:
|
|||||||
self.resultstring = ''
|
self.resultstring = ''
|
||||||
if command == 'a':
|
if command == 'a':
|
||||||
self.resultstring += self.set_user(arguments[0])
|
self.resultstring += self.set_user(arguments[0])
|
||||||
|
elif command == 'm':
|
||||||
|
self.resultstring += self.mark_work_as_mastered(arguments[0])
|
||||||
elif command == 'n':
|
elif command == 'n':
|
||||||
self.create_new_user(arguments[0], arguments[1])
|
self.create_new_user(arguments[0], arguments[1])
|
||||||
self.resultstring += f'Created new user {arguments[0]} {arguments[1]}.'
|
self.resultstring += f'Created new user {arguments[0]} {arguments[1]}.'
|
||||||
@@ -68,12 +70,29 @@ class Session:
|
|||||||
'''
|
'''
|
||||||
list_of_work_ids = self.db_agent.execute(sql_command).fetchall()
|
list_of_work_ids = self.db_agent.execute(sql_command).fetchall()
|
||||||
# GET WORKS OUT!
|
# 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
|
||||||
|
|
||||||
|
def mark_work_as_mastered(self, work_id):
|
||||||
|
resultstring = 'adding:\n'
|
||||||
|
work = work_under_id(work_id, self.db_agent)
|
||||||
|
for mov_number in work.values['movements'].keys():
|
||||||
|
sql_command = f'''
|
||||||
|
INSERT INTO is_able_to_play (work_id, mov_id, pianist_id)
|
||||||
|
VALUES ({work_id}, {mov_number}, {self.user})
|
||||||
|
'''
|
||||||
|
self.db_agent.execute(sql_command)
|
||||||
|
resultstring += f'{work.pretty_mov(mov_number)}\n'
|
||||||
|
return resultstring
|
||||||
|
|
||||||
# End session
|
# End session
|
||||||
|
|
||||||
class Werk_unter_id:
|
class work_under_id:
|
||||||
# con = sqlite3.connect('repertoire.db')
|
# con = sqlite3.connect('repertoire.db')
|
||||||
# reader = con.cursor()
|
# reader = con.cursor()
|
||||||
|
|
||||||
@@ -113,7 +132,7 @@ class Werk_unter_id:
|
|||||||
saetze[satz[1]] = satz[2], satz[3], satz[4]
|
saetze[satz[1]] = satz[2], satz[3], satz[4]
|
||||||
if not satz[2] is None:
|
if not satz[2] is None:
|
||||||
nummern.add(satz[2])
|
nummern.add(satz[2])
|
||||||
self.values['Sätze'] = saetze
|
self.values['movements'] = saetze
|
||||||
if len(nummern) == 1:
|
if len(nummern) == 1:
|
||||||
self.sätze_unter_nummer = True
|
self.sätze_unter_nummer = True
|
||||||
self.values['numb'] = nummern.pop()
|
self.values['numb'] = nummern.pop()
|
||||||
@@ -127,6 +146,51 @@ class Werk_unter_id:
|
|||||||
else:
|
else:
|
||||||
return sammlung
|
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 pretty_mov(self, mov_number):
|
||||||
|
ret_str = ''
|
||||||
|
for key in ['first_name', 'name',
|
||||||
|
'title', 'mov_title', 'opus', 'numb',
|
||||||
|
'main_key', 'alias',
|
||||||
|
'movements',
|
||||||
|
'work_directory','wd_number']:
|
||||||
|
if key in self.values.keys() and not self.values[key] is None:
|
||||||
|
if key == 'opus':
|
||||||
|
ret_str += f'op. {self.values[key]} '
|
||||||
|
elif key == 'name':
|
||||||
|
ret_str += f'{self.values[key]}, '
|
||||||
|
elif key == 'numb':
|
||||||
|
ret_str += f'Nr. {self.values[key]} '
|
||||||
|
elif key == 'movements':
|
||||||
|
if self.values[key][mov_number][1] is None:
|
||||||
|
ret_str += ''
|
||||||
|
else:
|
||||||
|
if len(self.values[key]) > 1:
|
||||||
|
ret_str += f'{mov_number}. {self.values[key][mov_number][1]} '
|
||||||
|
else:
|
||||||
|
ret_str += f'{self.values[key][mov_number][1]} '
|
||||||
|
elif key == 'title':
|
||||||
|
if self.values['mov_title'] is None:
|
||||||
|
ret_str += f'{self.values[key]} '
|
||||||
|
else:
|
||||||
|
ret_str += f'{self.values[key]} '
|
||||||
|
return ret_str
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
ret_str = ''
|
ret_str = ''
|
||||||
for key, value in self.values.items():
|
for key, value in self.values.items():
|
||||||
@@ -134,12 +198,12 @@ class Werk_unter_id:
|
|||||||
ret_str += f'{key}: {value}\n'
|
ret_str += f'{key}: {value}\n'
|
||||||
return ret_str
|
return ret_str
|
||||||
|
|
||||||
# End Werk_unter_id
|
# End work_under_id
|
||||||
|
|
||||||
def parse_user_input(user_in):
|
def parse_user_input(user_in):
|
||||||
split_user_in = user_in.split()
|
split_user_in = user_in.split()
|
||||||
command = split_user_in[0]
|
command = split_user_in[0]
|
||||||
if command in ('a', 'n', 'q', 's', 'su'):
|
if command in ('a', 'm', 'n', 'q', 's', 'su'):
|
||||||
arguments = split_user_in[1:]
|
arguments = split_user_in[1:]
|
||||||
return (command, arguments)
|
return (command, arguments)
|
||||||
else:
|
else:
|
||||||
@@ -164,6 +228,5 @@ def main():
|
|||||||
con.close()
|
con.close()
|
||||||
print('db-connection closed. Bye-bye!')
|
print('db-connection closed. Bye-bye!')
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main()
|
main()
|
||||||
Reference in New Issue
Block a user