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

Use yaml.safe_load() and yaml.safe_dump() #58

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions clay/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,17 +83,17 @@ def _load_config(self):
Read config from file.
"""
with open(self._config_file_path, 'r') as settings_file:
self._config = yaml.load(settings_file.read())
self._config = yaml.safe_load(settings_file.read())

# Load the configuration from Setuptools' ResourceManager API
self._default_config = yaml.load(pkg_resources.resource_string(__name__, "config.yaml"))
self._default_config = yaml.safe_load(pkg_resources.resource_string(__name__, "config.yaml"))

# We only either the user colour or the default colours to ease parsing logic.
if os.path.exists(self._colours_file_path):
with open(self._colours_file_path, 'r') as colours_file:
self.colours_config = yaml.load(colours_file.read())
self.colours_config = yaml.safe_load(colours_file.read())
else:
self.colours_config = yaml.load(pkg_resources.resource_string(__name__, "colours.yaml"))
self.colours_config = yaml.safe_load(pkg_resources.resource_string(__name__, "colours.yaml"))


def _load_cache(self):
Expand All @@ -111,7 +111,7 @@ def _commit_edits(self, config):
"""
self._config.update(config)
with open(self._config_file_path, 'w') as settings_file:
settings_file.write(yaml.dump(self._config, default_flow_style=False))
settings_file.write(yaml.safe_dump(self._config, default_flow_style=False))

def get(self, key, *sections):
"""
Expand Down