[116815] branches/gsoc11-statistics/stats-server/bin/new_ports

cal at macports.org cal at macports.org
Fri Feb 7 13:47:12 PST 2014


Revision: 116815
          https://trac.macports.org/changeset/116815
Author:   cal at macports.org
Date:     2014-02-07 13:47:12 -0800 (Fri, 07 Feb 2014)
Log Message:
-----------
macports stats: support indexing subports, carefully avoid printing non-data to stdout

Modified Paths:
--------------
    branches/gsoc11-statistics/stats-server/bin/new_ports

Modified: branches/gsoc11-statistics/stats-server/bin/new_ports
===================================================================
--- branches/gsoc11-statistics/stats-server/bin/new_ports	2014-02-07 21:41:01 UTC (rev 116814)
+++ branches/gsoc11-statistics/stats-server/bin/new_ports	2014-02-07 21:47:12 UTC (rev 116815)
@@ -20,9 +20,9 @@
 # Standard procedures
 proc print_usage args {
     global argv0
-    puts "Usage: $argv0 \[-d\] -m <time> \<directory\>"
-    puts "-d:\tOutput debugging information"
-    puts "-m:\tOutput ports newer than the given mtime"
+    puts stderr "Usage: $argv0 \[-d\] -m <time> \<directory\>"
+    puts stderr "-d:\tOutput debugging information"
+    puts stderr "-m:\tOutput ports newer than the given mtime"
 }
 
 proc pindex {portdir} {
@@ -38,19 +38,40 @@
                 seek $oldfd $offset
                 gets $oldfd line
                 set name [lindex $line 0]
-                set len [lindex $line 1]
+                set len  [lindex $line 1]
                 set line [read $oldfd $len]
                 array set portinfo $line
 
                 if {[info exists ui_options(ports_debug)]} {
-                    puts "Found entry for $portdir"
+                    puts stderr "Found entry for $portdir"
                 }
 
                 foreach field [array names portinfo] {
-                    puts $fd "${field}: $portinfo($field)"
+                    puts "${field}: $portinfo($field)"
                 }
-                puts $fd ""
+                puts ""
 
+                # continue if there are no subports
+                if {![info exists portinfo(subports)]} {
+                    return
+                }
+
+                # re-use the entries for its subports, too
+                foreach sub $portinfo(subports) {
+                    set offset $qindex([string tolower $sub])
+                    seek $oldfd $offset
+                    gets $oldfd line
+                    set name [lindex $line 0]
+                    set len  [lindex $line 1]
+                    set line [read $oldfd $len]
+                    array set subportinfo $line
+
+                    foreach field [array names subportinfo] {
+                        puts "${field}: $subportinfo($field)"
+                    }
+                    puts ""
+                }
+
                 return
             }
         } catch {*} {
@@ -132,9 +153,7 @@
     set newest 0
 }
 
-set fd stdout
 mporttraverse pindex $directory
 if {[info exists oldfd]} {
     close $oldfd
 }
-close $fd
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/macports-changes/attachments/20140207/66e46def/attachment.html>


More information about the macports-changes mailing list