changeset 410:7e27d2145007

Code-cleanup: improves style. * Fixes warnings by pep8 v1.5.7.
author Bernhard Reiter <bernhard@intevation.de>
date Wed, 03 May 2017 11:50:30 +0200
parents 8ba4576e5381
children 0650c47e7a1c
files getan/resources.py getan/states.py getan/walker.py
diffstat 3 files changed, 23 insertions(+), 25 deletions(-) [+]
line wrap: on
line diff
--- a/getan/resources.py	Fri Mar 17 08:18:31 2017 +0100
+++ b/getan/resources.py	Wed May 03 11:50:30 2017 +0200
@@ -4,9 +4,9 @@
 _base_dir = os.path.join(os.path.dirname(__file__), os.pardir)
 share_dir = os.path.join(_base_dir, "share")
 
+
 def gettext(message):
     modir = os.path.join(share_dir, "locale")
     t = py_gettext.translation("getan", modir, fallback=True)
 
     return t.ugettext(message)
-
--- a/getan/states.py	Fri Mar 17 08:18:31 2017 +0100
+++ b/getan/states.py	Wed May 03 11:50:30 2017 +0200
@@ -21,15 +21,14 @@
 
 
 class State(object):
-
     """ Represents a State of Getan
 
-    A State can be used to handle user input. The user input handling is done in
-    three phases. First it is possible to filter keys that shouldn't be passed
-    to a widget in input_filter. Afterwards it is possible to redirect a key to
-    a specific widget in keypress. In the third phase it is possible to act on
-    user input which isn't handled by a widget yet. The corresponing method is
-    handle_input.
+    A State can be used to handle user input. The user input handling is done
+    in three phases. First it is possible to filter keys that shouldn't be
+    passed to a widget in input_filter. Afterwards it is possible to redirect
+    a key to a specific widget in keypress. In the third phase it is possible
+    to act on user input which isn't handled by a widget yet. The corresponing
+    method is handle_input.
 
     Normally handle_input should be used to act on user input and change a
     state.
@@ -526,9 +525,8 @@
             else:
                 entry = self.view.item_in_focus()
                 self.set_next_state(DeleteEntryState(self.projectlist_state,
-                                                     self,
-                                                     self.controller, self.view,
-                                                     [entry]))
+                                                     self, self.controller,
+                                                     self.view, [entry]))
             return True
 
         if keys.get_entry_move() in key:
@@ -549,16 +547,16 @@
             entry = self.view.item_in_focus()
             if entry:
                 self.set_next_state(AdjustEntryState(self.projectlist_state,
-                                                     self.controller, self.view,
-                                                     entry))
+                                                     self.controller,
+                                                     self.view, entry))
             return True
 
         if keys.get_entry_length() in key:
             entry = self.view.item_in_focus()
             if entry:
                 self.set_next_state(LengthEntryState(self.projectlist_state,
-                                                     self.controller, self.view,
-                                                     entry))
+                                                     self.controller,
+                                                     self.view, entry))
             return True
 
         return False
@@ -618,7 +616,8 @@
 
     def set_project_footer(self):
         self.project_view.set_footer_text("Selecting project from "
-                                          "key: %s" % self.proj_keys, "running")
+                                          "key: %s" % self.proj_keys,
+                                          "running")
 
     def reset_project_footer(self):
         self.project_view.reset_footer()
@@ -756,7 +755,6 @@
 
 
 class EditEntryState(HandleUserInputState):
-
     messages = {
         'edit_entry': _('Edit entry text: '),
     }
@@ -792,8 +790,8 @@
         self.controller.view.set_focus("entries")
         self.view.frame.set_focus("footer")
 
+
 class AdjustEntryState(HandleUserInputState):
-
     messages = {
         'adjust_entry': _('Adjust datetime of entry: '),
     }
@@ -802,7 +800,7 @@
         view.set_footer_text(self.msg('adjust_entry'),
                              'question', True)
         super(AdjustEntryState, self).__init__(controller, view,
-                                             None, view.footer)
+                                               None, view.footer)
 
         # we only care up to seconds (which is 19 characters).
         # for usability the default value has to match the strptime fmt below.
@@ -813,13 +811,14 @@
         logger.debug("AdjustEntryState: Entry %s" % entry)
 
     def enter(self):
-        entry_datetime = self.footer.get_edit_text() #
+        entry_datetime = self.footer.get_edit_text()
 
         entry = self.entry
         duration = entry.get_duration()
 
         try:
-            entry.start = datetime.strptime(entry_datetime, "%Y-%m-%d %H:%M:%S")
+            entry.start = datetime.strptime(entry_datetime,
+                                            "%Y-%m-%d %H:%M:%S")
         except:
             return self
 
@@ -839,8 +838,8 @@
         self.controller.view.set_focus("entries")
         self.view.frame.set_focus("footer")
 
+
 class LengthEntryState(HandleUserInputState):
-
     messages = {
         'adjust_length_entry': _('Adjust length of entry: '),
     }
@@ -849,7 +848,7 @@
         view.set_footer_text(self.msg('adjust_length_entry'),
                              'question', True)
         super(LengthEntryState, self).__init__(controller, view,
-                                             None, view.footer)
+                                               None, view.footer)
 
         # format current duration as string that is also accepted by enter()
         total_minutes = int(entry.get_duration().total_seconds()/60)
@@ -906,7 +905,6 @@
         self.view.frame.set_focus("footer")
 
 
-
 class ProjectEditKeyState(AlterProjectState):
 
     messages = {
--- a/getan/walker.py	Fri Mar 17 08:18:31 2017 +0100
+++ b/getan/walker.py	Wed May 03 11:50:30 2017 +0200
@@ -12,6 +12,7 @@
 
 logger = logging.getLogger(__name__)
 
+
 class ListWalker(urwid.SimpleListWalker):
 
     def __init__(self, content, widget=None):
@@ -27,4 +28,3 @@
         if self.widget and self.position != position:
             self.position = position
             self.widget.content_focus_changed()
-
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)