]> Devi Nivas Git - chevron.git/commitdiff
Merge branch 'master' into fix/yaml-loader_GH-78
authorNoah Morrison <noah+github@morrison.ph>
Sat, 2 Jan 2021 18:00:48 +0000 (13:00 -0500)
committerGitHub <noreply@github.com>
Sat, 2 Jan 2021 18:00:48 +0000 (13:00 -0500)
1  2 
chevron/main.py

diff --cc chevron/main.py
index d941ff42e287165c75858f906e884473d4c7efea,83bfa932071a7ac2c7da86a8ea867a392a73baaf..613f9300fccf64fbfbed801549de266473f2b3de
@@@ -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,