-#Config parser from merged files section
-class Iterfiles:
- def __init__(self, filename):
- self.filename = filename
-
- def iterf(self):
- shortname = os.path.basename(filename)
- shortname1 = os.path.splitext(shortname)[0]
- return (self.filename, shortname1)
-
-class Openfile:
- def __init__(self, filename, shortname1):
- self.filename = filename
- self.shortname1 = shortname1
- def openf(self):
- file = open(self.filename, encoding="utf_8")
- config.read_file(add_section_header(file, self.shortname1), source=self.filename)
- return config
-
-#cfg files are not real ini files, need to add section headers.
+# Config parser from merged files section
+def read_config(filename):
+ shortname = os.path.basename(filename)
+ header_name = os.path.splitext(shortname)[0]
+ with open(filename, "r", encoding="utf_8") as config_file:
+ config.read_file(add_section_header(config_file, header_name), source=filename)
+ return config
+
+# Cfg files are not real ini files, need to add section headers.