changeset 135:ce707fbb9666

Change coding style of if clauses
author Björn Ricks <bjoern.ricks@intevation.de>
date Wed, 31 Oct 2012 14:21:44 +0100
parents c80c7fc6a8fc
children 92b7582b8f44
files getan/backend.py getan/controller.py getan/project.py getan/states.py getan/utils.py getan/view.py
diffstat 6 files changed, 45 insertions(+), 23 deletions(-) [+]
line wrap: on
line diff
--- a/getan/backend.py	Wed Oct 31 09:57:20 2012 +0100
+++ b/getan/backend.py	Wed Oct 31 14:21:44 2012 +0100
@@ -130,8 +130,9 @@
             while True:
                 row = cur.fetchone()
 
-                if not row: break
-                proj          = Project(*row)
+                if not row:
+                    break
+                proj = Project(*row)
                 proj.entries = self.load_entries(proj.id)
                 projects.append(proj)
 
@@ -155,7 +156,8 @@
                 try:
                     row = cur.fetchone()
 
-                    if not row: break
+                    if not row:
+                        break
                     entries.append(Entry(*row))
                 except:
                     logger.warn("found invalid entry.")
@@ -168,7 +170,8 @@
 
 
     def insert_project_entry(self, project, stop_time, desc):
-        if project is None: return
+        if project is None:
+            return
         cur = None
         try:
             cur = self.con.cursor()
@@ -195,7 +198,8 @@
             close(cur)
 
     def delete_entries(self, entries):
-        if entries is None: return
+        if entries is None:
+            return
 
         cur = None
         try:
@@ -209,7 +213,8 @@
 
 
     def move_entries(self, entries, new_project_id):
-        if entries is None or new_project_id is None: return
+        if entries is None or new_project_id is None:
+            return
 
         cur = None
         try:
@@ -238,7 +243,8 @@
 def close(cur):
     """ This function closes a database cursor if it is existing """
     if cur:
-        try: cur.close()
+        try:
+            cur.close()
         except:
             logger.warn("could not close database cursor.")
 
--- a/getan/controller.py	Wed Oct 31 09:57:20 2012 +0100
+++ b/getan/controller.py	Wed Oct 31 14:21:44 2012 +0100
@@ -57,8 +57,10 @@
 
     def update_entries(self, project):
         logger.debug("GetanController: update entries.")
-        if project: entries = self.backend.load_entries(project.id)
-        else:       entries = []
+        if project:
+            entries = self.backend.load_entries(project.id)
+        else:
+            entries = []
         self.entries_view.set_rows(entries)
         self.view.update_view()
 
@@ -68,7 +70,8 @@
         try:
             while self.entries_view.selection:
                 node = self.entries_view.selection.pop()
-                if node.selected: node.select()
+                if node.selected:
+                    node.select()
                 entries.append(node.item)
                 logger.info("GetanController: move entry '%s' (id = %d, "\
                             "project id = %d) to project '%s'"
@@ -79,7 +82,8 @@
                     old_project = self.project_by_id(node.item.project_id)
         finally:
             self.backend.move_entries(entries, project.id)
-            if not old_project: return
+            if not old_project:
+                return
             project.entries     = self.backend.load_entries(project.id)
             old_project.entries = self.backend.load_entries(old_project.id)
             self.update_entries(old_project)
@@ -115,7 +119,8 @@
         return None
 
     def start_project(self, project):
-        if not project: return
+        if not project:
+            return
         self.running.append(project)
         project.start = datetime.now()
         logger.info("Start project '%s' at %s."
@@ -124,9 +129,11 @@
         logger.debug('All running projects: %r' % self.running)
 
     def stop_project(self, desc='-no description-', display=True):
-        if not self.running: return
+        if not self.running:
+            return
         project = self.running.pop()
-        if not project: return
+        if not project:
+            return
         logger.info("Stop project '%s' at %s."
                     % (project.desc, format_time(datetime.now())))
         project.stop = datetime.now()
--- a/getan/project.py	Wed Oct 31 09:57:20 2012 +0100
+++ b/getan/project.py	Wed Oct 31 14:21:44 2012 +0100
@@ -54,7 +54,8 @@
         now   = datetime.now()
         for entry in self.entries:
             start = entry.start
-            if start.month == now.month and start.year == now.year and start.day  == now.day:
+            if start.month == now.month and start.year == now.year \
+                    and start.day  == now.day:
                 total += (entry.end - start).seconds
         return total
 
--- a/getan/states.py	Wed Oct 31 09:57:20 2012 +0100
+++ b/getan/states.py	Wed Oct 31 14:21:44 2012 +0100
@@ -175,7 +175,8 @@
 
     def handle_signal(self, signum, frame):
         proj = self.project
-        if not proj: return
+        if not proj:
+            return
         if not self.break_start:
             self.controller.view.set_footer_text(self.msg('running') %
                                                  (human_time(self.sec),
@@ -387,7 +388,8 @@
     def renew_focus(self):
         e_len = self.view.row_count()
         f     = self.view.focused
-        if f >= e_len: f = e_len - 1
+        if f >= e_len:
+            f = e_len - 1
         self.view.focused = f
         self.view.update_focus(f)
 
--- a/getan/utils.py	Wed Oct 31 09:57:20 2012 +0100
+++ b/getan/utils.py	Wed Oct 31 14:21:44 2012 +0100
@@ -20,7 +20,8 @@
 logger = logging.getLogger()
 
 def human_time(seconds):
-    if seconds == None or seconds == 0: return "--:--:--"
+    if seconds == None or seconds == 0:
+        return "--:--:--"
     s = seconds % 60
     seconds /= 60
     m = seconds % 60
--- a/getan/view.py	Wed Oct 31 09:57:20 2012 +0100
+++ b/getan/view.py	Wed Oct 31 14:21:44 2012 +0100
@@ -67,7 +67,8 @@
         self._update_view()
 
     def row_count(self):
-        if not self.rows: return 0
+        if not self.rows:
+            return 0
         return len(self.rows)
 
     def item_in_focus(self):
@@ -101,7 +102,8 @@
         self._update_view()
 
     def select(self):
-        if not self.rows: return None
+        if not self.rows:
+            return None
         node = self.rows[self.focused]
         logger.debug("ListWidget: select row '%s'" % self.focused)
         node.select()
@@ -116,7 +118,8 @@
     def clear(self):
         logger.debug("EntryList: clear focus and selection of all entries.")
         for node in self.selection:
-            if node.selected: node.select()
+            if node.selected:
+                node.select()
         self.update_focus(-1, self.focused)
         self.focused = False
 
@@ -171,8 +174,10 @@
 
     def switch_time_mode(self):
         tmp = self.mode[0] + 1
-        if tmp > 4: self.mode = self.MODES[0]
-        else:       self.mode = self.MODES[tmp]
+        if tmp > 4:
+            self.mode = self.MODES[0]
+        else:
+            self.mode = self.MODES[tmp]
         self.update()
 
     def update_w(self):
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)