pyx12.map_walker¶
Walk a tree of x12_map nodes. Find the correct node.
If seg indicates a loop has been entered, returns the first child segment node. If seg indicates a segment has been entered, returns the segment node.
Attributes¶
Classes¶
A pending 'mandatory missing' error to be flushed once the loop has moved on. |
|
Walks a map_if tree. Tracks loop/segment counting, missing loop/segment. |
Functions¶
|
|
|
Find the first segment in loop, verify it matches segment |
|
|
|
Debug function - From the start path, pop up then push down to get a path string |
|
Forward walker SegErrors to an err_handler. Each error with a non-None |
Module Contents¶
- class pyx12.map_walker.MissingMandatorySeg[source]¶
Bases:
NamedTupleA pending ‘mandatory missing’ error to be flushed once the loop has moved on.
- seg_data: pyx12.segment.Segment[source]¶
- pyx12.map_walker.pop_to_parent_loop(node)[source]¶
- Parameters:
node (L{node<map_if.x12_node>}) – Loop Node
- Returns:
Closest parent loop node
- Return type:
L{node<map_if.x12_node>}
- pyx12.map_walker.is_first_seg_match2(child, seg_data)[source]¶
Find the first segment in loop, verify it matches segment
- Parameters:
child (L{node<map_if.x12_node>}) – child node
seg_data (L{segment<segment.Segment>}) – Segment object
- Return type:
boolean
- pyx12.map_walker.traverse_path(start_node, pop_loops, push_loops)[source]¶
Debug function - From the start path, pop up then push down to get a path string
- pyx12.map_walker.apply_walk_errors(errh, errors)[source]¶
Forward walker SegErrors to an err_handler. Each error with a non-None map_node triggers errh.add_seg(…) before errh.seg_error(…); map_node=None preserves the existing cursor (used for usage=’N’ emissions that historically attach to the prior segment).
- Parameters:
errh (L{error_handler.err_handler}) – Error handler
errors ([L{SegError}]) – SegErrors accumulated by walk_errors()
- Return type:
None
- class pyx12.map_walker.walk_tree(initialCounts=None)[source]¶
Walks a map_if tree. Tracks loop/segment counting, missing loop/segment.
- Parameters:
initialCounts (collections.abc.Mapping[str | pyx12.path.X12Path, int] | None)
- mandatory_segs_missing: list[MissingMandatorySeg][source]¶
- errors_pending: list[pyx12.error_item.SegError][source]¶
- walk_errors(node, seg_data, seg_count, cur_line, ls_id)[source]¶
Walk the node tree from the starting node to the node matching seg_data. Catch any counting or requirement errors along the way.
Handle required segment/loop missed (not found in seg) Handle found segment = Not used
- Parameters:
- Returns:
The matching x12 segment node, a list of x12 popped loops, a list of x12 pushed loops from the start segment to the found segment, and the list of accumulated SegErrors found along the way.
- Return type:
(L{node<map_if.segment_if>}, [L{node<map_if.loop_if>}], [L{node<map_if.loop_if>}], [L{SegError}])
TODO: check single segment loop repeat
- setCountState(initialCounts=None)[source]¶
- Parameters:
initialCounts (collections.abc.Mapping[str | pyx12.path.X12Path, int] | None)
- Return type:
None