[Mpuls-commits] r2244 - in wasko/branches/2.0: . mpulsweb/lib

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Mon Mar 29 18:00:22 CEST 2010


Author: bh
Date: 2010-03-29 18:00:22 +0200 (Mon, 29 Mar 2010)
New Revision: 2244

Modified:
   wasko/branches/2.0/ChangeLog
   wasko/branches/2.0/mpulsweb/lib/evaluation.py
Log:
* mpulsweb/lib/evaluation.py: Fix formatting.


Modified: wasko/branches/2.0/ChangeLog
===================================================================
--- wasko/branches/2.0/ChangeLog	2010-03-29 15:55:13 UTC (rev 2243)
+++ wasko/branches/2.0/ChangeLog	2010-03-29 16:00:22 UTC (rev 2244)
@@ -1,5 +1,9 @@
 2010-03-29  Bernhard Herzog  <bh at intevation.de>
 
+	* mpulsweb/lib/evaluation.py: Fix formatting.
+
+2010-03-29  Bernhard Herzog  <bh at intevation.de>
+
 	* mpulsweb/lib/helpers.py: Fix formatting.
 
 2010-03-29  Bernhard Herzog  <bh at intevation.de>

Modified: wasko/branches/2.0/mpulsweb/lib/evaluation.py
===================================================================
--- wasko/branches/2.0/mpulsweb/lib/evaluation.py	2010-03-29 15:55:13 UTC (rev 2243)
+++ wasko/branches/2.0/mpulsweb/lib/evaluation.py	2010-03-29 16:00:22 UTC (rev 2244)
@@ -1,84 +1,91 @@
 # -*- coding: utf-8 -*-
 # Copyright 2007, 2008 Intevation GmbH, Germany, <info at intevation.de>
-# 
-# This file is part of mpuls WASKA (CoMPUter-based case fiLeS - 
+#
+# This file is part of mpuls WASKA (CoMPUter-based case fiLeS -
 # Web-Anwendungs-Server fuer Kompetenzagenturen).
-# 
+#
 # mpuls WASKA is free software: you can redistribute it and/or modify it under
 # the terms of the GNU Affero General Public License as published by the
 # Free Software Foundation, either version 3 of the License, or (at your
 # option) any later version.
-# 
+#
 # mpuls WASKA is distributed in the hope that it will be useful, but WITHOUT
 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 # FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Affero General Public
 # License for more details.
-# 
+#
 # You should have received a copy of the GNU Affero General Public
 # License along with mpuls WASKA. If not, see <http://www.gnu.org/licenses/>.
-# 
-# mpuls WASKA has been developed on behalf of the 
+#
+# mpuls WASKA has been developed on behalf of the
 # Projekttraeger im Deutschen Zentrum fuer Luft- und Raumfahrt e.V. (PT-DLR)
 # within the programme Kompetenzagenturen (Durchfuehrungsphase) funded by
-# the Bundesministerium fuer Familie, Senioren, Frauen und Jugend and 
+# the Bundesministerium fuer Familie, Senioren, Frauen und Jugend and
 # European Social Fund resources.
 
 
 from pylons import app_globals as g
 
-from mpulsweb.lib.helpers import timedelta_in_minutes 
+from mpulsweb.lib.helpers import timedelta_in_minutes
 from mpulsweb.lib.db import db
 
+
 class LogbookEvaluation:
+
     """Zeitaufwände aus dem Logbuch aller Fälle"""
+
     def __init__(self, id):
-        self.sql  = """SELECT sum(coalesce(l.dauer, '0 second'::interval)) AS dauer, count(l.id) AS anzahl, l.art, m.id
+        self.sql = """SELECT
+            sum(coalesce(l.dauer, '0 second'::interval)) AS dauer,
+            count(l.id) AS anzahl, l.art, m.id
             FROM ka_logbuch_tbl_view l
             JOIN master_tbl_eval_total_view m
             ON m.id = l.master_id
             WHERE l.master_id = %s
             AND l.art <> '0'
-            GROUP BY l.art, m.id 
+            GROUP BY l.art, m.id
             ORDER BY l.art
         """ % id
 
     def perform(self):
         unique_cases = []
         result = {}
-        for num, category in enumerate(g.mpuls_config.get('logbook', 'categories')):
+        for num, category in enumerate(g.mpuls_config.get('logbook',
+                                                          'categories')):
             for item in category.get('items'):
-                result[item] = [0,0]
-            result['sum_cat%s' % num] = [0,0]
-        result['sum_all']= [0,0]
+                result[item] = [0, 0]
+            result['sum_cat%s' % num] = [0, 0]
+        result['sum_all']= [0, 0]
         try:
             try:
                 conn = db.getConnection()
-                cur  = conn.cursor()
+                cur = conn.cursor()
                 cur.execute(self.sql)
                 count = 0
                 while True:
                     row = cur.fetchone()
-                    if not row: break
+                    if not row:
+                        break
 
                     if row[3] not in unique_cases:
                         count += 1
                         unique_cases.append(row[3])
 
                     duration = int(timedelta_in_minutes(row[0]))
-                    num      = row[1]
-                    type     = str(row[2])
+                    num = row[1]
+                    type = str(row[2])
 
                     result[type][0] += num
                     result[type][1] += duration
-        
+
                     # Search category of the item and sum num and duration
                     for cnum, category in enumerate(
                         g.mpuls_config.get('logbook', 'categories')):
 
                         if type in category.get('items'):
-                            result['sum_cat%s' % cnum][0] += num 
+                            result['sum_cat%s' % cnum][0] += num
                             result['sum_cat%s' % cnum][1] += int(duration)
-                            break;
+                            break
 
                     result['sum_all'][0] += num
                     result['sum_all'][1] += int(duration)



More information about the Mpuls-commits mailing list