edison-parser 0.2__tar.gz → 0.4__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.2
3
+ Version: 0.4
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
@@ -36,16 +36,16 @@ Dynamic: license-file
36
36
  </div>
37
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
39
+ message as a flat stream of segments, it models valid messages as a tree.
40
+ You define the schema once, then parse, validate, or pretty-print
41
41
  messages against that structure.
42
42
 
43
43
  ## Highlights
44
44
 
45
45
  - Define EDIFACT syntax trees directly in Python.
46
+ - Segments can define groups of child segments, which can be conditional, mandatory, or repeatable.
46
47
  - Attach parsing callbacks to the segments you care about.
47
48
  - Select schemas by message version.
48
- - Model conditional, mandatory, and repeatable segments.
49
49
  - Handle escaped EDIFACT separators and EBCDIC control characters.
50
50
  - Properly tokenize segments with specified lengths like `BLB`
51
51
  - Export transition graphs with `pydot`.
@@ -109,16 +109,21 @@ REF+3'
109
109
  UNT+19+1'
110
110
  """
111
111
 
112
+ # Create the parser and parse this EDIFACT message.
113
+ # The `summary` attribute is populated by the callbacks.
112
114
  parser = PIZZAQParser()
113
115
  parser.parse(edi)
116
+ parser.summary # {"MARGARITA": 2, "PESTO": 1}
114
117
 
115
- assert parser.summary == {"MARGARITA": 2, "PESTO": 1}
116
- assert PIZZAQParser.validate(edi)
117
- print(PIZZAQParser.show(edi))
118
+ # Validate and pretty-print the message.
119
+ PIZZAQParser.validate(edi) # True/False
120
+ PIZZAQParser.show(edi) # to print
118
121
  ```
119
122
 
123
+ Here is the output of `PIZZAQParser.show(edi)`.
124
+
120
125
  <div align="center">
121
- <img src="https://raw.githubusercontent.com/AmadeusITGroup/Edison/main/docs/Image.png" width="360" height="360" alt="Edison">
126
+ <img src="https://raw.githubusercontent.com/AmadeusITGroup/Edison/main/docs/Image.png" width="364" alt="Edison">
122
127
  <p><strong>Tree-based structure.</strong></p>
123
128
  </div>
124
129
 
@@ -318,9 +323,12 @@ finishes.
318
323
  <details>
319
324
  <summary>Transition graphs</summary>
320
325
 
321
- `pydot` is installed with Edison. To write PNG files, make sure Graphviz is
322
- available on your system, then call `build_dot_object()` on a `BaseParser`
323
- subclass.
326
+ Internally, Edison builds a directed graph of transitions between segments, when the parser class is created.
327
+ Each node is a specific segment, and each edge is a valid transition to the next segment.
328
+ With this, parsing is just a walk through the graph, and validation is checking if the path exists.
329
+
330
+ You can visualize the transition graph with `build_dot_object()`, which returns a `pydot.Dot` object.
331
+ `pydot` is installed with Edison. To write PNG files, make sure Graphviz is available on your system.
324
332
 
325
333
  ```python
326
334
  from edison import BaseParser
@@ -345,6 +353,12 @@ dot = Parser.build_dot_object()
345
353
  dot.write_png("transitions.png")
346
354
  ```
347
355
 
356
+ Here is the resulting graph for the above schema.
357
+
358
+ <p align="center">
359
+ <img src="https://raw.githubusercontent.com/AmadeusITGroup/Edison/main/docs/transitions.png" alt="pydot">
360
+ </p>
361
+
348
362
  You can pass the same version selector used by parsing, and hide upward links
349
363
  for a simpler tree-like graph:
350
364
 
@@ -11,16 +11,16 @@
11
11
  </div>
12
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
14
+ message as a flat stream of segments, it models valid messages as a tree.
15
+ You define the schema once, then parse, validate, or pretty-print
16
16
  messages against that structure.
17
17
 
18
18
  ## Highlights
19
19
 
20
20
  - Define EDIFACT syntax trees directly in Python.
21
+ - Segments can define groups of child segments, which can be conditional, mandatory, or repeatable.
21
22
  - Attach parsing callbacks to the segments you care about.
22
23
  - Select schemas by message version.
23
- - Model conditional, mandatory, and repeatable segments.
24
24
  - Handle escaped EDIFACT separators and EBCDIC control characters.
25
25
  - Properly tokenize segments with specified lengths like `BLB`
26
26
  - Export transition graphs with `pydot`.
@@ -84,16 +84,21 @@ REF+3'
84
84
  UNT+19+1'
85
85
  """
86
86
 
87
+ # Create the parser and parse this EDIFACT message.
88
+ # The `summary` attribute is populated by the callbacks.
87
89
  parser = PIZZAQParser()
88
90
  parser.parse(edi)
91
+ parser.summary # {"MARGARITA": 2, "PESTO": 1}
89
92
 
90
- assert parser.summary == {"MARGARITA": 2, "PESTO": 1}
91
- assert PIZZAQParser.validate(edi)
92
- print(PIZZAQParser.show(edi))
93
+ # Validate and pretty-print the message.
94
+ PIZZAQParser.validate(edi) # True/False
95
+ PIZZAQParser.show(edi) # to print
93
96
  ```
94
97
 
98
+ Here is the output of `PIZZAQParser.show(edi)`.
99
+
95
100
  <div align="center">
96
- <img src="https://raw.githubusercontent.com/AmadeusITGroup/Edison/main/docs/Image.png" width="360" height="360" alt="Edison">
101
+ <img src="https://raw.githubusercontent.com/AmadeusITGroup/Edison/main/docs/Image.png" width="364" alt="Edison">
97
102
  <p><strong>Tree-based structure.</strong></p>
98
103
  </div>
99
104
 
@@ -293,9 +298,12 @@ finishes.
293
298
  <details>
294
299
  <summary>Transition graphs</summary>
295
300
 
296
- `pydot` is installed with Edison. To write PNG files, make sure Graphviz is
297
- available on your system, then call `build_dot_object()` on a `BaseParser`
298
- subclass.
301
+ Internally, Edison builds a directed graph of transitions between segments, when the parser class is created.
302
+ Each node is a specific segment, and each edge is a valid transition to the next segment.
303
+ With this, parsing is just a walk through the graph, and validation is checking if the path exists.
304
+
305
+ You can visualize the transition graph with `build_dot_object()`, which returns a `pydot.Dot` object.
306
+ `pydot` is installed with Edison. To write PNG files, make sure Graphviz is available on your system.
299
307
 
300
308
  ```python
301
309
  from edison import BaseParser
@@ -320,6 +328,12 @@ dot = Parser.build_dot_object()
320
328
  dot.write_png("transitions.png")
321
329
  ```
322
330
 
331
+ Here is the resulting graph for the above schema.
332
+
333
+ <p align="center">
334
+ <img src="https://raw.githubusercontent.com/AmadeusITGroup/Edison/main/docs/transitions.png" alt="pydot">
335
+ </p>
336
+
323
337
  You can pass the same version selector used by parsing, and hide upward links
324
338
  for a simpler tree-like graph:
325
339
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: edison-parser
3
- Version: 0.2
3
+ Version: 0.4
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
@@ -36,16 +36,16 @@ Dynamic: license-file
36
36
  </div>
37
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
39
+ message as a flat stream of segments, it models valid messages as a tree.
40
+ You define the schema once, then parse, validate, or pretty-print
41
41
  messages against that structure.
42
42
 
43
43
  ## Highlights
44
44
 
45
45
  - Define EDIFACT syntax trees directly in Python.
46
+ - Segments can define groups of child segments, which can be conditional, mandatory, or repeatable.
46
47
  - Attach parsing callbacks to the segments you care about.
47
48
  - Select schemas by message version.
48
- - Model conditional, mandatory, and repeatable segments.
49
49
  - Handle escaped EDIFACT separators and EBCDIC control characters.
50
50
  - Properly tokenize segments with specified lengths like `BLB`
51
51
  - Export transition graphs with `pydot`.
@@ -109,16 +109,21 @@ REF+3'
109
109
  UNT+19+1'
110
110
  """
111
111
 
112
+ # Create the parser and parse this EDIFACT message.
113
+ # The `summary` attribute is populated by the callbacks.
112
114
  parser = PIZZAQParser()
113
115
  parser.parse(edi)
116
+ parser.summary # {"MARGARITA": 2, "PESTO": 1}
114
117
 
115
- assert parser.summary == {"MARGARITA": 2, "PESTO": 1}
116
- assert PIZZAQParser.validate(edi)
117
- print(PIZZAQParser.show(edi))
118
+ # Validate and pretty-print the message.
119
+ PIZZAQParser.validate(edi) # True/False
120
+ PIZZAQParser.show(edi) # to print
118
121
  ```
119
122
 
123
+ Here is the output of `PIZZAQParser.show(edi)`.
124
+
120
125
  <div align="center">
121
- <img src="https://raw.githubusercontent.com/AmadeusITGroup/Edison/main/docs/Image.png" width="360" height="360" alt="Edison">
126
+ <img src="https://raw.githubusercontent.com/AmadeusITGroup/Edison/main/docs/Image.png" width="364" alt="Edison">
122
127
  <p><strong>Tree-based structure.</strong></p>
123
128
  </div>
124
129
 
@@ -318,9 +323,12 @@ finishes.
318
323
  <details>
319
324
  <summary>Transition graphs</summary>
320
325
 
321
- `pydot` is installed with Edison. To write PNG files, make sure Graphviz is
322
- available on your system, then call `build_dot_object()` on a `BaseParser`
323
- subclass.
326
+ Internally, Edison builds a directed graph of transitions between segments, when the parser class is created.
327
+ Each node is a specific segment, and each edge is a valid transition to the next segment.
328
+ With this, parsing is just a walk through the graph, and validation is checking if the path exists.
329
+
330
+ You can visualize the transition graph with `build_dot_object()`, which returns a `pydot.Dot` object.
331
+ `pydot` is installed with Edison. To write PNG files, make sure Graphviz is available on your system.
324
332
 
325
333
  ```python
326
334
  from edison import BaseParser
@@ -345,6 +353,12 @@ dot = Parser.build_dot_object()
345
353
  dot.write_png("transitions.png")
346
354
  ```
347
355
 
356
+ Here is the resulting graph for the above schema.
357
+
358
+ <p align="center">
359
+ <img src="https://raw.githubusercontent.com/AmadeusITGroup/Edison/main/docs/transitions.png" alt="pydot">
360
+ </p>
361
+
348
362
  You can pass the same version selector used by parsing, and hide upward links
349
363
  for a simpler tree-like graph:
350
364
 
@@ -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",
@@ -1,7 +1,7 @@
1
1
  {
2
- "tag": "0.2",
2
+ "tag": "0.4",
3
3
  "distance": 0,
4
- "node": "g82e7d515e1682ec92e09285fb19b461e5d92ceb8",
4
+ "node": "gd5d6d94b1b4dd48881eaa4ea42bee94e6e437a97",
5
5
  "dirty": false,
6
6
  "branch": "HEAD",
7
7
  "node_date": "2026-10-21"
File without changes
File without changes
File without changes
File without changes