From: Noah Morrison Date: Sat, 2 Jan 2021 18:00:48 +0000 (-0500) Subject: Merge branch 'master' into fix/yaml-loader_GH-78 X-Git-Url: https://git.devinivas.org/?a=commitdiff_plain;h=c409d85122e7ef4752ec50f39fc6de456996b6ba;p=chevron.git Merge branch 'master' into fix/yaml-loader_GH-78 --- c409d85122e7ef4752ec50f39fc6de456996b6ba diff --cc chevron/main.py index d941ff4,83bfa93..613f930 --- a/chevron/main.py +++ b/chevron/main.py @@@ -11,15 -16,13 +11,15 @@@ except (ValueError, SystemError): # py from metadata import version - def main(template, data={}, **kwargs): + def main(template, data=None, **kwargs): with io.open(template, 'r', encoding='utf-8') as template_file: - + yaml_loader = kwargs.pop('yaml_loader', None) or 'FullLoader' + - if data != {}: - data_file = io.open(data, 'r', encoding='utf-8') - data = _load_data(data_file, yaml_loader) - data_file.close() + if data is not None: + with io.open(data, 'r', encoding='utf-8') as data_file: - data = json.load(data_file) ++ data = _load_data(data_file, yaml_loader) + else: + data = {} args = { 'template': template_file,