[Mpuls-commits] r934 - in wasko/branches/2.0: . waskaweb/model
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Tue Jan 26 20:43:50 CET 2010
Author: bh
Date: 2010-01-26 20:43:48 +0100 (Tue, 26 Jan 2010)
New Revision: 934
Modified:
wasko/branches/2.0/ChangeLog
wasko/branches/2.0/waskaweb/model/phases_factory.py
Log:
* waskaweb/model/phases_factory.py: Fix formatting
Modified: wasko/branches/2.0/ChangeLog
===================================================================
--- wasko/branches/2.0/ChangeLog 2010-01-26 19:35:00 UTC (rev 933)
+++ wasko/branches/2.0/ChangeLog 2010-01-26 19:43:48 UTC (rev 934)
@@ -1,5 +1,9 @@
2010-01-26 Bernhard Herzog <bh at intevation.de>
+ * waskaweb/model/phases_factory.py: Fix formatting
+
+2010-01-26 Bernhard Herzog <bh at intevation.de>
+
* waskaweb/model/agencysettings.py: Remove unused imports
2010-01-26 Bernhard Herzog <bh at intevation.de>
Modified: wasko/branches/2.0/waskaweb/model/phases_factory.py
===================================================================
--- wasko/branches/2.0/waskaweb/model/phases_factory.py 2010-01-26 19:35:00 UTC (rev 933)
+++ wasko/branches/2.0/waskaweb/model/phases_factory.py 2010-01-26 19:43:48 UTC (rev 934)
@@ -1,63 +1,65 @@
# -*- coding: utf-8 -*-
#
# Copyright 2007, 2008, 2010 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.
# Authors:
#
# Sascha L. Teichmann <sascha.teichmann at intevation.de>
#
-from waskaweb.model.phases import *
+import sys
+import re
+import traceback
+from xml.sax.saxutils import quoteattr
+from cgi import escape
+
+from waskaweb.model.phases import *
from waskaweb.model.phase_transition import *
-#from waskaweb.model.data import PageNode
+#from waskaweb.model.data import PageNode
-#from waskaweb.model.casedocument import WARNING
+#from waskaweb.model.casedocument import WARNING
-from xml.sax.saxutils import quoteattr
-import re
-import sys
-import traceback
-
-from cgi import escape
-
PAIRS = (
(CLEAR_START, CLEAR_ENDE, u"Eingangs-<wbr />Dokumentation"),
(CM_START, CM_ENDE, u"Case Management"),
(NB_START, NB_ENDE, u"Nach­betreuung"))
+
def description(nc):
p = nc
while p:
desc = p.getDescription()
if desc:
desc = desc.strip()
- if desc: return desc
+ if desc:
+ return desc
p = p.parent
return nc.getName()
+
def page(nc):
p = nc
while p:
@@ -66,6 +68,7 @@
p = p.parent
return p
+
def nescape(s):
return escape(s).replace(' ', ' ')
@@ -89,11 +92,11 @@
class RequiredFields:
def __init__(self, formed):
- self.formed = formed
- self.phase_times = {}
- self.missing_cache = {}
+ self.formed = formed
+ self.phase_times = {}
+ self.missing_cache = {}
self.rule_eval_cache = {}
- self.var_eval_cache = {}
+ self.var_eval_cache = {}
def getPhaseTime(self, phase):
@@ -102,16 +105,19 @@
except KeyError:
try:
time_vars = self.formed.getTimeVars(phase)
- if not time_vars: return None
+ if not time_vars:
+ return None
pt = [self.formed.getData(x.getName()) for x in time_vars]
- if pt: pt = pt[0]
- else: pt = None
+ if pt:
+ pt = pt[0]
+ else:
+ pt = None
self.phase_times[phase] = pt
except KeyError:
return None
return pt
- def isPhaseComplete(self, phase, master_id = None):
+ def isPhaseComplete(self, phase, master_id=None):
return not bool(self.missingFields(phase, master_id))
# def missingFields(self, phase, master_id):
@@ -125,15 +131,12 @@
# except: pass
def missingFields(self, phase, master_id = None):
-
- #print >> outfile, "\nEvaluating phase '%s' -------------------------------" % phase
-
vars = self.formed.getPhaseVars(phase)
- if not vars: return []
+ if not vars:
+ return []
try:
missing = self.missing_cache[phase]
- #print >> outfile, "using phase cache: %s " % ', '.join([x.getName() for x in missing])
return missing
except KeyError:
pass
@@ -144,61 +147,61 @@
self.missing_cache[phase] = missing
for var in vars:
var_name = var.getName()
- #print >> outfile, "checking var '%s'" % var_name
-
try:
result = self.var_eval_cache[var_name]
- if not result: missing.append(var)
- #print >> outfile, "var cache -> %s" % result
+ if not result:
+ missing.append(var)
continue
except KeyError:
pass
rules = self.formed.getRulesForVariable(var_name)
- if not rules: continue
+ if not rules:
+ continue
result = True
for rule in rules:
# only eval warning rules
mark = WARNING.search(rule.getMark())
- if not mark: continue
+ if not mark:
+ continue
rule_name = rule.getName()
try:
result = self.rule_eval_cache[rule_name]
- #print >> outfile, "eval cache rule '%s' -> %s" % (rule_name, result)
except KeyError:
- expr = rule.getExpr()
- deps = expr.getDependencies()
+ expr = rule.getExpr()
+ deps = expr.getDependencies()
params = dict((v, getData(v, master_id)) for v in deps)
try:
result = expr.evaluate(params)
except:
result = True
- #print >> outfile, "evaluate '%s' -> %s" % (rule.getAttribute('expr'), result)
- #print >> outfile, " params: %s" % repr(params)
+
self.rule_eval_cache[rule_name] = result
- if not result: break
+ if not result:
+ break
self.var_eval_cache[var_name] = result
- if not result: missing.append(var)
+ if not result:
+ missing.append(var)
- #print >> outfile, "missing: %s " % ', '.join([x.getName() for x in missing])
return missing
def getLinkListForPhase(self, phase, navigation=None, link=None,
- master_id = None):
+ master_id=None):
+ if not navigation and not link:
+ return u""
- if not navigation and not link: return u""
-
all_vars = self.formed.getPhaseVars(phase)
- if not all_vars: return u""
+ if not all_vars:
+ return u""
- missing_set = set([x.getName() for x in
- self.missingFields(phase, master_id = master_id)])
+ missing_set = set([x.getName() for x in
+ self.missingFields(phase, master_id=master_id)])
- pages, used_pages = [], {}
-
+ pages = []
+ used_pages = {}
on_invisible_page = []
for var in all_vars:
@@ -211,7 +214,8 @@
t = used_pages[p_name]
except KeyError:
tree_item = navigation.findTreeItemByPageName(p_name)
- if not tree_item: continue
+ if not tree_item:
+ continue
tree_item = tree_item.deepest_item()
t = [tree_item, []]
pages.append(t)
@@ -220,23 +224,28 @@
if var.getName() in missing_set:
t[1].append(var)
- if not pages and not on_invisible_page: return u""
+ if not pages and not on_invisible_page:
+ return u""
out = [u"<ul>"]
for var in on_invisible_page:
out.append(u"<li>")
missing = var.getName() in missing_set
- if missing: out.append(u'<span class="required_missing">')
+ if missing:
+ out.append(u'<span class="required_missing">')
out.append(escape(var.getDescription()))
- if missing: out.append(u"</span>")
+ if missing:
+ out.append(u"</span>")
out.append(u"</li>")
for tree_item, warn in pages:
out.append(u"<li>")
if not warn:
- out.append(u'<a href=%s title="Seite für Phase vollständig ausgefüllt"><strong>%s</strong></a>' % (
- link(tree_item), nescape(tree_item.description)))
+ out.append(u'<a href=%s'
+ u' title="Seite für Phase vollständig ausgefüllt">'
+ u'<strong>%s</strong></a>'
+ % (link(tree_item), nescape(tree_item.description)))
else:
if len(warn) < 6:
out2 = []
@@ -244,77 +253,67 @@
desc = description(v)
if len(desc) > 15:
title = quoteattr(u"Fehlende Angabe: %s" % desc)
- desc = escape(space_short(desc, 15))
+ desc = escape(space_short(desc, 15))
else:
title = u'"Fehlende Angabe für diese Phase"'
- desc = escape(desc)
+ desc = escape(desc)
- out2.append(
- u'<a href=%s class="required_missing" '
- u'title=%s>%s' % (
- link(tree_item, u"#f_" + v.getName()),
- title, desc))
+ out2.append(u'<a href=%s class="required_missing"'
+ u' title=%s>%s'
+ % (link(tree_item, u"#f_" + v.getName()),
+ title, desc))
links = u",</a> ".join(out2) + u"</a>"
- out.append(u'<strong>%s</strong>: %s' % (nescape(tree_item.description), links))
+ out.append(u'<strong>%s</strong>: %s'
+ % (nescape(tree_item.description), links))
else:
- out.append(
- u'<a href=%s '
- u'title="Auf dieser Seite sind noch %d Felder auszufüllen." '
- u'><strong>%s <span class="required_missing">(%d)</span></strong></a>' % (
- link(tree_item), len(warn),
- nescape(tree_item.description), len(warn)))
+ out.append(u'<a href=%s'
+ u' title="Auf dieser Seite sind noch %d Felder'
+ ' auszufüllen.">'
+ u'<strong>%s'
+ ' <span class="required_missing">(%d)</span>'
+ '</strong></a>'
+ % (link(tree_item), len(warn),
+ nescape(tree_item.description), len(warn)))
out.append(u"</li>")
out.append(u"</ul>")
return u"".join(out)
- def phases_pairs(
- self, current_phase, navigation=None, link=None, master_id = None):
-
+ def phases_pairs(self, current_phase, navigation=None, link=None,
+ master_id=None):
pairs = []
-
all = {}
-
symbol = phase_symbol(current_phase)
- cur_phase = Phase(
- current_phase,
- True,
- self.isPhaseComplete(symbol, master_id),
- self.getPhaseTime(symbol),
- self.getLinkListForPhase(symbol, navigation, link, master_id))
+ cur_phase = Phase(current_phase, True,
+ self.isPhaseComplete(symbol, master_id),
+ self.getPhaseTime(symbol),
+ self.getLinkListForPhase(symbol, navigation, link,
+ master_id))
for p1, p2, description in PAIRS:
-
symbol = phase_symbol(p1)
-
- start = Phase(
- p1,
- p1 == current_phase,
- self.isPhaseComplete(symbol, master_id),
- self.getPhaseTime(symbol),
- self.getLinkListForPhase(symbol, navigation, link, master_id))
-
+ start = Phase(p1, p1 == current_phase,
+ self.isPhaseComplete(symbol, master_id),
+ self.getPhaseTime(symbol),
+ self.getLinkListForPhase(symbol, navigation, link,
+ master_id))
all[p1] = start
symbol = phase_symbol(p2)
+ ende = Phase(p2, p2 == current_phase,
+ self.isPhaseComplete(symbol, master_id),
+ self.getPhaseTime(symbol),
+ self.getLinkListForPhase(symbol, navigation, link,
+ master_id))
- ende = Phase(
- p2,
- p2 == current_phase,
- self.isPhaseComplete(symbol, master_id),
- self.getPhaseTime(symbol),
- self.getLinkListForPhase(symbol, navigation, link, master_id))
-
all[p2] = ende
-
# Only add phases which are on the path of the current phase
#pairs.append(PhasePair(start, ende, description))
- if cur_phase.hasSuccessor(start) \
- or cur_phase.hasPredecessor(start) \
- or current_phase == p1:
+ if (cur_phase.hasSuccessor(start) or cur_phase.hasPredecessor(start)
+ or current_phase == p1):
pairs.append(PhasePair(start, ende, description))
for p in all.itervalues():
@@ -326,16 +325,13 @@
return pairs
- def currentPhase(required_fields, current_phase, master_id = None):
-
+ def currentPhase(required_fields, current_phase, master_id=None):
symbol = phase_symbol(current_phase)
- cur_phase = Phase(
- current_phase,
- True,
- required_fields.isPhaseComplete(symbol, master_id),
- required_fields.getPhaseTime(symbol),
- required_fields.getLinkListForPhase(symbol, None, None,
- master_id))
+ cur_phase = Phase(current_phase, True,
+ required_fields.isPhaseComplete(symbol, master_id),
+ required_fields.getPhaseTime(symbol),
+ required_fields.getLinkListForPhase(symbol, None,
+ None, master_id))
return cur_phase
# vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8:
More information about the Mpuls-commits
mailing list