def get_es_template(self, filename):
"""Loads an ElasticSearch template (as JSON)"""
template_path = os.path.join(self.config["template_path"], filename)
try:
with open(template_path) as f:
es_template = json.load(f)
except (FileNotFoundError, json.decoder.JSONDecodeError) as e:
if type(e) == FileNotFoundError:
logger.debug("Didn't find ES template (%s), falling back to default" %
template_path)
elif type(e) == json.decoder.JSONDecodeError:
recoverable_error(("Error JSON-decoding ES template (%s)" %
template_path), self.bypass_errors)
with resource_stream(__name__, BUILTIN_ES_TEMPLATE) as f:
es_template = json.load(f)
return es_template
评论列表
文章目录