Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
else:
parsed[key] = value
# Expand dot notation keys into nested dictionaries.
target = data
parts = key.split(self._period_code)
for part in parts[:-1]:
target = target.setdefault(part, {})
target[parts[-1]] = value
return data
else:
raise lucidity.error.ParseError(
'Path {0!r} did not match template pattern.'.format(path)
)
'''
parsed = {}
match = self._regex.search(path)
if match:
data = {}
for key, value in sorted(match.groupdict().items()):
# Strip number that was added to make group name unique.
key = key[:-3]
# If strict mode enabled for duplicate placeholders, ensure that
# all duplicate placeholders extract the same value.
if self.duplicate_placeholder_mode == self.STRICT:
if key in parsed:
if parsed[key] != value:
raise lucidity.error.ParseError(
'Different extracted values for placeholder '
'{0!r} detected. Values were {1!r} and {2!r}.'
.format(key, parsed[key], value)
)
else:
parsed[key] = value
# Expand dot notation keys into nested dictionaries.
target = data
parts = key.split(self._period_code)
for part in parts[:-1]:
target = target.setdefault(part, {})
target[parts[-1]] = value