Skip to content

Commit

Permalink
Merge pull request #139 from Luffbee/master
Browse files Browse the repository at this point in the history
Optimize _expand_named_fields
  • Loading branch information
wimglenn authored Nov 9, 2023
2 parents 010d635 + 71ee32b commit 286bcb1
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,11 @@ def _expand_named_fields(self, named_fields):
result = {}
for field, value in named_fields.items():
# split 'aaa[bbb][ccc]...' into 'aaa' and '[bbb][ccc]...'
basename, subkeys = re.match(r'([^\[]+)(.*)', field).groups()
n = field.find('[')
if n == -1:
basename, subkeys = field, ''
else:
basename, subkeys = field[:n], field[n:]

# create nested dictionaries {'aaa': {'bbb': {'ccc': ...}}}
d = result
Expand Down

0 comments on commit 286bcb1

Please sign in to comment.