Skip to content

Commit

Permalink
Encoding option + version bump
Browse files Browse the repository at this point in the history
  • Loading branch information
mkaranasou committed Jan 28, 2022
1 parent 638b58d commit d950404
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = pyaml_env
version = 1.1.3
version = 1.1.4
author = Maria Karanasou
author_email = karanasou@gmail.com
description = Provides yaml file parsing with environment variable resolution
Expand Down
3 changes: 1 addition & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,10 @@
REQUIREMENTS = [i.strip() for i in open('requirements.txt').readlines()]
tests_require = [
'pytest',
'mock',
]

setup(name='pyaml_env',
version='1.1.3',
version='1.1.4',
description='Provides yaml file parsing with '
'environment variable resolution',
long_description=long_description,
Expand Down
7 changes: 5 additions & 2 deletions src/pyaml_env/parse_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ def parse_config(
default_sep=':',
default_value='N/A',
raise_if_na=False,
loader=yaml.SafeLoader
loader=yaml.SafeLoader,
encoding='utf-8'
):
"""
Load yaml configuration from path or from the contents of a file (data)
Expand All @@ -36,6 +37,8 @@ def parse_config(
value set for the env variable.
:param Type[yaml.loader] loader: Specify which loader to use. Defaults to
yaml.SafeLoader
:param str encoding: the encoding of the data if a path is specified,
defaults to utf-8
:return: the dict configuration
:rtype: dict[str, T]
"""
Expand Down Expand Up @@ -91,7 +94,7 @@ def constructor_env_variables(loader, node):
loader.add_constructor(tag, constructor_env_variables)

if path:
with open(path, encoding='utf-8') as conf_data:
with open(path, encoding=encoding) as conf_data:
return yaml.load(conf_data, Loader=loader)
elif data:
return yaml.load(data, Loader=loader)
Expand Down

0 comments on commit d950404

Please sign in to comment.