[Mpuls-commits] r777 - in wasko/branches/2.0: . waskaweb/lib
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Tue Jan 19 21:20:11 CET 2010
Author: bh
Date: 2010-01-19 21:20:11 +0100 (Tue, 19 Jan 2010)
New Revision: 777
Modified:
wasko/branches/2.0/ChangeLog.txt
wasko/branches/2.0/waskaweb/lib/helpers.py
Log:
* waskaweb/lib/helpers.py: Fix formatting
Modified: wasko/branches/2.0/ChangeLog.txt
===================================================================
--- wasko/branches/2.0/ChangeLog.txt 2010-01-19 20:16:37 UTC (rev 776)
+++ wasko/branches/2.0/ChangeLog.txt 2010-01-19 20:20:11 UTC (rev 777)
@@ -1,5 +1,9 @@
2010-01-19 Bernhard Herzog <bh at intevation.de>
+ * waskaweb/lib/helpers.py: Fix formatting
+
+2010-01-19 Bernhard Herzog <bh at intevation.de>
+
* waskaweb/lib/helpers.py (safe_unicode): Removed. Unused.
2010-01-19 Bernhard Herzog <bh at intevation.de>
Modified: wasko/branches/2.0/waskaweb/lib/helpers.py
===================================================================
--- wasko/branches/2.0/waskaweb/lib/helpers.py 2010-01-19 20:16:37 UTC (rev 776)
+++ wasko/branches/2.0/waskaweb/lib/helpers.py 2010-01-19 20:20:11 UTC (rev 777)
@@ -21,17 +21,20 @@
# within the programme Kompetenzagenturen (Durchfuehrungsphase) funded by
# the Bundesministerium fuer Familie, Senioren, Frauen und Jugend and
# European Social Fund resources.
+
"""Helper functions
Consists of functions to typically be used within templates, but also
available to Controllers. This module is available to both as 'h'.
"""
+
+import sys
import locale
import logging
-import sys
import re
import datetime
from string import printable
+
from pylons import c, cache, config, g, request, response, session
from pylons.i18n import _
@@ -47,6 +50,7 @@
log = logging.getLogger(__name__)
+
def render_navigation(mode="r"):
tree = session['navigation.tree']
#factory = InstanceFactory(g.formed, PostgresDBInterface())
@@ -173,8 +177,8 @@
# TODO: what should happen if d is a unicode object?
if type(d) == str:
try:
- y,m,d = d.split('-')
- d = datetime(y,m,d)
+ y, m, d = d.split('-')
+ d = datetime(y, m, d)
except:
return empty
return "%02d.%02d.%d" % (d.day, d.month, d.year)
@@ -210,19 +214,18 @@
return HH_MM(datetime.datetime.now() + datetime.timedelta(minutes=28))
def timedelta_in_minutes(ti):
- if ti is None: return None
- days = float(ti.days * (24*60))
- secs = ti.seconds / 60.0
- return round(days + secs)
+ if ti is None:
+ return None
+ return round(float(ti.days * (24*60)) + ti.seconds / 60.0)
-def timedelta_in_weeks(ti, empty = None):
- if ti is None: return empty
- days = float(ti.days) / 7.0
- secs = ti.seconds / (60.0 * 24.0 * 7.0)
- return formatNumber(days + secs)
+def timedelta_in_weeks(ti, empty=None):
+ if ti is None:
+ return empty
+ return formatNumber(float(ti.days) / 7.0 + ti.seconds / (60.0 * 24.0 * 7.0))
def human_timedelta(td, empty=None):
- if td is None: return empty
+ if td is None:
+ return empty
out = []
if -td == abs(td):
out.append("-")
@@ -245,12 +248,14 @@
def hasErrorsOnPage(page_id):
- case = session.get('case')
+ case = session.get('case')
navigation = session.get('navigation.tree')
- if not navigation or not case: return False
+ if not navigation or not case:
+ return False
errors = case.getFormErrors()
tree_item = navigation.getTreeItem(page_id)
- if not tree_item: return False
+ if not tree_item:
+ return False
name = tree_item.name
for error in errors.itervalues():
if error.page == name:
More information about the Mpuls-commits
mailing list