Mercurial > getan
changeset 206:9f1c45a2126e
Update coding style for states
author | Björn Ricks <bjoern.ricks@intevation.de> |
---|---|
date | Fri, 05 Apr 2013 19:46:08 +0200 |
parents | a1b00ffea269 |
children | 910136052631 |
files | getan/states.py |
diffstat | 1 files changed, 25 insertions(+), 15 deletions(-) [+] |
line wrap: on
line diff
--- a/getan/states.py Fri Apr 05 19:44:59 2013 +0200 +++ b/getan/states.py Fri Apr 05 19:46:08 2013 +0200 @@ -149,7 +149,8 @@ self.view.set_footer_text("", "entry_footer") def set_footer_text(self): - self.view.set_footer_text("Selecting project from key: %s" % self.proj_keys, "running") + self.view.set_footer_text("Selecting project from key: %s" % \ + self.proj_keys, "running") def check_key(self, key): return len(self.controller.find_projects_by_key(key)) @@ -259,9 +260,8 @@ self.controller.loop.draw_screen() self.sec = self.sec + 1 else: - self.view.set_footer_text( - self.msg('paused') % - (human_time((datetime.now()-self.break_start).seconds), + self.view.set_footer_text(self.msg('paused') % + (human_time((datetime.now() - self.break_start).seconds), self.msg('continue') % keys.get_project_pause()), 'paused_running') self.controller.loop.draw_screen() @@ -278,6 +278,7 @@ if keys.get_enter() in key: return self.stop() + if keys.get_add_time() in key: self.view.set_footer_text(self.msg('add_time'), 'question', 1) @@ -312,7 +313,8 @@ self.view.select() if self.break_start: proj = self.project - if proj: proj.start += datetime.now() - self.break_start + if proj: + proj.start += datetime.now() - self.break_start self.controller.view.set_footer_text(self.msg('description'),'question',1) self.controller.view.get_frame().set_focus('footer') self.set_next_state(DescriptionProjectsState(self.controller, self.view, @@ -321,10 +323,11 @@ class HandleUserInputState(State): + def __init__(self, controller, view, state, footer): super(HandleUserInputState, self).__init__(controller, view) - self.state = state - self.footer = footer + self.state = state + self.footer = footer def handle_input(self, key): logger.debug("HandleUserInputState: handle key '%r'" % key) @@ -377,6 +380,7 @@ class BaseTimeState(HandleUserInputState): + def __init__(self, controller, view, running_state): super(BaseTimeState, self).__init__(controller, view, running_state, view.frame.get_footer()) @@ -396,10 +400,11 @@ class AddTimeState(BaseTimeState): + def enter(self): - minutes = safe_int(self.view.frame.get_footer().get_edit_text()) - project = self.project - project.start -= timedelta(minutes=minutes) + minutes = safe_int(self.view.frame.get_footer().get_edit_text()) + project = self.project + project.start -= timedelta(minutes=minutes) self.state.sec += minutes * 60 logger.info("AddTimeState: add %d minutes to project '%s'" % (minutes, project.desc)) @@ -409,17 +414,18 @@ class SubtractTimeState(BaseTimeState): + def enter(self): - minutes = safe_int(self.view.frame.get_footer().get_edit_text()) + minutes = safe_int(self.view.frame.get_footer().get_edit_text()) sec = minutes * 60 if sec > self.state.sec: self.view._total_time() return self.state - project = self.project - project.start += timedelta(minutes=minutes) + project = self.project + project.start += timedelta(minutes=minutes) self.state.sec -= sec logger.info("SubtractTimeState: subtract %d minutes from project '%s'" - % (minutes, project.desc)) + % (minutes, project.desc)) self.view._total_time() self.set_next_state(self.state) return True @@ -450,6 +456,7 @@ class EntryListState(State): + def __init__(self, state, controller, view): super(EntryListState, self).__init__(controller, view) self.projectlist_state = state @@ -457,6 +464,7 @@ def handle_input(self, key): logger.debug("EntryListState: pressed key '%r'" % key) keys = self.config.get_keybinding() + if keys.get_switch_lists() in key: self.view.clear() self.set_next_state(self.projectlist_state) @@ -473,7 +481,7 @@ def renew_focus(self): e_len = self.view.row_count() - f = self.view.focused + f = self.view.focused if f >= e_len: f = e_len - 1 self.view.focused = f @@ -521,6 +529,7 @@ class DeleteEntryState(EntryListState): + messages = { 'delete' : _("Really delete this entry? (y/n)"), } @@ -672,6 +681,7 @@ class AddProjectDescriptionState(AlterProjectState): + messages = { 'proj_description': _('Insert a description for project: '), 'choose_proj': _(" Choose a project.")