Prechádzať zdrojové kódy

mandatory sections should only be checked once and not once for each section!

twall 11 rokov pred
rodič
commit
f295463aa9
1 zmenil súbory, kde vykonal 13 pridanie a 12 odobranie
  1. 13 12
      nsist/__init__.py

+ 13 - 12
nsist/__init__.py

@@ -281,6 +281,7 @@ def read_and_verify_config_file(config_file):
             ('bitness', False),
         ],
     }
+    # check for invalid sections and subsections
     for section in cfg:
         # check section names
         section_name = str(section)
@@ -305,18 +306,18 @@ def read_and_verify_config_file(config_file):
                             section_name,
                             ', '.join(subsection_names))
                 raise NameError(err_msg)
-        # check mandatory sections
-        for section_name, subsection_list in valid_config_sections.items():
-            for subsection_name, mandatory in subsection_list:
-                if mandatory:
-                    try:
-                        cfg[section_name][subsection_name]
-                    except KeyError:
-                        err_msg = ("The section '{0}' must contain a "
-                                   "subsection '{1}'!").format(
-                                    section_name,
-                                    subsection_name)
-                        raise NameError(err_msg)
+    # check mandatory sections
+    for section_name, subsection_list in valid_config_sections.items():
+        for subsection_name, mandatory in subsection_list:
+            if mandatory:
+                try:
+                    cfg[section_name][subsection_name]
+                except KeyError:
+                    err_msg = ("The section '{0}' must contain a "
+                               "subsection '{1}'!").format(
+                                section_name,
+                                subsection_name)
+                    raise NameError(err_msg)
     return cfg
 
 def main(argv=None):