@@ -426,16 +426,17 @@ def validate(self):
426
426
427
427
428
428
class Interchange (FileSourcableMixin , UNAHandlingMixin , AbstractSegmentsContainer ):
429
- """
430
- An interchange (started by UNB_ segment, ended by UNZ_ segment)
429
+ """An EDIFACT interchange.
431
430
432
- Optional features of UNB are not yet supported.
431
+ In EDIFACT, the **interchange** is the entire document at the highest level. Except
432
+ for its header (a UNB_ segment) and footer (a UNZ_ segment), it consists of one or
433
+ more **messages**.
433
434
434
- Functional groups are not yet supported.
435
+ :class:`Interchange` currently does not support functional groups and optional
436
+ features of UNB.
435
437
436
- Messages are supported (see :meth:`get_message`), but are
437
- optional: interchange segments can be accessed without going through
438
- messages.
438
+ :class:`Interchange` supports all methods of :class:`AbstractSegmentsContainer` plus
439
+ some additional methods.
439
440
440
441
.. _UNB: https://www.stylusstudio.com/edifact/40100/UNB_.htm
441
442
.. _UNZ: https://www.stylusstudio.com/edifact/40100/UNZ_.htm
@@ -475,11 +476,6 @@ def get_header_segment(self) -> Segment:
475
476
)
476
477
477
478
def get_footer_segment (self ) -> Segment :
478
- """:returns a (UNZ) footer segment with correct segment count and control reference.
479
-
480
- It counts either of the number of messages or, if used, of the number of functional groups
481
- in an interchange (TODO)."""
482
-
483
479
# FIXME: count functional groups (UNG/UNE) correctly
484
480
cnt = 0
485
481
for segment in self .segments :
@@ -495,11 +491,12 @@ def get_footer_segment(self) -> Segment:
495
491
)
496
492
497
493
def get_messages (self ) -> List [Message ]:
498
- """parses a list of messages out of the internal segments .
494
+ """Get list of messages in the interchange .
499
495
500
- :raises EDISyntaxError if constraints are not met (e.g. UNH/UNT both correct)
496
+ Using :meth:`get_messages` is optional; interchange segments can be accessed
497
+ directly without going through messages.
501
498
502
- TODO: parts of this here are better done in the validate() method
499
+ :raises: :class:`EDISyntaxError` if the interchange contents are not correct.
503
500
"""
504
501
505
502
message = None
@@ -531,6 +528,8 @@ def get_messages(self) -> List[Message]:
531
528
raise EDISyntaxError ("UNH segment was not closed with a UNT segment." )
532
529
533
530
def add_message (self , message : Message ) -> "Interchange" :
531
+ """Append a message to the interchange.
532
+ """
534
533
segments = (
535
534
[message .get_header_segment ()]
536
535
+ message .segments
0 commit comments