[Getan-commits] [PATCH 10 of 16] Add methods to return a workpackage [wp] from a Entry description

Wald Commits scm-commit at wald.intevation.org
Mon Mar 3 15:00:41 CET 2014


# HG changeset patch
# User Björn Ricks <bjoern.ricks at intevation.de>
# Date 1393853319 -3600
# Node ID bc12acbff1436e036d3b4ceaebe49361de17d60a
# Parent  4f5094f3f615dda215631cf99700362c5422d2d4
Add methods to return a workpackage [wp] from a Entry description

diff -r 4f5094f3f615 -r bc12acbff143 getan/project.py
--- a/getan/project.py	Mon Mar 03 14:27:36 2014 +0100
+++ b/getan/project.py	Mon Mar 03 14:28:39 2014 +0100
@@ -9,6 +9,7 @@
 # For details see LICENSE coming with the source of 'getan'.
 
 import locale
+import re
 
 from datetime import datetime, timedelta
 
@@ -81,6 +82,8 @@
 
 class Entry(object):
 
+    WORKPACKAGE = re.compile("^\[(\w*)(\s|\])")
+
     def __init__(self, id, project_id, start, end, desc):
         self.id = id
         self.project_id = project_id
@@ -93,9 +96,25 @@
         if self.desc and not isinstance(self.desc, unicode):
             self.desc = unicode(self.desc, locale.getpreferredencoding())
 
-    def duration(self):
+        c = self.desc
+        m = self.WORKPACKAGE.match(c)
+        if m:
+            self.workpackage = m.group(1)
+            c = c[m.end():].strip()
+        else:
+            self.workpackage = "----"
+        c = c.replace('\x1b', '')
+        self.comment = c
+
+    def get_workpackage(self):
+        return self.workpackage
+
+    def get_duration(self):
         return (self.end - self.start)
 
+    def get_comment(self):
+        return self.comment
+
     def __str__(self):
         return ("[%s | %s | %s | %s | %s]" %
                (self.id, self.project_id, self.start, self.end, self.desc))


More information about the Getan-commits mailing list