allow for missing resource file
Change-Id: Iad0fcb07a942cadd6851196b52d640ebf4308f8c Signed-off-by: Doug Hellmann <doug@doughellmann.com>
This commit is contained in:
parent
6281ec4617
commit
67134ff7f0
|
@ -19,7 +19,7 @@ import munch
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
def load(filename):
|
def load(filename, missing_ok=False):
|
||||||
"Read the file and return the parsed data in a consistent format."
|
"Read the file and return the parsed data in a consistent format."
|
||||||
LOG.info('loading resource list from %s', filename)
|
LOG.info('loading resource list from %s', filename)
|
||||||
|
|
||||||
|
@ -31,9 +31,14 @@ def load(filename):
|
||||||
images=[],
|
images=[],
|
||||||
)
|
)
|
||||||
|
|
||||||
with open(filename, 'r', encoding='utf-8') as fd:
|
try:
|
||||||
contents = munch.Munch.fromYAML(fd.read())
|
with open(filename, 'r', encoding='utf-8') as fd:
|
||||||
to_return.update(contents)
|
contents = munch.Munch.fromYAML(fd.read())
|
||||||
|
except FileNotFoundError:
|
||||||
|
if not missing_ok:
|
||||||
|
raise
|
||||||
|
else:
|
||||||
|
to_return.update(contents)
|
||||||
|
|
||||||
# Ensure all entries have consistent sets of keys so the rest of
|
# Ensure all entries have consistent sets of keys so the rest of
|
||||||
# the app doesn't have to check every time it wants to use a
|
# the app doesn't have to check every time it wants to use a
|
||||||
|
|
Loading…
Reference in New Issue