]> git.decadent.org.uk Git - dak.git/commitdiff
dak/contents.py, daklib/contents.py: add archive option
authorAnsgar Burchardt <ansgar@debian.org>
Sun, 12 Aug 2012 09:06:40 +0000 (11:06 +0200)
committerAnsgar Burchardt <ansgar@debian.org>
Sun, 12 Aug 2012 09:06:40 +0000 (11:06 +0200)
dak/contents.py
daklib/contents.py

index f36e96dcaf0449749bef146ae19fe5f4995b5e5c..407b3c06475dfae80229d676175bbec415d7fd35 100755 (executable)
@@ -67,6 +67,9 @@ OPTIONS
         show this help and exit
 
 OPTIONS for generate
+     -a, --archive=ARCHIVE
+        only operate on suites in the specified archive
+
      -s, --suite={stable,testing,unstable,...}
         only operate on specified suite names
 
@@ -84,9 +87,9 @@ OPTIONS for scan-source and scan-binary
 
 ################################################################################
 
-def write_all(cnf, suite_names = [], component_names = [], force = None):
+def write_all(cnf, archive_names = [], suite_names = [], component_names = [], force = None):
     Logger = daklog.Logger('contents generate')
-    ContentsWriter.write_all(Logger, suite_names, component_names, force)
+    ContentsWriter.write_all(Logger, archive_names, suite_names, component_names, force)
     Logger.close()
 
 ################################################################################
@@ -119,6 +122,7 @@ def main():
     cnf['Contents::Options::Limit'] = ''
     cnf['Contents::Options::Force'] = ''
     arguments = [('h', "help",      'Contents::Options::Help'),
+                 ('a', 'archive',   'Contents::Options::Archive',   'HasArg'),
                  ('s', "suite",     'Contents::Options::Suite',     "HasArg"),
                  ('c', "component", 'Contents::Options::Component', "HasArg"),
                  ('l', "limit",     'Contents::Options::Limit',     "HasArg"),
@@ -142,13 +146,14 @@ def main():
         binary_scan_all(cnf, limit)
         return
 
+    archive_names   = utils.split_args(options['Archive'])
     suite_names     = utils.split_args(options['Suite'])
     component_names = utils.split_args(options['Component'])
 
     force = bool(options['Force'])
 
     if args[0] == 'generate':
-        write_all(cnf, suite_names, component_names, force)
+        write_all(cnf, archive_names, suite_names, component_names, force)
         return
 
     usage()
index 2fb7dfcd35b3e8fcb98bcbf5cf68c28a8d087522..aedeb83dff5d529ad0bcf5ee417147841ecd77f2 100644 (file)
@@ -284,7 +284,7 @@ class ContentsWriter(object):
         class_.logger.log(result)
 
     @classmethod
-    def write_all(class_, logger, suite_names = [], component_names = [], force = False):
+    def write_all(class_, logger, archive_names = [], suite_names = [], component_names = [], force = False):
         '''
         Writes all Contents files for suites in list suite_names which defaults
         to all 'touchable' suites if not specified explicitely. Untouchable
@@ -293,6 +293,8 @@ class ContentsWriter(object):
         class_.logger = logger
         session = DBConn().session()
         suite_query = session.query(Suite)
+        if len(archive_names) > 0:
+            suite_query = suite_query.join(Suite.archive).filter(Archive.archive_name.in_(archive_names))
         if len(suite_names) > 0:
             suite_query = suite_query.filter(Suite.suite_name.in_(suite_names))
         component_query = session.query(Component)