pyx12.map_if¶
Interface to a X12N IG Map.
This package re-exports the classes that previously lived in a single map_if.py module so that import pyx12.map_if and from pyx12.map_if import X keep working unchanged.
Attributes¶
Classes¶
X12 Node Superclass |
|
Composite Node Interface |
|
Element Interface |
|
Loop Interface |
|
Map file interface |
|
Segment Interface |
Functions¶
|
Verifies the segment against the syntax |
|
Create the map object from a file |
Package Contents¶
- pyx12.map_if.is_syntax_valid(seg_data, syn)[source]¶
Verifies the segment against the syntax :param seg_data: data segment instance :type seg_data: L{segment<segment.Segment>} :param syn: list containing the syntax type, and the indices of elements :type syn: list[string] :rtype: tuple(boolean, error string)
- Parameters:
seg_data (pyx12.segment.Segment)
syn (list[Any])
- Return type:
- pyx12.map_if.MAXINT = 2147483647¶
- class pyx12.map_if.x12_node[source]¶
X12 Node Superclass
- get_child_node_by_ordinal(ordinal)[source]¶
Get a child element or composite by the X12 ordinal :param ord: one based element/composite index. Corresponds to the map <seq> element :type ord: int
- x12path¶
- class pyx12.map_if.composite_if(root, parent, elem)[source]¶
Bases:
pyx12.map_if._base.x12_nodeComposite Node Interface
Get the values for this composite :param parent: parent node
- Parameters:
root (pyx12.map_if._root.map_if)
parent (pyx12.map_if._base.x12_node)
- root: pyx12.map_if._root.map_if¶
- parent¶
- path = ''¶
- id¶
- usage¶
- name¶
- is_valid_errors(comp_data)[source]¶
Pure validator: returns (ok, errors) without touching an error handler. Composite-level errors leave map_node unset (=None) so a wrapper iterating with cursor tracking attaches them to whatever cursor was last set — matches the historical behavior of the per-composite errh.ele_error calls.
- Parameters:
comp_data (pyx12.segment.Composite | None)
- Return type:
- class pyx12.map_if.element_if(root, parent, elem)[source]¶
Bases:
pyx12.map_if._base.x12_nodeElement Interface
- Parameters:
parent (pyx12.map_if._base.x12_node) – parent node
root (pyx12.map_if._root.map_if)
- root: pyx12.map_if._root.map_if¶
- rec: re.Pattern[str] | None¶
- children = []¶
- parent¶
- id¶
- usage¶
- name¶
- path¶
- get_parent()[source]¶
- Returns:
ref to parent class instance
- Return type:
pyx12.map_if._base.x12_node | None
- is_valid_errors(elem, type_list=None)[source]¶
Pure validator: returns (ok, errors) without touching an error handler.
- Parameters:
elem (pyx12.segment.Element | pyx12.segment.Composite | None)
- Return type:
- pyx12.map_if.load_map_file(map_file, param, map_path=None)[source]¶
Create the map object from a file
- Parameters:
map_file (string) – filename (basename) of the map xml file to load
map_path (string) – Override directory containing map xml files. If None, uses package resource folder
param (pyx12.params.ParamsBase)
- Return type:
pyx12.map_if
- class pyx12.map_if.loop_if(root, parent, elem)[source]¶
Bases:
pyx12.map_if._base.x12_nodeLoop Interface
- Parameters:
root (pyx12.map_if._root.map_if)
parent (pyx12.map_if._base.x12_node)
- root: pyx12.map_if._root.map_if¶
- parent¶
- id¶
- path¶
- name¶
- usage¶
- childIterator()[source]¶
- Return type:
collections.abc.Iterator[pyx12.map_if._base.x12_node]
- getnodebypath(spath)[source]¶
- Parameters:
spath (string) – remaining path to match
- Returns:
matching node, or None is no match
- Return type:
pyx12.map_if._base.x12_node | None
- getnodebypath2(path_str)[source]¶
Try x12 path
- Parameters:
path_str (string) – remaining path to match
- Returns:
matching node, or None is no match
- Return type:
pyx12.map_if._base.x12_node | None
- get_child_node_by_idx(idx)[source]¶
- Parameters:
idx (int) – zero based
- Return type:
pyx12.map_if._base.x12_node | None
- is_match(seg_data)[source]¶
- Returns:
Is the segment a match to this loop?
- Return type:
boolean
- Parameters:
seg_data (L{segment<segment.Segment>})
- get_child_seg_node(seg_data)[source]¶
Return the child segment matching the segment data
- Parameters:
seg_data (pyx12.segment.Segment)
- Return type:
pyx12.map_if._segment.segment_if | None
- get_child_loop_node(seg_data)[source]¶
Return the child segment matching the segment data
- Parameters:
seg_data (pyx12.segment.Segment)
- Return type:
loop_if | None
- get_counts_list(ct_list)[source]¶
Build a list of (path, ct) of the current node and parents Gets the node counts to apply to another map :param ct_list: List to append to :type ct_list: list[(string, int)]
- loop_segment_iterator()[source]¶
- Return type:
collections.abc.Iterator[pyx12.map_if._base.x12_node]
- class pyx12.map_if.map_if(eroot, param, base_path=None)[source]¶
Bases:
pyx12.map_if._base.x12_nodeMap file interface
- Parameters:
eroot (xml.etree.ElementTree.Element) – ElementTree root
param (pyx12.params.ParamsBase) – map of parameters
base_path (str | None)
- param: pyx12.params.ParamsBase¶
- ext_codes: pyx12.codes.ExternalCodes¶
- data_elements: pyx12.dataele.DataElements¶
- children = None¶
- path = '/'¶
- id¶
- name¶
- get_child_node_by_idx(idx)[source]¶
- Parameters:
idx (int) – zero based
- Return type:
pyx12.map_if._base.x12_node | None
- getnodebypath(spath)[source]¶
- Parameters:
spath (string) – Path string; /1000/2000/2000A/NM102-3
- Return type:
pyx12.map_if._base.x12_node | None
- getnodebypath2(path_str)[source]¶
- Parameters:
path (string) – Path string; /1000/2000/2000A/NM102-3
path_str (str)
- Return type:
pyx12.map_if._base.x12_node | None
- loop_segment_iterator()[source]¶
- Return type:
collections.abc.Iterator[pyx12.map_if._base.x12_node]
- class pyx12.map_if.segment_if(root, parent, elem)[source]¶
Bases:
pyx12.map_if._base.x12_nodeSegment Interface
- Parameters:
parent (pyx12.map_if._base.x12_node) – parent node
root (pyx12.map_if._root.map_if)
- root: pyx12.map_if._root.map_if¶
- parent¶
- id¶
- path¶
- name¶
- usage¶
- get_child_node_by_idx(idx)[source]¶
- Parameters:
idx (int) – zero based
- Return type:
pyx12.map_if._element.element_if | pyx12.map_if._composite.composite_if | None
- get_child_node_by_ordinal(ord)[source]¶
Get a child element or composite by the X12 ordinal :param ord: one based element/composite index. Corresponds to the map <seq> element :type ord: int
- Parameters:
ord (int)
- Return type:
pyx12.map_if._element.element_if | pyx12.map_if._composite.composite_if | None
- getnodebypath2(path_str)[source]¶
Try x12 path
- Parameters:
path_str (string) – remaining path to match
- Returns:
matching node, or None is no match
- Return type:
pyx12.map_if._base.x12_node | None
- is_match(seg)[source]¶
Is data segment given a match to this segment node? :param seg: data segment instance :return: boolean :rtype: boolean
- Parameters:
seg (pyx12.segment.Segment)
- Return type:
- is_match_qual(seg_data, seg_id, qual_code)[source]¶
Is segment id and qualifier a match to this segment node and to this particular segment data? :param seg_data: data segment instance :type seg_data: L{segment<segment.Segment>} :param seg_id: data segment ID :param qual_code: an ID qualifier code :return: (True if a match, qual_code, element_index, subelement_index) :rtype: tuple(boolean, string, int, int)
- guess_unique_key_id_element()[source]¶
Some segments, like REF, DTP, and DTP are duplicated. They are matched using the value of an ID element. Which element to use varies. This function tries to find a good candidate.
- Return type:
pyx12.map_if._element.element_if | None
- get_unique_key_id_element(id_val)[source]¶
Some segments, like REF, DTP, and DTP are duplicated. They are matched using the value of an ID element. Which element to use varies. This function tries to find a good candidate, using a key value
- Parameters:
id_val (str)
- Return type:
pyx12.map_if._element.element_if | None
- is_valid_errors(seg_data)[source]¶
Pure validator parallel to is_valid: returns (ok, errors) without touching an error handler. Seg-level errors (too many elements, too many sub-elements, syntax) leave map_node unset (=None); per-element errors carry map_node from the element validator so a cursor-tracking wrapper can replay add_ele/ele_error in the original order.
- Parameters:
seg_data (pyx12.segment.Segment)
- Return type:
- get_counts_list(ct_list)[source]¶
Build a list of (path, ct) of the current node and parents Gets the node counts to apply to another map :param ct_list: List to append to :type ct_list: list[(string, int)]
- loop_segment_iterator()[source]¶
- Return type:
collections.abc.Iterator[pyx12.map_if._base.x12_node]