Author: gstein
Date: Sat May 11 06:15:38 2024
New Revision: 1917661

URL: http://svn.apache.org/viewvc?rev=1917661&view=rev
Log:
Clarify/document the configuration of groups.

* tools/hook-scripts/mailer/mailer.py:
  (Config.__init__): define helper func build_section_ob() and use
    that to copy values from the ConfigParser instance into SELF. Add
    varous comments to make it clearer what is happening.

Modified:
    subversion/trunk/tools/hook-scripts/mailer/mailer.py

Modified: subversion/trunk/tools/hook-scripts/mailer/mailer.py
URL: 
http://svn.apache.org/viewvc/subversion/trunk/tools/hook-scripts/mailer/mailer.py?rev=1917661&r1=1917660&r2=1917661&view=diff
==============================================================================
--- subversion/trunk/tools/hook-scripts/mailer/mailer.py (original)
+++ subversion/trunk/tools/hook-scripts/mailer/mailer.py Sat May 11 06:15:38 
2024
@@ -1258,18 +1258,27 @@ class Config:
     # record the (non-default) groups that we find
     ordered_groups = [ ]
 
+    def build_section_ob(section_name):
+        ob = _sub_section()
+        # Get the raw values. We use the same format for *our* interpolation.
+        vars(ob).update(cp.items(section_name, raw=True))
+        return ob
+
+    # The config file MUST contain [general] and [defaults]; maybe [maps]
+    self.general = build_section_ob('general')
+    self.defaults = build_section_ob('defaults')
+    if cp.has_section('maps'):
+        self.maps = build_section_ob('maps')
+
+    # Process all other sections as groups.
     for section in cp.sections():
-      if not hasattr(self, section):
-        section_ob = _sub_section()
-        setattr(self, section, section_ob)
-        if section not in self.PREDEFINED:
-            ordered_groups.append(section)
-      else:
-        section_ob = getattr(self, section)
-      for option in cp.options(section):
-        # get the raw value -- we use the same format for *our* interpolation
-        value = cp.get(section, option, raw=1)
-        setattr(section_ob, option, value)
+        if section in self.PREDEFINED:
+            continue
+        assert not hasattr(self, section)
+
+        ordered_groups.append(section)
+
+        setattr(self, section, build_section_ob(section))
 
     # be compatible with old format config files
     if hasattr(self.general, 'diff') and not hasattr(self.defaults, 'diff'):


Reply via email to