[gyrus/gyrus-python] Fixed bug #600420



commit 5eb98832dc79152d99b78aa31029f72059d207cf
Author: Alejandro Valdes Jimenez <avaldes gnome org>
Date:   Thu Nov 12 16:13:07 2009 -0300

    Fixed bug #600420

 ChangeLog                     |   12 ++++++++++++
 src/GyrusAclTreeView.py       |   36 +++++++++++++++++++-----------------
 src/GyrusMailboxesTreeView.py |   15 ++++++++-------
 3 files changed, 39 insertions(+), 24 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 1f015e6..cddedd2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2009-11-01  Francisco Rojas  <frojas alumnos utalca cl>
+
+    * src/GyrusAclTreeView.py: (update_of_mailbox)
+    use of Regular Expression for data extraction instead of split
+    Fixes bug #600420
+
+2009-10-18  Francisco Rojas  <frojas alumnos utalca cl>
+
+    * src/GyrusMailboxesTreeView.py: (get_quota_of_mailbox)
+    use of Regular Expression for data extraction instead of split
+    Fixes bug #600420
+
 2009-10-16  Francisco Rojas  <frojas alumnos utalca cl>
 
 	* src/GyrusAdmin.py: delete undeclared var used in the method 
diff --git a/src/GyrusAclTreeView.py b/src/GyrusAclTreeView.py
index aa7b48c..1b02f12 100644
--- a/src/GyrusAclTreeView.py
+++ b/src/GyrusAclTreeView.py
@@ -26,6 +26,8 @@ pygtk.require('2.0')
 import gtk
 import gobject
 import gettext
+import re
+
 import GyrusAclStore
 
 from gyrus_constant import *
@@ -80,15 +82,15 @@ class GyrusAclTreeView(gtk.TreeView):
 
         self.connection = connection
         self.set_enable_search(False)
-            
+
         cell = gtk.CellRendererText()
         cell.set_property('editable',True)
         cell.connect('edited', self._on_identifier_edited)
-        
+
         column = gtk.TreeViewColumn(_("identifier"),cell,text=0)
         column.set_resizable(True)
         self.append_column(column)     
-        
+
         for ncol in range(1,10):
             cell = gtk.CellRendererToggle()
             cell.set_property('activatable',True)
@@ -177,27 +179,28 @@ class GyrusAclTreeView(gtk.TreeView):
         
     #update
     def update_of_mailbox(self):
-        
+
         if (self.mailbox==None):
             self.model().clear()
             return
-        
+
         # get ACLs
-        t = self.connection.getacl(NAMESPACE + self.mailbox)
-        tm = t[1]
-        tmp = tm[0].split(" ")
+        response = self.connection.getacl(NAMESPACE + self.mailbox)
 
-        lin = 1
-        j = lin
-        l = len(tmp)/2
+        #This is wrong, because 'response' could throws a WARNING and we
+        #omit it
 
         model_acl = self.get_model()
         model_acl.clear()
-            
-        while lin <= l:
-            id_acl = tmp[j]
-            acls = tmp[j+1]
 
+        pattern = re.compile(r'(\b[\w\.\\]+\b|\".*?\")')
+        data = pattern.findall(response[1][0])
+
+        j = 1
+
+        while j < len(data):
+            id_acl = data[j].strip('\"')
+            acls = data[j+1]
             model_acl.add_acl(id_acl, 
                         self._have_acl(acls,"l"),
                         self._have_acl(acls,"r"),
@@ -208,9 +211,8 @@ class GyrusAclTreeView(gtk.TreeView):
                         self._have_acl(acls,"c"),
                         self._have_acl(acls,"d"),
                         self._have_acl(acls,"a"),)
-
             j = j + 2
-            lin = lin + 1
+
 
     #check if the string contains a specific permisson
     def _have_acl(self,string,acl):
diff --git a/src/GyrusMailboxesTreeView.py b/src/GyrusMailboxesTreeView.py
index 86b54ae..4d12482 100644
--- a/src/GyrusMailboxesTreeView.py
+++ b/src/GyrusMailboxesTreeView.py
@@ -30,6 +30,7 @@ import gtk
 import gobject
 import gettext
 import sys
+import re
 
 import config
 from gyrus_constant import *
@@ -148,7 +149,7 @@ class GyrusMailboxesTreeView (gtk.TreeView):
 
         num_users = 0
         
-        #THIS IST WRONG, because if the query lunch a WARNING we omit it
+        #THIS IST WRONG, because if the query throws a WARNING we omit it
         if not data[0] == None: 
             
             token = None
@@ -189,14 +190,14 @@ class GyrusMailboxesTreeView (gtk.TreeView):
         response = self.connection.getquota(NAMESPACE + mailbox)
         
         if response[0] == 'OK':
-            data_quota_mailbox = response[1]
-            tmp = data_quota_mailbox[0].split(" ")
-                        
-            used = tmp[2]
+            data_quota_mailbox = response[1][0]
             
-            quota = tmp[3].split(")")[0]
+            pattern = re.compile(r'.*STORAGE (?P<used>[0-9]*) (?P<quota>[0-9]*).*')
+            match = pattern.match(data_quota_mailbox)
             
-            free = (int(quota) - int(used)) / 1024
+            used = match.group('used')
+            quota = match.group('quota')
+            free =  (int(quota) - int(used)) / 1024
             quota = int(quota) / 1024
             
             return True,None,free,quota



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]