VMM: The Python 2.4.x compatibility commit. v0.6.x
authorPascal Volk <user@localhost.localdomain.org>
Wed, 27 Jun 2012 12:18:53 +0000
branchv0.6.x
changeset 559 cc0f67f99780
parent 558 2fcf12fdecc2
child 560 2662f4e17eb4
VMM: The Python 2.4.x compatibility commit.
VirtualMailManager/account.py
VirtualMailManager/cli/subcommands.py
VirtualMailManager/handler.py
--- a/VirtualMailManager/account.py	Thu Jun 14 20:45:12 2012 +0000
+++ b/VirtualMailManager/account.py	Wed Jun 27 12:18:53 2012 +0000
@@ -85,11 +85,17 @@
             self._uid, _mid, _qid, _ssid, _tid, _note = result
 
             def load_helper(ctor, own, field, dbresult):
-                cur = None if own is None else getattr(own, field)
+                #  Py25: cur = None if own is None else getattr(own, field)
+                if own is None:
+                    cur = None
+                else:
+                    cur = getattr(own, field)
                 if cur != dbresult:
-                    kwargs = { field : dbresult }
-                    return None if dbresult is None \
-                                else ctor(self._dbh, **kwargs)
+                    kwargs = {field: dbresult}
+                    if dbresult is None:
+                        return dbresult
+                    else:
+                        return ctor(self._dbh, **kwargs)
 
             self._qlimit = load_helper(QuotaLimit, self._qlimit, 'qid', _qid)
             self._services = load_helper(ServiceSet, self._services, 'ssid',
--- a/VirtualMailManager/cli/subcommands.py	Thu Jun 14 20:45:12 2012 +0000
+++ b/VirtualMailManager/cli/subcommands.py	Wed Jun 27 12:18:53 2012 +0000
@@ -673,12 +673,14 @@
               ctx.scmd)
     elif ctx.argc < 4:
         usage(EX_MISSING_ARGS, _(u'Missing storage value.'), ctx.scmd)
-    try:
-        bytes_ = ctx.args[3] if ctx.args[3] == 'default' \
-                             else size_in_bytes(ctx.args[3])
-    except (ValueError, TypeError):
-        usage(INVALID_ARGUMENT, _(u"Invalid storage value: '%s'") %
-              ctx.args[3], ctx.scmd)
+    if ctx.args[3] != 'default':
+        try:
+            bytes_ = size_in_bytes(ctx.args[3])
+        except (ValueError, TypeError):
+            usage(INVALID_ARGUMENT, _(u"Invalid storage value: '%s'") %
+                  ctx.args[3], ctx.scmd)
+    else:
+        bytes_ = ctx.args[3]
     if ctx.argc < 5:
         messages = 0
     else:
--- a/VirtualMailManager/handler.py	Thu Jun 14 20:45:12 2012 +0000
+++ b/VirtualMailManager/handler.py	Wed Jun 27 12:18:53 2012 +0000
@@ -832,8 +832,10 @@
         if not acc:
             raise VMMError(_(u"The account '%s' does not exist.") %
                            acc.address, NO_SUCH_ACCOUNT)
-        transport = None if transport == 'default' \
-                         else Transport(self._dbh, transport=transport)
+        if transport == 'default':
+            transport = None
+        else:
+            transport = Transport(self._dbh, transport=transport)
         acc.update_transport(transport)
 
     def user_services(self, emailaddress, *services):