Skip to content

Commit

Permalink
Avoid templating 'only references' into a string
Browse files Browse the repository at this point in the history
Fixes type conversions of referenced ints/bools/floats/…
  • Loading branch information
akaIDIOT committed Jan 16, 2019
1 parent d75026a commit 10ab57f
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions confidence.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,26 +159,28 @@ def _resolve(self, value):

reference = self._root.get(path, resolve_references=False)

if isinstance(reference, Configuration):
if match.span(0) != (0, len(value)):
if match.span(0) != (0, len(value)):
if isinstance(reference, Configuration):
raise ConfiguredReferenceError(
'cannot insert namespace at {path} into referring value'.format(path=path),
key=path
)

return reference

value = '{start}{reference}{end}'.format(
start=value[:match.start(0)],
reference=reference,
end=value[match.end(0):]
)
value = '{start}{reference}{end}'.format(
start=value[:match.start(0)],
reference=reference,
end=value[match.end(0):]
)
else:
value = reference

references.add(path)

match = self._reference_pattern.search(value)
if isinstance(value, str):
match = self._reference_pattern.search(value)
else:
match = None

# TODO: auto-convert value type to mimic value getting parsed from file?
return value
except NotConfiguredError as e:
# TODO: error should include key that includes the missing reference
Expand Down

0 comments on commit 10ab57f

Please sign in to comment.