SF.net SVN: gar:[23443] csw/mgar/gar/v2/lib/web/pkgdb_web.py

wahwah at users.sourceforge.net wahwah at users.sourceforge.net
Sun Apr 20 21:11:54 CEST 2014


Revision: 23443
          http://sourceforge.net/p/gar/code/23443
Author:   wahwah
Date:     2014-04-20 19:11:54 +0000 (Sun, 20 Apr 2014)
Log Message:
-----------
pkgdb-web: Catalog information as dicts by default

Clients will have to deal with it.

Modified Paths:
--------------
    csw/mgar/gar/v2/lib/web/pkgdb_web.py

Modified: csw/mgar/gar/v2/lib/web/pkgdb_web.py
===================================================================
--- csw/mgar/gar/v2/lib/web/pkgdb_web.py	2014-04-20 19:11:44 UTC (rev 23442)
+++ csw/mgar/gar/v2/lib/web/pkgdb_web.py	2014-04-20 19:11:54 UTC (rev 23443)
@@ -61,7 +61,7 @@
   r'/rest/catalogs/([^/]+)/(sparc|i386)/(SunOS[^/]+)/for-generation/as-dicts/',
       'CatalogForGenerationAsDicts',
   r'/rest/catalogs/([^/]+)/(sparc|i386)/(SunOS[^/]+)/for-generation/',
-      'CatalogForGeneration',
+      'CatalogForGenerationAsDicts',
   r'/rest/catalogs/([^/]+)/(sparc|i386)/(SunOS[^/]+)/timing/',
       'CatalogTiming',
   # Query by catalog release, arch, OS release and catalogname
@@ -83,6 +83,20 @@
 render = web.template.render(templatedir)
 
 
+def SanitizeDescription(catalogname, desc):
+  prefix = '%s - ' % catalogname
+  if desc.startswith(prefix):
+    return desc[len(prefix):]
+  return desc
+
+
+def FormatPkginstList(lst):
+  if lst:
+    return '|'.join(lst)
+  else:
+    return 'none'
+
+
 class index(object):
 
   def GET(self):
@@ -662,12 +676,6 @@
     return response
 
 
-def FormatPkginstList(lst):
-  if lst:
-    return '|'.join(lst)
-  else:
-    return 'none'
-
 def GetCatalogEntries(catrel_name, arch_name, osrel_name):
   """Returns a list of CatalogEntry tuples."""
   try:
@@ -677,6 +685,8 @@
     raise web.notfound()
   rows = list(models.GetCatalogGenerationResult(sqo_osrel, sqo_arch, sqo_catrel))
   def MakeCatalogEntry(row):
+    catalogname = row[0]
+    desc = SanitizeDescription(catalogname, row[8])
     i_deps = cjson.decode(row[7])
     i_deps_str = FormatPkginstList(i_deps)
     deps_with_desc = cjson.decode(row[6])
@@ -692,7 +702,7 @@
         deps=deps_str,       # 6
         category="none",     # 7
         i_deps=i_deps_str,   # 8
-        desc=row[8],         # 9
+        desc=desc,           # 9
     )
     return entry
   entries_list = [MakeCatalogEntry(row) for row in rows]
@@ -716,20 +726,6 @@
     return response
 
 
-class CatalogForGeneration(object):
-
-  def GET(self, catrel_name, arch_name, osrel_name):
-    """A list of tuples, aligning with the catalog format.
-
-    catalogname version_string pkgname
-    basename md5_sum size deps category i_deps
-    """
-    entries_list = GetCatalogEntries(catrel_name, arch_name, osrel_name)
-    response = cjson.encode([tuple(x) for x in entries_list])
-    web.header('Content-Length', str(len(response)))
-    return response
-
-
 class CatalogTiming(object):
 
   def GET(self, catrel_name, arch_name, osrel_name):
@@ -746,11 +742,13 @@
     rows = list(models.GetCatalogGenerationResult(sqo_osrel, sqo_arch, sqo_catrel))
     # Change this to return a list of dicts
     def MakeCatalogTimingEntry(row):
+      catalogname = row[0]
+      desc = SanitizeDescription(catalogname, row[8])
       i_deps = tuple(cjson.decode(row[7]))
       deps_with_desc = cjson.decode(row[6])
       deps = tuple(x[0] for x in deps_with_desc if x[0].startswith('CSW'))
       entry = representations.CatalogTimingEntry(
-        catalogname=row[0],  # 0
+        catalogname=catalogname,  # 0
         version=row[1],      # 1
         pkgname=row[2],      # 2
         basename=row[3],     # 3
@@ -759,7 +757,7 @@
         deps=deps,           # 6
         category="none",     # 7
         i_deps=i_deps,       # 8
-        desc=row[8],         # 9
+        desc=desc,           # 9
         maintainer=row[9],
         mtime=row[10].isoformat(),
         inserted_on=row[11].isoformat(),

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