[Mpuls-commits] r1222 - in wasko/branches/2.0: . mpulsweb mpulsweb/model waskaweb/lib waskaweb/model

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Thu Feb 4 10:20:17 CET 2010


Author: torsten
Date: 2010-02-04 10:20:16 +0100 (Thu, 04 Feb 2010)
New Revision: 1222

Added:
   wasko/branches/2.0/mpulsweb/model/
   wasko/branches/2.0/mpulsweb/model/annotations.py
Removed:
   wasko/branches/2.0/waskaweb/model/annotations.py
Modified:
   wasko/branches/2.0/ChangeLog
   wasko/branches/2.0/waskaweb/lib/app_globals.py
Log:
Moved model/annotations into base


Modified: wasko/branches/2.0/ChangeLog
===================================================================
--- wasko/branches/2.0/ChangeLog	2010-02-04 08:32:46 UTC (rev 1221)
+++ wasko/branches/2.0/ChangeLog	2010-02-04 09:20:16 UTC (rev 1222)
@@ -1,5 +1,14 @@
 2010-02-04  Torsten Irländer <torsten.irlaender at intevation.de>
 
+	Moved model/annotations into base
+
+	* waskaweb/model/annotations.py,
+	  mpulsweb/model,
+	  mpulsweb/model/annotations.py: Moved to base
+	* waskaweb/lib/app_globals.py: Import Annotationsprovider from base 
+
+2010-02-04  Torsten Irländer <torsten.irlaender at intevation.de>
+
 	* formed: Deleted. Formedtree and other files are now located unter
 	waskaweb/public/formed
 

Copied: wasko/branches/2.0/mpulsweb/model/annotations.py (from rev 1211, wasko/branches/2.0/waskaweb/model/annotations.py)


Property changes on: wasko/branches/2.0/mpulsweb/model/annotations.py
___________________________________________________________________
Name: svn:mergeinfo
   + 

Modified: wasko/branches/2.0/waskaweb/lib/app_globals.py
===================================================================
--- wasko/branches/2.0/waskaweb/lib/app_globals.py	2010-02-04 08:32:46 UTC (rev 1221)
+++ wasko/branches/2.0/waskaweb/lib/app_globals.py	2010-02-04 09:20:16 UTC (rev 1222)
@@ -35,7 +35,7 @@
 from waskaweb.lib.timelog import setupTimeLogging
 from waskaweb.lib.config import MpulsConfig
 
-from waskaweb.model.annotations import AnnotationsProvider
+from mpulsweb.model.annotations import AnnotationsProvider
 
 
 log = logging.getLogger(__name__)

Deleted: wasko/branches/2.0/waskaweb/model/annotations.py
===================================================================
--- wasko/branches/2.0/waskaweb/model/annotations.py	2010-02-04 08:32:46 UTC (rev 1221)
+++ wasko/branches/2.0/waskaweb/model/annotations.py	2010-02-04 09:20:16 UTC (rev 1222)
@@ -1,96 +0,0 @@
-# -*- coding: utf-8 -*-
-#
-# (c) 2008 by Intevation GmbH
-# This is Free software under the GPLv3. 
-# See LICENSE comming with the source of 'mpuls offline'
-# for details.
-#
-# author: Sascha L. Teichmann <sascha.teichmann at intevation.de>
-#
-
-from xml.dom.minidom import parse
-
-import re
-import os
-
-REQUIRED   = ("required", )
-HELP       = ("help", )
-EVALUATION = ("evaluation", )
-
-ANNOTATION_DIV_ID = re.compile("([a-zA-Z0-9_\-]+):([a-zA-Z0-9_\-]+):([a-zA-Z0-9_\-,]+)")
-
-class Annotation:
-
-    def __init__(self, kind, msg):
-        self.kind = kind
-        self.msg  = msg
-
-    def __str__(self):
-        return repr(self.kind) + ": " + repr(self.msg)
-
-    def __repr__(self):
-        return self.__str__()
-
-def build_annotation(annotations_file):
-
-    annotations = {}
-    dom = None
-    try:
-        dom = parse(annotations_file)
-        for div in dom.getElementsByTagName("div"):
-            id = div.getAttribute("id")
-            if not id: continue
-            m = ANNOTATION_DIV_ID.match(id)
-            if not m: continue
-            id, kind = m.group(1), m.group(2)
-            items = [item for item in m.group(3).split(",") if item]
-            if not items: continue
-            div.setAttribute("id", id)
-
-            msg = unicode(div.toxml())
-
-            for item in items:
-                annons = annotations.setdefault(item, [])
-                annons.append(Annotation(kind, msg))
-    finally:
-        if dom: dom.unlink()
-
-    return annotations
-
-
-class AnnotationsProvider:
-
-    def __init__(self, annotations_file):
-        if os.path.isfile(annotations_file):
-            self.annotations = build_annotation(annotations_file)
-        else:
-            self.annotations = {}
-
-    def hasHelp(self, id):
-        return self.hasAnnotations(id, HELP)
-
-    def getHelp(self, id):
-        return self.getAnnotations(id, HELP)
-        
-    def hasEvaluation(self, id):
-        return self.hasAnnotations(id, EVALUATION)
-
-    def getEvaluation(self, id):
-        return self.getAnnotations(id, EVALUATION)
-        
-    def hasAnnotations(self, id, kinds = REQUIRED):
-        annotations = self.annotations.get(id)
-        if not annotations: return False
-        for annotation in annotations:
-            if annotation.kind in kinds:
-                return True
-        return False
-
-    def getAnnotations(self, id, kinds = REQUIRED):
-        try:
-            x = [a.msg for a in self.annotations[id] if a.kind in kinds]
-        except KeyError:
-            x = []
-        return u''.join(x)
-
-# vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :



More information about the Mpuls-commits mailing list