You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@whimsical.apache.org by cu...@apache.org on 2019/05/09 20:36:04 UTC

[whimsy] branch master updated: Remove deprecated code

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 afef6e5  Remove deprecated code
afef6e5 is described below

commit afef6e527ab4a681fece2feb231fe2f2b72eb36f
Author: Shane Curcuru <as...@shanecurcuru.org>
AuthorDate: Thu May 9 16:35:55 2019 -0400

    Remove deprecated code
---
 tools/mboxhdr2csv.rb | 118 ---------------------------------------------------
 1 file changed, 118 deletions(-)

diff --git a/tools/mboxhdr2csv.rb b/tools/mboxhdr2csv.rb
index 002d2f4..5675e35 100644
--- a/tools/mboxhdr2csv.rb
+++ b/tools/mboxhdr2csv.rb
@@ -309,124 +309,6 @@ def scan_dir_stats2csv(dir, outname)
   return errors
 end
 
-# Aggregate selected header fields from an mbox
-# @deprecated TODO use mbox2stats et al instead
-def scan_mbox_headers(f, headers)
-  begin
-    messages = read_mbox(f)
-  rescue => e
-    puts "ERROR:scan_mbox_hdr(#{f}) #{e}"
-    return
-  end
-  begin
-    messages.each do |message|
-      header = {}
-      catch :headerend do
-        lines = message.split(/\n/)
-        lines.shift # Drop first bogus line
-        lines.each do |line|
-          throw :headerend if line == ""
-          case line
-          when /^Subject: (.*)/
-            header[:subject] = "#{$1}"
-          when /^From: (.*)/
-            header[:from] = "#{$1}"
-          when /^Date: (.*)/
-            header[:date] = "#{$1}"
-          when /^List-Id: <(.*)>/
-            header[:listid] = "#{$1}"
-          when /^Message-ID: <(.*)>/
-            header[:messageid] = "#{$1}"
-          when /^In-Reply-To: <(.*)>/
-            header[:inreplyto] = "#{$1}"
-          end
-        end
-      end
-      headers << header
-    end
-    return
-  rescue => e
-    puts e # TODO rationalize error processing
-    return ["ERROR:scan_mbox_hdr(#{f}) #{e.message[0..255]}", "\t#{e.backtrace.join("\n\t")}"]
-  end
-end
-
-# Return headers for a directory of mboxes
-# @deprecated TODO use mbox2stats et al instead
-def scan_dir_headers(dir, ext)
-  headers = []
-  errs = []
-  Dir["#{dir}/**/*#{ext}*".untaint].each do |f|
-    headers, errs = scan_mbox_headers(f.untaint, headers)
-  end
-  annotate_headers(headers)
-  return headers
-end
-
-# Simple header annotations for best guesses of ASF attributes related to trademarks@
-# @deprecated TODO use mbox2stats et al instead
-# TODO Only additional feature is setting header[:type], which is list-specific
-SHANE = 'Shane'
-def annotate_headers(headers)
-  headers.each do |header|
-    if header[:from] =~ /\(JIRA\)/
-      header[:type] = 'JIRA'
-    elsif header[:subject] =~ /\Asvn commit/
-      header[:type] = 'SVN'
-    elsif header[:subject] =~ /\A\[REPORT\] /
-      header[:type] = 'REPORT'
-    elsif header[:subject] =~ /\A\[[A-Z]{5,6}\] / # mailto: from website
-      header[:type] = 'Question-Web'
-    else
-      header.key?(:inreplyto) ? header[:type] = '' : header[:type] = 'Question' # Presumably a new incoming question
-    end
-    
-    if header[:from] =~ /\AShane Curcuru \(JIRA/i # Optimize case for trademarks@
-      header[:who] = 'Shane-JIRA'
-      header[:committer] = SHANE
-    elsif header[:from] =~ /Shane Curcuru/i # Optimize case for trademarks@
-      header[:who] = 'Shane'
-      header[:committer] = SHANE
-    elsif header[:from] =~ /\AVice President, Brand Management/i # Optimize case for trademarks@
-      header[:who] = 'Shane-VP'
-      header[:committer] = SHANE
-    elsif header[:from] =~ /jira@/i # Optimize case for trademarks@, hackish
-      header[:who] = header[:from].sub("<ji...@apache.org>", '').gsub('""', '')
-      header[:committer] = COMMITTER
-    else
-      begin
-        tmp = liberal_email_parser(header[:from])
-        person = ASF::Person.find_by_email(tmp.address.dup)
-        if person
-          header[:who] = person.cn
-          if person.asf_member?
-            header[:committer] = MEMBER
-          else
-            header[:committer] = COMMITTER
-          end
-        else
-          header[:who] = tmp.display_name
-          header[:committer] = 'n'
-        end
-      rescue
-        header[:who] = header[:from]
-        header[:committer] = 'N'
-      end
-    end
-  end
-end
-
-# Common use case - analyze headers in mbox files to see who asks questions on trademarks@
-# @deprecated TODO use mbox2stats et al instead
-def do_mbox2csv_hdr(dir)
-  headers = scan_dir_headers(dir, MBOX_EXT)
-  CSV.open(File.join("#{dir}", "mboxhdr2csv.csv"), "w", headers: %w( date who subject messageid committer question ), write_headers: true) do |csv|
-    headers.each do |h|
-      csv << [h[:date], h[:who], h[:subject], h[:messageid], h[:committer], h[:type] ]
-    end
-  end
-end
-
 # ## ### #### ##### ######
 # Check options and call needed methods
 DEFAULT_OUTPUT = 'mbox-analysis.csv'