pyx12 :: segment :: Segment :: Class Segment
[hide private]

Class Segment

source code

object --+
         |
        Segment

Encapsulates a X12 segment. Contains composites.

Instance Methods [hide private]
 
__init__(self, seg_str, seg_term, ele_term, subele_term)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
source code
string
__repr__(self)
repr(x)
source code
 
append(self, val)
Append a composite to the segment
source code
int
__len__(self) source code
string
get_seg_id(self) source code
tuple(ele_idx, subele_idx)
_parse_refdes(self, ref_des)
Format of ref_des:
source code
segment.Composite
get(self, ref_des)
Returns: Element or Composite
source code
 
get_value(self, ref_des) source code
 
get_value_by_ref_des(self, ref_des) source code
 
set(self, ref_des, val)
Set the value of an element or subelement identified by the Reference Designator
source code
 
is_element(self, ref_des) source code
 
is_composite(self, ref_des) source code
int
ele_len(self, ref_des)
Returns: number of sub-elements in an element or composite
source code
 
set_seg_term(self, seg_term) source code
 
set_ele_term(self, ele_term) source code
 
set_subele_term(self, subele_term) source code
string
format(self, seg_term=None, ele_term=None, subele_term=None) source code
 
format_ele_list(self, str_elems, subele_term=None)
Modifies the parameter str_elems Strips trailing empty composites
source code
boolean
is_empty(self) source code
boolean
is_seg_id_valid(self)
Is the Segment identifier the correct length
source code

Inherited from object: __delattr__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __setattr__, __str__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, seg_str, seg_term, ele_term, subele_term)
(Constructor)

source code 

x.__init__(...) initializes x; see x.__class__.__doc__ for signature

Overrides: object.__init__

__repr__(self)
(Representation operator)

source code 

repr(x)

Returns: string
Overrides: object.__repr__

append(self, val)

source code 

Append a composite to the segment

Parameters:
  • val (string) - String value of composite

_parse_refdes(self, ref_des)

source code 

Format of ref_des:

  • a simple element: TST02
  • a composite: TST03 where TST03 is a composite
  • a sub-element: TST03-2
  • or any of the above with the segment ID omitted (02, 03, 03-1)
Parameters:
  • ref_des (string) - X12 Reference Designator
Returns: tuple(ele_idx, subele_idx)
Raises:
  • EngineError - If the given ref_des does not match the segment ID or if the indexes are not valid integers

get(self, ref_des)

source code 
Parameters:
  • ref_des (string) - X12 Reference Designator
Returns: segment.Composite
Element or Composite

get_value(self, ref_des)

source code 
Parameters:
  • ref_des (string) - X12 Reference Designator

get_value_by_ref_des(self, ref_des)

source code 
Parameters:
  • ref_des (string) - X12 Reference Designator

Attention: Deprecated - use get_value

set(self, ref_des, val)

source code 

Set the value of an element or subelement identified by the Reference Designator

Parameters:
  • ref_des (string) - X12 Reference Designator
  • val (string) - New value

is_element(self, ref_des)

source code 
Parameters:
  • ref_des (string) - X12 Reference Designator

is_composite(self, ref_des)

source code 
Parameters:
  • ref_des (string) - X12 Reference Designator

ele_len(self, ref_des)

source code 
Parameters:
  • ref_des (string) - X12 Reference Designator
Returns: int
number of sub-elements in an element or composite

set_seg_term(self, seg_term)

source code 
Parameters:
  • seg_term (string) - Segment terminator

set_ele_term(self, ele_term)

source code 
Parameters:
  • ele_term (string) - Element terminator

set_subele_term(self, subele_term)

source code 
Parameters:
  • subele_term (string) - Sub-element terminator