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

wahwah at users.sourceforge.net wahwah at users.sourceforge.net
Sat Feb 5 20:34:52 CET 2011


Revision: 13197
          http://gar.svn.sourceforge.net/gar/?rev=13197&view=rev
Author:   wahwah
Date:     2011-02-05 19:34:52 +0000 (Sat, 05 Feb 2011)

Log Message:
-----------
pkgdb: GetCatPackagesResult moved to models.py

It's a reusable function.

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

Modified: csw/mgar/gar/v2/lib/python/models.py
===================================================================
--- csw/mgar/gar/v2/lib/python/models.py	2011-02-04 19:56:11 UTC (rev 13196)
+++ csw/mgar/gar/v2/lib/python/models.py	2011-02-05 19:34:52 UTC (rev 13197)
@@ -326,3 +326,21 @@
   pkginst = sqlobject.ForeignKey('Pkginst', notNone=True)
   dep_uniq_idx = sqlobject.DatabaseIndex(
       'srv4_file', 'pkginst')
+
+
+def GetCatPackagesResult(sqo_osrel, sqo_arch, sqo_catrel):
+  join = [
+      sqlbuilder.INNERJOINOn(None,
+        Srv4FileInCatalog,
+        Srv4FileInCatalog.q.srv4file==Srv4FileStats.q.id),
+  ]
+  res = Srv4FileStats.select(
+      sqlobject.AND(
+        Srv4FileInCatalog.q.osrel==sqo_osrel,
+        Srv4FileInCatalog.q.arch==sqo_arch,
+        Srv4FileInCatalog.q.catrel==sqo_catrel,
+        Srv4FileStats.q.use_to_generate_catalogs==True,
+      ),
+      join=join,
+  ).orderBy('catalogname')
+  return res

Modified: csw/mgar/gar/v2/lib/python/pkgdb.py
===================================================================
--- csw/mgar/gar/v2/lib/python/pkgdb.py	2011-02-04 19:56:11 UTC (rev 13196)
+++ csw/mgar/gar/v2/lib/python/pkgdb.py	2011-02-05 19:34:52 UTC (rev 13197)
@@ -334,24 +334,6 @@
   return sqo_osrel, sqo_arch, sqo_catrel
 
 
-def GetCatPackagesResult(sqo_osrel, sqo_arch, sqo_catrel):
-    join = [
-        sqlbuilder.INNERJOINOn(None,
-          m.Srv4FileInCatalog,
-          m.Srv4FileInCatalog.q.srv4file==m.Srv4FileStats.q.id),
-    ]
-    res = m.Srv4FileStats.select(
-        sqlobject.AND(
-          m.Srv4FileInCatalog.q.osrel==sqo_osrel,
-          m.Srv4FileInCatalog.q.arch==sqo_arch,
-          m.Srv4FileInCatalog.q.catrel==sqo_catrel,
-          m.Srv4FileStats.q.use_to_generate_catalogs==True,
-        ),
-        join=join,
-    ).orderBy('catalogname')
-    return res
-
-
 def main():
   parser = optparse.OptionParser(USAGE)
   parser.add_option("-d", "--debug", dest="debug",
@@ -534,7 +516,7 @@
   elif (command, subcommand) == ('show', 'cat'):
     sqo_osrel, sqo_arch, sqo_catrel = GetSqoTriad(
         options.osrel, options.arch, options.catrel)
-    res = GetCatPackagesResult(sqo_osrel, sqo_arch, sqo_catrel)
+    res = m.GetCatPackagesResult(sqo_osrel, sqo_arch, sqo_catrel)
     for obj in res:
       print obj.catalogname, obj.basename, obj.md5_sum
   elif command == 'gen-cat':
@@ -563,7 +545,7 @@
       for arch in archs:
         sqo_osrel, sqo_arch, sqo_catrel = GetSqoTriad(
             osrel, arch, catrel)
-        pkgs = list(GetCatPackagesResult(sqo_osrel, sqo_arch, sqo_catrel))
+        pkgs = list(m.GetCatPackagesResult(sqo_osrel, sqo_arch, sqo_catrel))
         logging.debug("The catalog contains %s packages" % len(pkgs))
         # For now, only making hardlinks to packages from allpkgs
         osrel_short = ShortenOsrel(osrel)

Modified: csw/mgar/gar/v2/lib/web/pkgdb_web.py
===================================================================
--- csw/mgar/gar/v2/lib/web/pkgdb_web.py	2011-02-04 19:56:11 UTC (rev 13196)
+++ csw/mgar/gar/v2/lib/web/pkgdb_web.py	2011-02-05 19:34:52 UTC (rev 13197)
@@ -122,7 +122,7 @@
     cat_name = " ".join((catrel_name, arch_name, osrel_name))
     sqo_osrel, sqo_arch, sqo_catrel = pkgdb.GetSqoTriad(
         osrel_name, arch_name, catrel_name)
-    pkgs = pkgdb.GetCatPackagesResult(sqo_osrel, sqo_arch, sqo_catrel)
+    pkgs = models.GetCatPackagesResult(sqo_osrel, sqo_arch, sqo_catrel)
     return render.CatalogDetail(cat_name, pkgs)
 
 class MaintainerList(object):


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