[Treepkg-commits] r359 - in branches/treepkg-status: bin treepkg/info

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Mon Jul 12 14:10:34 CEST 2010


Author: bricks
Date: 2010-07-12 14:10:34 +0200 (Mon, 12 Jul 2010)
New Revision: 359

Modified:
   branches/treepkg-status/bin/treepkginfo.py
   branches/treepkg-status/treepkg/info/status.py
Log:
let the user specify num revisions that should be shown in the info


Modified: branches/treepkg-status/bin/treepkginfo.py
===================================================================
--- branches/treepkg-status/bin/treepkginfo.py	2010-07-09 15:06:15 UTC (rev 358)
+++ branches/treepkg-status/bin/treepkginfo.py	2010-07-12 12:10:34 UTC (rev 359)
@@ -16,12 +16,23 @@
 
 def parse_commandline():
     parser = create_parser()
+    parser.set_defaults(newest=-1)
+    parser.add_option("--newest", type="int",
+                      help=("Number of newest revisions to list."))
+    parser.add_option("--pretty", action="store_true", help=("Show XML pretty"
+                      " output."))
  
+
     return parser.parse_args()
 
 def main():
     options, args = parse_commandline()
 
-    tpkginfo = status.TreepkgInfo(options.config_file)
+    tpkginfo = status.TreepkgInfo(options.config_file, options.newest)
 
+    if options.pretty:
+        print tpkginfo.toxml().toprettyxml()
+    else:
+        print tpkginfo.toxml().toxml()
+
 main()

Modified: branches/treepkg-status/treepkg/info/status.py
===================================================================
--- branches/treepkg-status/treepkg/info/status.py	2010-07-09 15:06:15 UTC (rev 358)
+++ branches/treepkg-status/treepkg/info/status.py	2010-07-12 12:10:34 UTC (rev 359)
@@ -27,7 +27,8 @@
 
 class TreepkgInfo:
 
-    def __init__(self, config):
+    def __init__(self, config, numnewestrev=-1):
+        self.numnewestrev = numnewestrev
         group = get_packager_group(config)
         self.tpkgroot = TreepkgRootInfo(group.name, group.treepkg_dir, 
                                         group.tracks_dir)
@@ -43,6 +44,11 @@
 
     def add_revisions(self, track, trackinfo):
         revisions = track.get_revisions()
+        #revisions = sorted(revisions, key=lambda r: r.status.start,
+        #                   reverse=True)
+        #if self.numnewestrev > 0:
+        #    revisions = revisions[:self.numnewestrev]
+
         for rev in revisions:
             revision = rev.revision
             rules_revision = rev.rules_revision



More information about the Treepkg-commits mailing list