Catalogs: Modification of the template file parsing.

The code is now a function in the 'catalog' module and checks for the existence
of the file are now performed.
This commit is contained in:
Edward d'Auvergne
2019-11-13 22:26:11 +01:00
parent 9ec3e015b2
commit 8534a8aba4
2 changed files with 16 additions and 6 deletions
+14
View File
@@ -406,3 +406,17 @@ def parse_config_file(parser=None, file_name=None):
# Parse the XML and return the root node.
config = ET.parse(file_name, parser)
return config.getroot()
def parse_template_file(parser=None, file_name=None):
"""Test and parse the catalog configuration file."""
# Check for the file.
if not access(file_name, F_OK):
print("CatalogError: The catalog template file '%s' cannot be found." % file_name)
sys.exit(1)
# Parse the XML and return the template node.
template = ET.parse(file_name, parser)
template_root = template.getroot()
return template_root.find('template')