Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace misused calls to yaml.load with a helper function. #575

Merged
merged 1 commit into from
May 31, 2016

Conversation

ftsamis
Copy link
Member

@ftsamis ftsamis commented May 31, 2016

Most of the yaml.load operations looked like yaml.load(open(filename)). Opening files and relying on the garbage collector to close them is a bad practice in Python.

With this PR, I'm introducing yaml_load_file and yaml_load_config_file in tardis.io.util and changing every call to yaml.load with the appropriate one of the above.

This also makes sure that when loading a config file (by using yaml_load_config_file), quantities are parsed from the YAMLLoader as astropy Quantity objects and opens the way for the new validator to work with the pytest tests (since it won't accept strings for quantity type properties).

Replace yaml.load(open(filename))-like calls which didn't
close the file after opening, with the helper functions
yaml_load_file and yaml_load_config_file which properly parse
a YAML file with the default yaml.Loader or with
tardis.io.util.YAMLLoader respectively.
@wkerzendorf wkerzendorf merged commit e17f42f into tardis-sn:master May 31, 2016
@ftsamis ftsamis deleted the use-yamlloader branch December 20, 2016 15:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants