nerdocs / pydifact

A python EDIFACT library.
MIT License
156 stars 45 forks source link

Parser: enable configurable control characters and Parser reuse #59

Closed mj0nez closed 1 year ago

mj0nez commented 1 year ago

PR for #58

mj0nez commented 1 year ago

A short summery of the introduced changes

parser = Parser(characters=Characters.from_str("UNA:+.? '"))

edi = (
    "UNB+UNOC:1+1234+3333+200102:2212+42'"
    "UNH+42z42+PAORES:93:1:IA'"
    "UNT+2+42z42'"
    "UNZ+1+42'"
)

interchange = Interchange.from_str(edi, parser=parser)

assert edi.characters.decimal_point == "."

Creating an Interchange without a parser is still possible, but uses the pydifact default character set:

interchange = Interchange.from_str(edi)

assert edi.characters.decimal_point == ","