edison-parser 0.3__tar.gz → 0.5__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: edison-parser
3
- Version: 0.3
3
+ Version: 0.5
4
4
  Summary: An EDIFACT parser with a real syntax tree.
5
5
  Author-email: Alex Prengère <alex.prengere@gmail.com>
6
6
  License-Expression: MIT
@@ -31,21 +31,23 @@ Dynamic: license-file
31
31
  <a href="https://github.com/AmadeusITGroup/Edison/actions/workflows/ci.yml"><img src="https://github.com/AmadeusITGroup/Edison/actions/workflows/ci.yml/badge.svg" alt="Build"></a>
32
32
  <a href="https://pypi.org/project/edison-parser/"><img src="https://img.shields.io/pypi/v/edison-parser.svg" alt="Version"></a>
33
33
  <a href="https://pypi.org/project/edison-parser/"><img src="https://img.shields.io/pypi/pyversions/edison-parser.svg" alt="Python versions"></a>
34
+ <a href="https://github.com/AmadeusITGroup/Edison/blob/main/LICENSE"><img src="https://img.shields.io/badge/license-MIT-blue.svg" alt="License"></a>
34
35
  <!-- <a href="https://pepy.tech/project/edison-parser"><img src="https://static.pepy.tech/badge/edison-parser" alt="Downloads"></a> -->
35
36
  </p>
36
37
  </div>
37
38
 
38
- Edison is a Python library for parsing EDIFACT messages. Instead of treating a
39
- message as a flat stream of segments, it models valid messages as a tree of
40
- transitions. You define the schema once, then parse, validate, or pretty-print
41
- messages against that structure.
39
+ Edison is a Python library for parsing EDIFACT messages. Instead of treating a message as a flat list of segments,
40
+ it models messages as a syntax tree: segments can define groups of child segments, recursively.
41
+
42
+ You define the syntax tree once, then parse, validate, or pretty-print messages against that structure.
43
+ It works by converting the syntax tree to a state machine of possible transitions between segments.
42
44
 
43
45
  ## Highlights
44
46
 
45
47
  - Define EDIFACT syntax trees directly in Python.
48
+ - Segments can define groups of child segments, which can be conditional, mandatory, or repeatable.
46
49
  - Attach parsing callbacks to the segments you care about.
47
- - Select schemas by message version.
48
- - Model conditional, mandatory, and repeatable segments.
50
+ - Select syntax tree by message version.
49
51
  - Handle escaped EDIFACT separators and EBCDIC control characters.
50
52
  - Properly tokenize segments with specified lengths like `BLB`
51
53
  - Export transition graphs with `pydot`.
@@ -72,12 +74,12 @@ class PIZZAQParser(BaseParser):
72
74
  (0, 0): [
73
75
  ["UNH"],
74
76
  ["CVR"],
75
- ["REF"],
77
+ ["REF"], # one type of REF segment
76
78
  [
77
79
  "PIZ",
78
80
  [
79
81
  ["TYP", [], "parse_typ"],
80
- ["REF", [], "parse_ref"],
82
+ ["REF", [], "parse_ref"], # another type of REF segment
81
83
  ],
82
84
  ],
83
85
  ["UNT"],
@@ -89,9 +91,12 @@ class PIZZAQParser(BaseParser):
89
91
  self.pizza = None
90
92
 
91
93
  def parse_typ(self, segment: str):
94
+ # Executed when the parser sees a "TYP" segment. The segment is passed as a string.
92
95
  self.pizza = segment[4:]
93
96
 
94
97
  def parse_ref(self, segment: str):
98
+ # Executed when the parser sees a "REF" segment. The segment is passed as a string.
99
+ # Only executed on the "second" type of "REF" segment!
95
100
  refs = segment[4:].split("*")
96
101
  self.summary[self.pizza] = len(refs)
97
102
 
@@ -323,9 +328,12 @@ finishes.
323
328
  <details>
324
329
  <summary>Transition graphs</summary>
325
330
 
326
- `pydot` is installed with Edison. To write PNG files, make sure Graphviz is
327
- available on your system, then call `build_dot_object()` on a `BaseParser`
328
- subclass.
331
+ Internally, Edison builds a directed graph of transitions between segments, when the parser class is created.
332
+ Each node is a specific segment, and each edge is a valid transition to the next segment.
333
+ With this, parsing is just a walk through the graph, and validation is checking if the path exists.
334
+
335
+ You can visualize the transition graph with `build_dot_object()`, which returns a `pydot.Dot` object.
336
+ `pydot` is installed with Edison. To write PNG files, make sure Graphviz is available on your system.
329
337
 
330
338
  ```python
331
339
  from edison import BaseParser
@@ -350,6 +358,12 @@ dot = Parser.build_dot_object()
350
358
  dot.write_png("transitions.png")
351
359
  ```
352
360
 
361
+ Here is the resulting graph for the above schema.
362
+
363
+ <p align="center">
364
+ <img src="https://raw.githubusercontent.com/AmadeusITGroup/Edison/main/docs/transitions.png" alt="pydot">
365
+ </p>
366
+
353
367
  You can pass the same version selector used by parsing, and hide upward links
354
368
  for a simpler tree-like graph:
355
369
 
@@ -6,21 +6,23 @@
6
6
  <a href="https://github.com/AmadeusITGroup/Edison/actions/workflows/ci.yml"><img src="https://github.com/AmadeusITGroup/Edison/actions/workflows/ci.yml/badge.svg" alt="Build"></a>
7
7
  <a href="https://pypi.org/project/edison-parser/"><img src="https://img.shields.io/pypi/v/edison-parser.svg" alt="Version"></a>
8
8
  <a href="https://pypi.org/project/edison-parser/"><img src="https://img.shields.io/pypi/pyversions/edison-parser.svg" alt="Python versions"></a>
9
+ <a href="https://github.com/AmadeusITGroup/Edison/blob/main/LICENSE"><img src="https://img.shields.io/badge/license-MIT-blue.svg" alt="License"></a>
9
10
  <!-- <a href="https://pepy.tech/project/edison-parser"><img src="https://static.pepy.tech/badge/edison-parser" alt="Downloads"></a> -->
10
11
  </p>
11
12
  </div>
12
13
 
13
- Edison is a Python library for parsing EDIFACT messages. Instead of treating a
14
- message as a flat stream of segments, it models valid messages as a tree of
15
- transitions. You define the schema once, then parse, validate, or pretty-print
16
- messages against that structure.
14
+ Edison is a Python library for parsing EDIFACT messages. Instead of treating a message as a flat list of segments,
15
+ it models messages as a syntax tree: segments can define groups of child segments, recursively.
16
+
17
+ You define the syntax tree once, then parse, validate, or pretty-print messages against that structure.
18
+ It works by converting the syntax tree to a state machine of possible transitions between segments.
17
19
 
18
20
  ## Highlights
19
21
 
20
22
  - Define EDIFACT syntax trees directly in Python.
23
+ - Segments can define groups of child segments, which can be conditional, mandatory, or repeatable.
21
24
  - Attach parsing callbacks to the segments you care about.
22
- - Select schemas by message version.
23
- - Model conditional, mandatory, and repeatable segments.
25
+ - Select syntax tree by message version.
24
26
  - Handle escaped EDIFACT separators and EBCDIC control characters.
25
27
  - Properly tokenize segments with specified lengths like `BLB`
26
28
  - Export transition graphs with `pydot`.
@@ -47,12 +49,12 @@ class PIZZAQParser(BaseParser):
47
49
  (0, 0): [
48
50
  ["UNH"],
49
51
  ["CVR"],
50
- ["REF"],
52
+ ["REF"], # one type of REF segment
51
53
  [
52
54
  "PIZ",
53
55
  [
54
56
  ["TYP", [], "parse_typ"],
55
- ["REF", [], "parse_ref"],
57
+ ["REF", [], "parse_ref"], # another type of REF segment
56
58
  ],
57
59
  ],
58
60
  ["UNT"],
@@ -64,9 +66,12 @@ class PIZZAQParser(BaseParser):
64
66
  self.pizza = None
65
67
 
66
68
  def parse_typ(self, segment: str):
69
+ # Executed when the parser sees a "TYP" segment. The segment is passed as a string.
67
70
  self.pizza = segment[4:]
68
71
 
69
72
  def parse_ref(self, segment: str):
73
+ # Executed when the parser sees a "REF" segment. The segment is passed as a string.
74
+ # Only executed on the "second" type of "REF" segment!
70
75
  refs = segment[4:].split("*")
71
76
  self.summary[self.pizza] = len(refs)
72
77
 
@@ -298,9 +303,12 @@ finishes.
298
303
  <details>
299
304
  <summary>Transition graphs</summary>
300
305
 
301
- `pydot` is installed with Edison. To write PNG files, make sure Graphviz is
302
- available on your system, then call `build_dot_object()` on a `BaseParser`
303
- subclass.
306
+ Internally, Edison builds a directed graph of transitions between segments, when the parser class is created.
307
+ Each node is a specific segment, and each edge is a valid transition to the next segment.
308
+ With this, parsing is just a walk through the graph, and validation is checking if the path exists.
309
+
310
+ You can visualize the transition graph with `build_dot_object()`, which returns a `pydot.Dot` object.
311
+ `pydot` is installed with Edison. To write PNG files, make sure Graphviz is available on your system.
304
312
 
305
313
  ```python
306
314
  from edison import BaseParser
@@ -325,6 +333,12 @@ dot = Parser.build_dot_object()
325
333
  dot.write_png("transitions.png")
326
334
  ```
327
335
 
336
+ Here is the resulting graph for the above schema.
337
+
338
+ <p align="center">
339
+ <img src="https://raw.githubusercontent.com/AmadeusITGroup/Edison/main/docs/transitions.png" alt="pydot">
340
+ </p>
341
+
328
342
  You can pass the same version selector used by parsing, and hide upward links
329
343
  for a simpler tree-like graph:
330
344
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: edison-parser
3
- Version: 0.3
3
+ Version: 0.5
4
4
  Summary: An EDIFACT parser with a real syntax tree.
5
5
  Author-email: Alex Prengère <alex.prengere@gmail.com>
6
6
  License-Expression: MIT
@@ -31,21 +31,23 @@ Dynamic: license-file
31
31
  <a href="https://github.com/AmadeusITGroup/Edison/actions/workflows/ci.yml"><img src="https://github.com/AmadeusITGroup/Edison/actions/workflows/ci.yml/badge.svg" alt="Build"></a>
32
32
  <a href="https://pypi.org/project/edison-parser/"><img src="https://img.shields.io/pypi/v/edison-parser.svg" alt="Version"></a>
33
33
  <a href="https://pypi.org/project/edison-parser/"><img src="https://img.shields.io/pypi/pyversions/edison-parser.svg" alt="Python versions"></a>
34
+ <a href="https://github.com/AmadeusITGroup/Edison/blob/main/LICENSE"><img src="https://img.shields.io/badge/license-MIT-blue.svg" alt="License"></a>
34
35
  <!-- <a href="https://pepy.tech/project/edison-parser"><img src="https://static.pepy.tech/badge/edison-parser" alt="Downloads"></a> -->
35
36
  </p>
36
37
  </div>
37
38
 
38
- Edison is a Python library for parsing EDIFACT messages. Instead of treating a
39
- message as a flat stream of segments, it models valid messages as a tree of
40
- transitions. You define the schema once, then parse, validate, or pretty-print
41
- messages against that structure.
39
+ Edison is a Python library for parsing EDIFACT messages. Instead of treating a message as a flat list of segments,
40
+ it models messages as a syntax tree: segments can define groups of child segments, recursively.
41
+
42
+ You define the syntax tree once, then parse, validate, or pretty-print messages against that structure.
43
+ It works by converting the syntax tree to a state machine of possible transitions between segments.
42
44
 
43
45
  ## Highlights
44
46
 
45
47
  - Define EDIFACT syntax trees directly in Python.
48
+ - Segments can define groups of child segments, which can be conditional, mandatory, or repeatable.
46
49
  - Attach parsing callbacks to the segments you care about.
47
- - Select schemas by message version.
48
- - Model conditional, mandatory, and repeatable segments.
50
+ - Select syntax tree by message version.
49
51
  - Handle escaped EDIFACT separators and EBCDIC control characters.
50
52
  - Properly tokenize segments with specified lengths like `BLB`
51
53
  - Export transition graphs with `pydot`.
@@ -72,12 +74,12 @@ class PIZZAQParser(BaseParser):
72
74
  (0, 0): [
73
75
  ["UNH"],
74
76
  ["CVR"],
75
- ["REF"],
77
+ ["REF"], # one type of REF segment
76
78
  [
77
79
  "PIZ",
78
80
  [
79
81
  ["TYP", [], "parse_typ"],
80
- ["REF", [], "parse_ref"],
82
+ ["REF", [], "parse_ref"], # another type of REF segment
81
83
  ],
82
84
  ],
83
85
  ["UNT"],
@@ -89,9 +91,12 @@ class PIZZAQParser(BaseParser):
89
91
  self.pizza = None
90
92
 
91
93
  def parse_typ(self, segment: str):
94
+ # Executed when the parser sees a "TYP" segment. The segment is passed as a string.
92
95
  self.pizza = segment[4:]
93
96
 
94
97
  def parse_ref(self, segment: str):
98
+ # Executed when the parser sees a "REF" segment. The segment is passed as a string.
99
+ # Only executed on the "second" type of "REF" segment!
95
100
  refs = segment[4:].split("*")
96
101
  self.summary[self.pizza] = len(refs)
97
102
 
@@ -323,9 +328,12 @@ finishes.
323
328
  <details>
324
329
  <summary>Transition graphs</summary>
325
330
 
326
- `pydot` is installed with Edison. To write PNG files, make sure Graphviz is
327
- available on your system, then call `build_dot_object()` on a `BaseParser`
328
- subclass.
331
+ Internally, Edison builds a directed graph of transitions between segments, when the parser class is created.
332
+ Each node is a specific segment, and each edge is a valid transition to the next segment.
333
+ With this, parsing is just a walk through the graph, and validation is checking if the path exists.
334
+
335
+ You can visualize the transition graph with `build_dot_object()`, which returns a `pydot.Dot` object.
336
+ `pydot` is installed with Edison. To write PNG files, make sure Graphviz is available on your system.
329
337
 
330
338
  ```python
331
339
  from edison import BaseParser
@@ -350,6 +358,12 @@ dot = Parser.build_dot_object()
350
358
  dot.write_png("transitions.png")
351
359
  ```
352
360
 
361
+ Here is the resulting graph for the above schema.
362
+
363
+ <p align="center">
364
+ <img src="https://raw.githubusercontent.com/AmadeusITGroup/Edison/main/docs/transitions.png" alt="pydot">
365
+ </p>
366
+
353
367
  You can pass the same version selector used by parsing, and hide upward links
354
368
  for a simpler tree-like graph:
355
369
 
@@ -16,6 +16,7 @@
16
16
  "README.md",
17
17
  "docs/Image.png",
18
18
  "docs/edison.png",
19
+ "docs/transitions.png",
19
20
  "pyproject.toml",
20
21
  "src/edison/__init__.py",
21
22
  "src/edison/envelope.py",
@@ -0,0 +1,8 @@
1
+ {
2
+ "tag": "0.5",
3
+ "distance": 0,
4
+ "node": "g6322c36918168e89c37bd4a1872c622539a6ac58",
5
+ "dirty": false,
6
+ "branch": "HEAD",
7
+ "node_date": "2026-10-22"
8
+ }
@@ -1,8 +0,0 @@
1
- {
2
- "tag": "0.3",
3
- "distance": 0,
4
- "node": "g903d48fb0f27f07def1b2ff3044dee024c863b68",
5
- "dirty": false,
6
- "branch": "HEAD",
7
- "node_date": "2026-10-21"
8
- }
File without changes
File without changes
File without changes
File without changes