예제 #1
0
def buildSegment( name, desc, fieldText ):
    """Convert a block of text to a Segment definition.
    The block of text has one Element defined on each line.
    The Element definition is an Element name, one or more spaces, and the
    element description.
    
    :param name: the name of the segment
    :param desc: the description of the segment
    :param fieldText: a block of text, with one Element name and description per line.
    :returns: :class:`X12.parse.Segment` definition
    """
    theSeg= Segment( name, Properties( desc=desc ) )
    for line in fieldText.splitlines():
        clean= line.strip()
        eltName, space, eltDesc = clean.partition( " " )
        theElt= Element( eltName, Properties( desc=eltDesc ) )
        theSeg.append( theElt )
    return theSeg
예제 #2
0
def buildSegment(name, desc, fieldText):
    """Convert a block of text to a Segment definition.
    The block of text has one Element defined on each line.
    The Element definition is an Element name, one or more spaces, and the
    element description.
    
    :param name: the name of the segment
    :param desc: the description of the segment
    :param fieldText: a block of text, with one Element name and description per line.
    :returns: :class:`X12.parse.Segment` definition
    """
    theSeg = Segment(name, Properties(desc=desc))
    for line in fieldText.splitlines():
        clean = line.strip()
        eltName, space, eltDesc = clean.partition(" ")
        theElt = Element(eltName, Properties(desc=eltDesc))
        theSeg.append(theElt)
    return theSeg
예제 #3
0
def buildSegment(name, desc, fieldText):
    """Convert a block of text to a Segment definition.
    The block of text has one Element defined on each line.
    The Element definition is an Element name, one or more spaces, and the
    element description.

    :param name: the name of the segment
    :param desc: the description of the segment
    :param fieldText: a block of text, with one Element name
        and description per line.
    :returns: :class:`X12.parse.Segment` definition
    """
    segment = Segment(name, Properties(desc=desc))
    for line in filter(None, fieldText.splitlines()):
        name, description = line.strip().split(None, 1)
        element = Element(name, Properties(desc=description, codes=[]))
        segment.append(element)
    return segment
예제 #4
0
def buildSegment(name, desc, fieldText):
    """Convert a block of text to a Segment definition.
    The block of text has one Element defined on each line.
    The Element definition is an Element name, one or more spaces, and the
    element description.

    :param name: the name of the segment
    :param desc: the description of the segment
    :param fieldText: a block of text, with one Element name
        and description per line.
    :returns: :class:`X12.parse.Segment` definition
    """
    segment = Segment(name, Properties(desc=desc))
    for line in filter(None, fieldText.splitlines()):
        name, description = line.strip().split(None, 1)
        element = Element(name, Properties(desc=description, codes=[]))
        segment.append(element)
    return segment