We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent db130c8 commit 54e1359Copy full SHA for 54e1359
pydifact/segmentcollection.py
@@ -317,6 +317,25 @@ def from_segments(
317
318
return cls(reference_number, identifier).add_segments(segments)
319
320
+ @classmethod
321
+ def from_str(cls, string: str) -> "AbstractSegmentsContainer":
322
+ segments = Parser().parse(string)
323
+
324
+ unh = None
325
+ todo = []
326
327
+ for segment in segments:
328
+ if segment.tag == "UNH":
329
+ unh = segment
330
+ continue
331
+ if segment.tag == "UNT":
332
333
+ todo.append(segment)
334
335
+ if not unh:
336
+ raise EDISyntaxError("Missing header in message")
337
+ return cls.from_segments(unh[0], unh[1], todo)
338
339
340
class Interchange(FileSourcableMixin, UNAHandlingMixin, AbstractSegmentsContainer):
341
"""
0 commit comments