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

Spelling #315

Merged
merged 7 commits into from
May 27, 2024
Merged
Show file tree
Hide file tree
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
6 changes: 3 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@

# Version 0.3.13

* Fixed dictionary substititution merge. PR[#52]
* Fixed dictionary substitution merge. PR[#52]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some projects don't like changing changelogs. Happy to drop this or anything else.


# Version 0.3.12

Expand Down Expand Up @@ -265,13 +265,13 @@

# Version 0.3.4

* Fixed substitutions that are overriden later on by a non substitution. PR[#34]
* Fixed substitutions that are overridden later on by a non substitution. PR[#34]
* Added logging. PR[#30] and PR[#31]

# Version 0.3.3

* Fixed optional substitution when overriding elements at the same level. PR[#28]
* Silent IOErrors when including non-existent files. PR[#24]
* Silent IOErrors when including nonexistent files. PR[#24]
* Fixed when assign key to a value, list or dict that starts with eol. PR[#22]

## Version 0.3.2
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ password = conf.get('databases.mysql.password', 'default_password') # use defau
# you can use substitution with unquoted strings
retries_msg = You have ${databases.mysql.retries} retries

# retries message will be overriden if environment variable CUSTOM_MSG is set
# retries message will be overridden if environment variable CUSTOM_MSG is set
retries_msg = ${?CUSTOM_MSG}
}

Expand Down Expand Up @@ -388,7 +388,7 @@ assert config == d
- Scott Johnson ([@scottj97](https://github.com/scottj97))
- Yifei Tao ([@yifeitao](https://github.com/yifeitao))
- Kevin Fong ([@KevinMFong](https://github.com/KevinMFong))
- Erik Cederstrand [@ecederstrand](https://github.com/ecederstrand))
- Erik Cederstrand ([@ecederstrand](https://github.com/ecederstrand))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't precisely a spelling error, it's a stylistic error that turned up as I was tuning check-spelling to ignore the items in this list.


### Thanks

Expand Down
14 changes: 7 additions & 7 deletions pyhocon/config_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ def parse_file(cls, filename, encoding='utf-8', required=True, resolve=True, unr
:param resolve: if true, resolve substitutions
:type resolve: boolean
:param unresolved_value: assigned value to unresolved substitution.
If overriden with a default value, it will replace all unresolved values by the default value.
If overridden with a default value, it will replace all unresolved values by the default value.
If it is set to pyhocon.STR_SUBSTITUTION then it will replace the value by its substitution expression (e.g., ${x})
:type unresolved_value: class
:return: Config object or []
Expand All @@ -155,7 +155,7 @@ def parse_URL(cls, url, timeout=None, resolve=True, required=False, unresolved_v
:param resolve: if true, resolve substitutions
:type resolve: boolean
:param unresolved_value: assigned value to unresolved substitution.
If overriden with a default value, it will replace all unresolved values by the default value.
If overridden with a default value, it will replace all unresolved values by the default value.
If it is set to pyhocon.STR_SUBSTITUTION then it will replace the value by its substitution expression (e.g., ${x})
:type unresolved_value: class
:return: Config object or []
Expand Down Expand Up @@ -183,7 +183,7 @@ def parse_string(cls, content, basedir=None, resolve=True, unresolved_value=DEFA
:param resolve: if true, resolve substitutions
:type resolve: boolean
:param unresolved_value: assigned value to unresolved substitution.
If overriden with a default value, it will replace all unresolved values by the default value.
If overridden with a default value, it will replace all unresolved values by the default value.
If it is set to pyhocon.STR_SUBSTITUTION then it will replace the value by its substitution expression (e.g., ${x})
:type unresolved_value: class
:return: Config object
Expand Down Expand Up @@ -240,7 +240,7 @@ def parse(cls, content, basedir=None, resolve=True, unresolved_value=DEFAULT_SUB
:param resolve: if true, resolve substitutions
:type resolve: boolean
:param unresolved_value: assigned value to unresolved substitution.
If overriden with a default value, it will replace all unresolved values by the default value.
If overridden with a default value, it will replace all unresolved values by the default value.
If it is set to pyhocon.STR_SUBSTITUTION then it will replace the value by its substitution expression (e.g., ${x})
:type unresolved_value: boolean
:return: a ConfigTree or a list
Expand Down Expand Up @@ -580,7 +580,7 @@ def _do_substitute(cls, substitution, resolved_value, is_optional_resolved=True)
# use a deepcopy of resolved_value to avoid mutation
config_values.put(substitution.index, copy.deepcopy(formatted_resolved_value))
transformation = config_values.transform()
result = config_values.overriden_value \
result = config_values.overridden_value \
if transformation is None and not is_optional_resolved \
else transformation

Expand Down Expand Up @@ -635,7 +635,7 @@ def resolve_substitutions(cls, config, accept_unresolved=False):

for substitution in _substitutions:
unresolved = False
overridden_value = substitution.parent.overriden_value
overridden_value = substitution.parent.overridden_value
if isinstance(overridden_value, ConfigValues):
overridden_value = overridden_value.transform()
# If this substitution is an override, and the parent is still being processed,
Expand Down Expand Up @@ -663,7 +663,7 @@ def resolve_substitutions(cls, config, accept_unresolved=False):
continue
if not isinstance(resolved_value, ConfigValues):
cache_values.append(substitution)
overrides = [s for s in substitutions if s.parent.overriden_value == substitution.parent]
overrides = [s for s in substitutions if s.parent.overridden_value == substitution.parent]
if len(overrides) > 0:
for o in overrides:
values = cache.get(o) if cache.get(o) is not None else []
Expand Down
24 changes: 12 additions & 12 deletions pyhocon/config_tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def merge_configs(a, b, copy_trees=False):
value.parent = a
value.key = key
if key in a:
value.overriden_value = a[key]
value.overridden_value = a[key]
a[key] = value
if a.root:
if b.root:
Expand Down Expand Up @@ -115,7 +115,7 @@ def _put(self, key_path, value, append=False):
l_value.tokens.append(value)
l_value.recompute()
elif isinstance(l_value, ConfigTree) and isinstance(value, ConfigValues):
value.overriden_value = l_value
value.overridden_value = l_value
value.tokens.insert(0, l_value)
value.recompute()
value.parent = self
Expand All @@ -124,7 +124,7 @@ def _put(self, key_path, value, append=False):
self[key_elt] = value
elif isinstance(l_value, list) and isinstance(value, ConfigValues):
self._push_history(key_elt, value)
value.overriden_value = l_value
value.overridden_value = l_value
value.parent = self
value.key = key_elt
self[key_elt] = value
Expand All @@ -144,11 +144,11 @@ def _put(self, key_path, value, append=False):
type=l_value.__class__.__name__)
)
else:
# if there was an override keep overide value
# if there was an override keep override value
if isinstance(value, ConfigValues):
value.parent = self
value.key = key_elt
value.overriden_value = self.get(key_elt, None)
value.overridden_value = self.get(key_elt, None)
self._push_history(key_elt, value)
self[key_elt] = value
else:
Expand Down Expand Up @@ -477,7 +477,7 @@ def __init__(self, tokens, instring, loc):
self.key = None
self._instring = instring
self._loc = loc
self.overriden_value = None
self.overridden_value = None
self.recompute()

def recompute(self):
Expand Down Expand Up @@ -506,8 +506,8 @@ def get_substitutions(self):
# walking up the override chain and append overrides to the front.
# later, parent overrides will be processed first, followed by children
lst = [token for token in node.tokens if isinstance(token, ConfigSubstitution)] + lst
if hasattr(node, 'overriden_value'):
node = node.overriden_value
if hasattr(node, 'overridden_value'):
node = node.overridden_value
if not isinstance(node, ConfigValues):
break
else:
Expand Down Expand Up @@ -549,8 +549,8 @@ def format_str(v, last=False):

if first_tok_type is ConfigTree:
child = []
if hasattr(self, 'overriden_value'):
node = self.overriden_value
if hasattr(self, 'overridden_value'):
node = self.overridden_value
while node:
if isinstance(node, ConfigValues):
value = node.transform()
Expand All @@ -562,8 +562,8 @@ def format_str(v, last=False):
child.append(node)
else:
break
if hasattr(node, 'overriden_value'):
node = node.overriden_value
if hasattr(node, 'overridden_value'):
node = node.overridden_value
else:
break

Expand Down
8 changes: 4 additions & 4 deletions tests/test_config_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -2488,7 +2488,7 @@ def test_unicode_dict_key(self):
config.get_string(u'www.example-ö.com.us.name.missing')

def test_with_comment_on_last_line(self):
# Adress issue #102
# Address issue #102
config_tree = ConfigFactory.parse_string("""
foo: "1"
bar: "2"
Expand All @@ -2513,9 +2513,9 @@ def test_pop(self):
}
assert expected == config_tree

def test_merge_overriden(self):
# Adress issue #110
# ConfigValues must merge with its .overriden_value
def test_merge_overridden(self):
# Address issue #110
# ConfigValues must merge with its .overridden_value
# if both are ConfigTree
config_tree = ConfigFactory.parse_string("""
foo: ${bar}
Expand Down
4 changes: 2 additions & 2 deletions tests/test_config_tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ def test_config_tree_resolve(self):
resolve=False
)

substitudeConfig = ConfigFactory.parse_string(
substituteConfig = ConfigFactory.parse_string(
"""
sub = 100
nested {
Expand All @@ -345,7 +345,7 @@ def test_config_tree_resolve(self):
}
"""
)
result = config.resolve(substitudeConfig)
result = config.resolve(substituteConfig)
assert result.get_int('a') == 100
assert result.get_string('nested.value.a') == "string"
assert result.get_int('nested.value.b') == 10
Expand Down