Skip to content
This repository has been archived by the owner on Jan 11, 2022. It is now read-only.

Commit

Permalink
Use 'with' keyword for better readability
Browse files Browse the repository at this point in the history
  • Loading branch information
Stefan Nordhausen committed Nov 2, 2015
1 parent cd67a2f commit d770e0e
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions src/main/python/yamlreader/yamlreader.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,9 @@ def yaml_load(source, defaultdata=NO_DEFAULT):
logger.debug("Reading %s\n", ", ".join(files))
for yaml_file in files:
try:
try:
f = open(yaml_file)
with open(yaml_file) as f:
new_data = safe_load(f)
logger.debug("YAML LOAD: %s", new_data)
finally:
f.close()
logger.debug("YAML LOAD: %s", new_data)
except MarkedYAMLError as e:
logger.error("YAML Error: %s", e)
raise YamlReaderError("YAML Error: %s" % str(e))
Expand Down

0 comments on commit d770e0e

Please sign in to comment.