diff --git a/timeTrack.py b/timeTrack.py index 0a51567..f877906 100644 --- a/timeTrack.py +++ b/timeTrack.py @@ -3,7 +3,7 @@ # # timeTrack.py # by 4nima -# v.2.1.0 +# v.2.1.1 # ######################### # simple time tracking with database @@ -417,31 +417,25 @@ class TimeTrack: else: logging.debug('Event younger than 1 day') print('Vergangene Zeit: >{} Stunden'.format(int(elapsed.seconds/3600))) + + printtext = [ + 'Wie soll mit dem Event verfahren werden?', + '[1] fortsetzen', + '[2] löschen', + '[0] abbrechen' + ] + userinput = self.userchoise(printtext, 3) + self.clear_screen() - userinput = 0 - while not 0 < int(userinput) < 4: - print('Soll das Event fortgesetzt oder gelöscht werden?') - print('[1] für fortsetzen') - print('[2] für löschen') - print('[3] für abbrechen') - userinput = input('Aktion: ') - logging.debug('User input: {}'.format(userinput)) - try: - int(userinput) - except ValueError: - userinput = 0 - self.clear_screen() - - if userinput == "1": + if userinput == 1: logging.debug('Event should be continued') self.time_stop() - elif userinput == "2": + elif userinput == 2: logging.info('Event should be deleted (eventid: {})'.format(data[0])) self.delete_event(data[0]) self.time_start() else: - logging.debug('Terminated by the user') - exit() + self.start_interactive_mode() else: logging.debug('Event continues (eventid{})'.format(data[0])) @@ -454,21 +448,16 @@ class TimeTrack: logging.debug('Event stop progess is started') if data: self.clear_screen() - userinput = 0 - while not 0 < int(userinput) < 4: - print('Event von {} Uhr beenden?'.format(data[1].strftime("%H:%M"))) - print('[1] für beenden') - print('[2] für löschen') - print('[3] für abbrechen') - userinput = input('Aktion: ') - logging.debug('User input: {}'.format(userinput)) - try: - int(userinput) - except ValueError: - userinput = 0 - self.clear_screen() + printtext = [ + 'Event von {} Uhr beenden?'.format(data[1].strftime("%H:%M")), + '[1] für beenden', + '[2] für löschen', + '[0] für abbrechen' + ] + userinput = self.userchoise(printtext, 3) + self.clear_screen() - if userinput == "1": + if userinput == 1: logging.debug('Event is ended') print('Eingabe beenden mittels doppelter Leerzeile.') print('Durchgeführte Tätigkeiten:') @@ -510,30 +499,24 @@ class TimeTrack: self.clear_screen() self.print_time_entry(STARTTIME=data[1], ENDTIME=endtime, ACTIVITY=action) print('Zeiteintrag wurde gespeichert.') - userinput = 0 - while not 0 < int(userinput) < 3: - print('Nächsten Zeiteintrag beginnen ?') - print('[1] Ja') - print('[2] Nein') - userinput = input('Aktion: ') - logging.debug('User input: {}'.format(userinput)) - try: - int(userinput) - except ValueError: - userinput = 0 - self.clear_screen() + printtext = [ + 'Nächsten Zeiteintrag beginnen ?', + '[1] Ja', + '[0] Nein' + ] + userinput = self.userchoise(printtext) + self.clear_screen() - if userinput == "1": + if userinput == 1: self.time_start() else: self.start_interactive_mode() - elif userinput == "2": + elif userinput == 2: logging.info('Event should be deleted (eventid: {})'.format(data[0])) self.delete_event(data[0]) else: - logging.debug('Terminated by the user') - exit() + self.start_interactive_mode() ## Interactive mode #==================