You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@whimsical.apache.org by se...@apache.org on 2019/09/22 15:14:39 UTC

[whimsy] branch master updated: Move to mail.rb which needs to use the data

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 bc9e94c  Move to mail.rb which needs to use the data
bc9e94c is described below

commit bc9e94c4a620749113c0aa88d59387a3a3b8ead6
Author: Sebb <se...@apache.org>
AuthorDate: Sun Sep 22 16:14:35 2019 +0100

    Move to mail.rb which needs to use the data
---
 lib/whimsy/asf/mail.rb  | 63 +++++++++++++++++++++++++++++++++++++++++++++++++
 lib/whimsy/asf/mlist.rb | 47 ------------------------------------
 2 files changed, 63 insertions(+), 47 deletions(-)

diff --git a/lib/whimsy/asf/mail.rb b/lib/whimsy/asf/mail.rb
index ee17eda..ef5d9a8 100644
--- a/lib/whimsy/asf/mail.rb
+++ b/lib/whimsy/asf/mail.rb
@@ -195,6 +195,69 @@ module ASF
       return email
     end
     
+    # list the flags
+    # F:-aBcdeFgHiJklMnOpqrSTUVWXYz domain list
+    # Input:
+    # options: hash to filter output, e.g. {modsub: true}
+    # Output:
+    # yields: domain, list, flags
+    def self.list_flags(options={})
+      filter = nil
+      options.each do |k,v|
+        case k
+          when :modsub
+            filter = v ? /s/ : /S/
+          when :regex # allow direct specification for experts
+            filter = v
+          else
+            raise "Unexpected option #{k} #{v}"
+        end
+      end
+      self.parse_flags(filter) { |x| yield x } 
+    end
+  
+    # Do the flags indicate subscription moderation?
+    def self.isModSub?(flags)
+      flags.include? 's'
+    end
+
+    private
+
+    # flags for each mailing list
+    LIST_FLAGS = '/srv/subscriptions/list-flags'
+    
+    # Parse the flags file
+    def self._load_flags
+      if not @flags or File.mtime(LIST_FLAGS) != @flags_mtime
+        lists = []
+        File.open(LIST_FLAGS).each do |line|
+          if line.match(/^F:-([a-zA-Z]{26}) (\S+) (\S+)/)
+            flags,dom,list=$1,$2,$3
+            next if list =~ /^infra-[a-z]$/ or (dom == 'incubator' and list == 'infra-dev')
+            lists << [dom,list,flags]
+          else
+            raise "Unexpected flags: #{line}"
+          end
+        end
+        @flags = lists
+        @flags_mtime = File.mtime(LIST_FLAGS)
+      end
+    end
+
+    # parse the flags
+    # F:-aBcdeFgHiJklMnOpqrSTUVWXYz domain list
+    # Input:
+    # filter = RE to match against the flags, e.g. /s/ for subsmod
+    # Output:
+    # yields: domain, list, flags
+    def self.parse_flags(filter=nil)
+       self._load_flags()
+       @flags.each do |d,l,f|
+         next if filter and not f =~ filter
+         yield [d,l,f]
+       end
+    end
+
   end
 
   class Person < Base
diff --git a/lib/whimsy/asf/mlist.rb b/lib/whimsy/asf/mlist.rb
index 0e377bb..9cf3d16 100644
--- a/lib/whimsy/asf/mlist.rb
+++ b/lib/whimsy/asf/mlist.rb
@@ -231,52 +231,8 @@ module ASF
       end
     end
 
-    # list the flags
-    # F:-aBcdeFgHiJklMnOpqrSTUVWXYz domain list
-    # Input:
-    # options: hash to filter output, e.g. {modsub: true}
-    # Output:
-    # yields: domain, list, flags
-    def self.list_flags(options={})
-      filter = nil
-      options.each do |k,v|
-        case k
-          when :modsub
-            filter = v ? /s/ : /S/
-          when :regex # allow direct specification for experts
-            filter = v
-          else
-            raise "Unexpected option #{k} #{v}"
-        end
-      end
-      self.parse_flags(filter) { |x| yield x } 
-    end
-
-    # Do the flags indicate subscription moderation?
-    def self.isModSub?(flags)
-      flags.include? 's'
-    end
-
     private
 
-    # parse the flags
-    # F:-aBcdeFgHiJklMnOpqrSTUVWXYz domain list
-    # Input:
-    # filter = RE to match against the flags, e.g. /s/ for subsmod
-    # Output:
-    # yields: domain, list, flags
-    def self.parse_flags(filter=nil)
-      File.open(LIST_FLAGS).each do |line|
-        if line.match(/^F:-([a-zA-Z]{26}) (\S+) (\S+)/)
-          f,d,l=$1,$2,$3
-          next if filter and not f =~ filter
-          yield [d,l,f]
-        else
-          raise "Unexpected flags: #{line}"
-        end
-      end
-    end
-
     # return the archiver type as array: [:MBOX|:PONY|:MINO|:MAIL_ARCH|:MARKMAIL|:WHIMSY, 'public'|'private'|'alias'|'direct']
     # minotaur archiver names do not include any public/private indication as that is in bin/.archives
     def self.archiver_type(email, dom,list)
@@ -432,9 +388,6 @@ module ASF
 
     LIST_DIGS = '/srv/subscriptions/list-digs'
 
-    # flags for each mailing list
-    LIST_FLAGS = '/srv/subscriptions/list-flags'
-
     # If this file exists, it is the time when the data was last extracted
     # The mods and subs files are only updated if they have changed
     LIST_TIME = '/srv/subscriptions/list-start'