Skip to content

Commit

Permalink
WIP: Permit nested collectors
Browse files Browse the repository at this point in the history
  • Loading branch information
wwkimball committed May 19, 2019
1 parent d301a4e commit cc91090
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions yamlpath/path.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,11 @@ def __str__(self) -> str:
elif segment_type == PathSegmentTypes.SEARCH:
ppath += str(segment_attrs)
elif segment_type == PathSegmentTypes.COLLECTOR:
ppath += "({})".format(segment_attrs)
subpath = Path(segment_attrs)
print("-\n--\n---\n----\n-----")
print(subpath)
print("-----\n----\n---\n--\n-")
ppath += "({})".format(subpath)

add_sep = True

Expand Down Expand Up @@ -350,7 +354,10 @@ def _parse_path(self, strip_escapes: bool = True) -> deque:
demarc_stack.append(char)
demarc_count += 1
segment_type = PathSegmentTypes.COLLECTOR
continue

# Preserve nested collectors
if subpath_level == 1:
continue

elif subpath_level > 0:
if (
Expand All @@ -361,9 +368,11 @@ def _parse_path(self, strip_escapes: bool = True) -> deque:
subpath_level -= 1
demarc_count -= 1
demarc_stack.pop()
path_segments.append((segment_type, segment_id))
segment_id = ""
continue

if subpath_level < 1:
path_segments.append((segment_type, segment_id))
segment_id = ""
continue

elif demarc_count == 0 and char == "[":
# Array INDEX/SLICE or SEARCH
Expand Down

0 comments on commit cc91090

Please sign in to comment.