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:
parent
9ec3e015b2
commit
8534a8aba4
2 changed files with 16 additions and 6 deletions
|
@ -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')
|
||||
|
|
|
@ -13,7 +13,7 @@ import sgprops
|
|||
import sys
|
||||
import catalogTags
|
||||
import catalog
|
||||
from catalog import make_aircraft_node, make_aircraft_zip, parse_config_file
|
||||
from catalog import make_aircraft_node, make_aircraft_zip, parse_config_file, parse_template_file
|
||||
|
||||
|
||||
CATALOG_VERSION = 4
|
||||
|
@ -215,11 +215,7 @@ if not os.path.isdir(args.dir):
|
|||
|
||||
parser = ET.XMLParser(remove_blank_text=True)
|
||||
config_node = parse_config_file(parser=parser, file_name=os.path.join(args.dir, 'catalog.config.xml'))
|
||||
|
||||
template_file = os.path.join(args.dir, 'template.xml')
|
||||
template = ET.parse(template_file, parser)
|
||||
template_root = template.getroot()
|
||||
template_node = template_root.find('template')
|
||||
template_node = parse_template_file(parser=parser, file_name=os.path.join(args.dir, 'template.xml'))
|
||||
|
||||
md5sum_file = os.path.join(args.dir, 'md5sum.xml')
|
||||
if os.path.exists(md5sum_file):
|
||||
|
|
Loading…
Reference in a new issue