This is an automated email from the ASF dual-hosted git repository.
sebb 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 4d7f1b7 Common code to parse nominated-members.txt
4d7f1b7 is described below
commit 4d7f1b7a399067b9cfc07a75f86afd1601117b0e
Author: Sebb <[email protected]>
AuthorDate: Sat Feb 13 00:13:28 2021 +0000
Common code to parse nominated-members.txt
---
lib/whimsy/asf/nominated-members.rb | 69 +++++++++++++++++++++++++++++++++++++
1 file changed, 69 insertions(+)
diff --git a/lib/whimsy/asf/nominated-members.rb
b/lib/whimsy/asf/nominated-members.rb
new file mode 100644
index 0000000..306b08b
--- /dev/null
+++ b/lib/whimsy/asf/nominated-members.rb
@@ -0,0 +1,69 @@
+require_relative 'config'
+require_relative 'svn'
+module ASF
+
+ class MemberFiles
+
+ # Return a hash of nominated members.
+ # key: availid
+ # value: hash of entries:
+ # keys:
+ # Public Name
+ # Nominee email
+ # Nominated by
+ # Seconded by => array of seconders
+ # Nomination Statement => array of text lines
+ def self.member_nominees
+ # N.B. The format has changed over the years. This is the syntax as of
2021.
+ # -----------------------------------------
+ # <empty line>
+ # <NOMINATED PERSON'S APACHE ID> <PUBLIC NAME>
+ # Nominee email:
+ # Nominated by:
+ # Seconded by:
+
+ # Nomination Statement:
+
+ # Find most recent file:
+ nomfile = Dir[File.join(ASF::SVN['Meetings'], '*',
'nominated-members.txt')].max
+
+ nominees = {}
+ # options = {:external_encoding => Encoding::BINARY}
+ options = {:external_encoding => Encoding::BINARY,
+ :internal_encoding => Encoding::UTF_8,
+ :invalid => :replace}
+ # N.B. the ** prefix is needed to avoid the following message:
+ # Warning: Using the last argument as keyword parameters is deprecated
+ File.open(nomfile, mode='r', **options)
+ .slice_before(/^\s*---+--\s*/)
+ .drop(2) # instructions and sample block
+ .each do |block|
+ nominee = {}
+ id = '?'
+ block
+ .drop(2) # divider and blank line
+ .slice_before(/^ +(\S+ \S+):\s*/) # split on the header names
+ .each_with_index do |para, idx|
+ if idx == 0 # id and name
+ id, nominee['Public Name'] = para.first.chomp.split(' ',2)
+ else
+ key, value = para.shift.strip.split(': ',2)
+ if para.size == 0 # no more data to follow
+ nominee[key] = value
+ else
+ tmp = [value,para.map(&:chomp)].flatten.compact
+ tmp.pop if tmp[-1].empty? # drop trailing empty line only
+ nominee[key] = tmp
+ end
+ end
+ end
+ nominees[id] = nominee
+ end
+ nominees
+ end
+ end
+end
+
+if __FILE__ == $0
+ ASF::MemberFiles.member_nominees.each {|k,v| p [k, v['Public Name']]}
+end
\ No newline at end of file