[csw-devel] SF.net SVN: gar:[20537] csw/mgar/gar/v2/lib/python

wahwah at users.sourceforge.net wahwah at users.sourceforge.net
Fri Mar 29 21:44:04 CET 2013


Revision: 20537
          http://gar.svn.sourceforge.net/gar/?rev=20537&view=rev
Author:   wahwah
Date:     2013-03-29 20:44:04 +0000 (Fri, 29 Mar 2013)
Log Message:
-----------
checkpkg: More fixes after refactoring

Some wrinkles around earlier laziness in handling dates.

Modified Paths:
--------------
    csw/mgar/gar/v2/lib/python/models.py
    csw/mgar/gar/v2/lib/python/package_stats.py

Modified: csw/mgar/gar/v2/lib/python/models.py
===================================================================
--- csw/mgar/gar/v2/lib/python/models.py	2013-03-29 17:56:25 UTC (rev 20536)
+++ csw/mgar/gar/v2/lib/python/models.py	2013-03-29 20:44:04 UTC (rev 20537)
@@ -11,6 +11,14 @@
 import cPickle
 import datetime
 
+
+def SanitizeDatetime(d):
+  if isinstance(d, datetime.datetime):
+    return d.isoformat()
+  else:
+    return d
+
+
 class Error(Exception):
   """Generic error."""
 
@@ -259,7 +267,7 @@
     if self.data_obj_mimetype == 'application/json':
       pkgstats = cjson.decode(str(self.data_obj.pickle))
     elif self.data_obj_mimetype == 'application/python-pickle':
-    	pkgstats = cPickle.loads(str(self.data_obj.pickle))
+      pkgstats = cPickle.loads(str(self.data_obj.pickle))
     else:
       raise DataError("Unrecognized mime type: %s" % self.data_obj_mimetype)
     # There was a problem with bad utf-8 in the VENDOR field.
@@ -275,6 +283,9 @@
         d["path"] = self.GetUnicodeOrNone(d["path"])
         d["line"] = self.GetUnicodeOrNone(d["line"])
     # End of the workaround
+    pkgstats['mtime'] = SanitizeDatetime(pkgstats['mtime'])
+    if isinstance(pkgstats['isalist'], frozenset):
+      pkgstats['isalist'] = list(pkgstats['isalist'])
     return pkgstats
 
   def _GetBuildSource(self):
@@ -317,11 +328,6 @@
     #  - self.maintainer_id
     #  - GetVendorUrl unpickles the object (very slow)
     #  - GetSvnUrl unpickles the object (very slow)
-    def SanitizeDatetime(d):
-      if isinstance(d, datetime.datetime):
-       return d.isoformat()
-      else:
-       return d
     data = {
         'basename': self.basename,
         # For compatibility with the catalog parser from catalog.py

Modified: csw/mgar/gar/v2/lib/python/package_stats.py
===================================================================
--- csw/mgar/gar/v2/lib/python/package_stats.py	2013-03-29 17:56:25 UTC (rev 20536)
+++ csw/mgar/gar/v2/lib/python/package_stats.py	2013-03-29 20:44:04 UTC (rev 20537)
@@ -316,7 +316,7 @@
       db_pkg_stats.maintainer = maintainer
       db_pkg_stats.md5_sum = pkg_stats["basic_stats"]["md5_sum"]
       db_pkg_stats.size = pkg_stats["basic_stats"]["size"]
-      db_pkg_stats.mtime = dateutil.parser.parser(pkg_stats["mtime"])
+      db_pkg_stats.mtime = dateutil.parser.parse(pkg_stats["mtime"])
       db_pkg_stats.os_rel = os_rel
       db_pkg_stats.pkginst = pkginst
       db_pkg_stats.registered = register

This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.



More information about the devel mailing list