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

wahwah at users.sourceforge.net wahwah at users.sourceforge.net
Mon Dec 20 12:59:13 CET 2010


Revision: 12037
          http://gar.svn.sourceforge.net/gar/?rev=12037&view=rev
Author:   wahwah
Date:     2010-12-20 11:59:13 +0000 (Mon, 20 Dec 2010)

Log Message:
-----------
pkgdb: Add 'show cat [options]' support

It shows all packages in a given catalog.

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

Modified: csw/mgar/gar/v2/lib/python/pkgdb.py
===================================================================
--- csw/mgar/gar/v2/lib/python/pkgdb.py	2010-12-20 11:58:43 UTC (rev 12036)
+++ csw/mgar/gar/v2/lib/python/pkgdb.py	2010-12-20 11:59:13 UTC (rev 12037)
@@ -7,6 +7,7 @@
 import optparse
 import models as m
 import sqlobject
+from sqlobject import sqlbuilder
 import cPickle
 import logging
 import code
@@ -38,6 +39,7 @@
        %prog del-from-cat <osrel> <arch> <cat-release> <md5sum> [ ... ]
        %prog sync-cat-from-file <osrel> <arch> <cat-release> <catalog-file>
        %prog sync-catalogs-from-tree <cat-release> <directory>
+       %prog show cat [options]
 
   Inspecting individual packages:
        %prog show errors <md5sum> [ ... ]
@@ -445,6 +447,25 @@
     ci = CatalogImporter(debug=options.debug)
     catrel, base_dir = args
     ci.SyncFromCatalogTree(catrel, base_dir)
+  elif (command, subcommand) == ('show', 'cat'):
+    sqo_osrel = m.OsRelease.selectBy(short_name=options.osrel).getOne()
+    sqo_arch = m.Architecture.selectBy(name=options.arch).getOne()
+    sqo_catrel = m.CatalogRelease.selectBy(name=options.catrel).getOne()
+    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,
+        ),
+        join=join,
+    )
+    for obj in res:
+      print obj.basename, obj.md5_sum
   elif (command, subcommand) == ('show', 'basename'):
     db_catalog = checkpkg_lib.Catalog()
     for arg in args:


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