whimsical-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From curc...@apache.org
Subject [whimsy] branch master updated: Fix variable name bugs
Date Sat, 11 May 2019 12:23:08 GMT
This is an automated email from the ASF dual-hosted git repository.

curcuru pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/whimsy.git


The following commit(s) were added to refs/heads/master by this push:
     new 0bbb131  Fix variable name bugs
0bbb131 is described below

commit 0bbb1314544ccc31ca2c3f3154351fac8b6f8818
Author: Shane Curcuru <asf@shanecurcuru.org>
AuthorDate: Sat May 11 08:22:57 2019 -0400

    Fix variable name bugs
---
 tools/mboxhdr2csv.rb | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/tools/mboxhdr2csv.rb b/tools/mboxhdr2csv.rb
index b5fe1f7..749a696 100644
--- a/tools/mboxhdr2csv.rb
+++ b/tools/mboxhdr2csv.rb
@@ -118,7 +118,7 @@ def mbox2stats(f)
         text_part = mail.body.decoded.split(/\r?\n/)
       end
       ctr = 0 # Count text lines of nonblank, nonreply content
-      linkz = 0 # Count number of apparent hyperlinks
+      links = 0 # Count number of apparent hyperlinks
       text_part.each do |l|
         case l
         when /\A\s*>/
@@ -130,8 +130,9 @@ def mbox2stats(f)
         when /\A-----Original Message-----/
           # Stop counting if it seems like a forwarded message
           break
+          # TODO: figure out if we're in a .sig block, and stop counting
         else
-          linkz += 1 if l =~ URIRX
+          links += 1 if l =~ URIRX
           ctr += 1
         end
       end
@@ -292,15 +293,15 @@ def scan_dir_stats2csv(dir, outname, ext = '.json')
   puts "#{__method__} processing #{jzons.length} mbox json files"
   # Write out headers and the first array in new csv
   csvfile = File.join("#{dir}", outname)
-  csv = CSV.open(csvfile, "w", headers: %w( year month day weekday hour zone listid who subject
lines linkz committer messageid inreplyto ), write_headers: true)
+  csv = CSV.open(csvfile, "w", headers: %w( year month day weekday hour zone listid who subject
lines links committer messageid inreplyto ), write_headers: true)
   jzons.shift[0].each do |m|
-    csv << [ m['y'], m['m'], m['d'], m['w'], m['h'], m['z'], m['listid'], m['who'],
m['subject'], m['lines'], m['linkz'], m['committer'], m['messageid'], m['inreplyto']  ]
+    csv << [ m['y'], m['m'], m['d'], m['w'], m['h'], m['z'], m['listid'], m['who'],
m['subject'], m['lines'], m['links'], m['committer'], m['messageid'], m['inreplyto']  ]
   end
   # Write out all remaining arrays, without headers, appending
   jzons.each do |j|
     begin
       j[0].each do |m|
-        csv << [ m['y'], m['m'], m['d'], m['w'], m['h'], m['z'], m['listid'], m['who'],
m['subject'], m['lines'], m['linkz'], m['committer'], m['messageid'], m['inreplyto']  ]
+        csv << [ m['y'], m['m'], m['d'], m['w'], m['h'], m['z'], m['listid'], m['who'],
m['subject'], m['lines'], m['links'], m['committer'], m['messageid'], m['inreplyto']  ]
       end
     rescue => e
       puts "ERROR: write of #{f} raised #{e.message[0..255]}"
@@ -354,7 +355,7 @@ if __FILE__ == $PROGRAM_NAME
     puts "START: Parsing #{options[:dir]}/*#{MBOX_EXT} into *.json"
     scan_dir_mbox2stats(options[:dir]) # Side effect: writes out f.chomp(ext).json files
   end
-  puts "START: Analyzing #{options[:dir]}/*#{MBOX_EXT} into #{options[:output]}"
+  puts "START: Analyzing #{options[:dir]}/*.json into #{options[:output]}"
   errs = scan_dir_stats2csv(options[:dir], options[:output])
   if errs
     errs.each do |e|


Mime
View raw message