Catalogs: Modification of the configuration 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
b8c05410e3
commit
9ec3e015b2
@ -6,7 +6,7 @@ from fnmatch import fnmatch, translate
|
||||
import lxml.etree as ET
|
||||
import os
|
||||
from os.path import exists, join, relpath
|
||||
from os import walk
|
||||
from os import F_OK, access, walk
|
||||
import re
|
||||
import sgprops
|
||||
import sys
|
||||
@ -393,3 +393,16 @@ def fetch_zip_exclude_list(name, path, exclude_path):
|
||||
|
||||
# Return the list.
|
||||
return blacklist
|
||||
|
||||
|
||||
def parse_config_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 configuration file '%s' cannot be found." % file_name)
|
||||
sys.exit(1)
|
||||
|
||||
# Parse the XML and return the root node.
|
||||
config = ET.parse(file_name, parser)
|
||||
return config.getroot()
|
||||
|
@ -13,7 +13,7 @@ import sgprops
|
||||
import sys
|
||||
import catalogTags
|
||||
import catalog
|
||||
from catalog import make_aircraft_node, make_aircraft_zip
|
||||
from catalog import make_aircraft_node, make_aircraft_zip, parse_config_file
|
||||
|
||||
|
||||
CATALOG_VERSION = 4
|
||||
@ -214,10 +214,7 @@ if not os.path.isdir(args.dir):
|
||||
exit(0)
|
||||
|
||||
parser = ET.XMLParser(remove_blank_text=True)
|
||||
|
||||
config_file = os.path.join(args.dir, 'catalog.config.xml')
|
||||
config = ET.parse(config_file, parser)
|
||||
config_node = config.getroot()
|
||||
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)
|
||||
|
Loading…
Reference in New Issue
Block a user