pydpm_xl 0.2.8__tar.gz → 0.2.9__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.
- {pydpm_xl-0.2.8/pydpm_xl.egg-info → pydpm_xl-0.2.9}/PKG-INFO +12 -13
- {pydpm_xl-0.2.8 → pydpm_xl-0.2.9}/README.md +11 -12
- {pydpm_xl-0.2.8 → pydpm_xl-0.2.9}/py_dpm/__init__.py +1 -1
- {pydpm_xl-0.2.8 → pydpm_xl-0.2.9}/py_dpm/api/__init__.py +3 -9
- {pydpm_xl-0.2.8 → pydpm_xl-0.2.9}/py_dpm/api/dpm_xl/__init__.py +3 -12
- {pydpm_xl-0.2.8 → pydpm_xl-0.2.9}/py_dpm/api/dpm_xl/ast_generator.py +9 -9
- pydpm_xl-0.2.9/py_dpm/api/dpm_xl/complete_ast.py +95 -0
- {pydpm_xl-0.2.8 → pydpm_xl-0.2.9}/py_dpm/dpm_xl/utils/serialization.py +15 -0
- {pydpm_xl-0.2.8 → pydpm_xl-0.2.9/pydpm_xl.egg-info}/PKG-INFO +12 -13
- {pydpm_xl-0.2.8 → pydpm_xl-0.2.9}/pyproject.toml +2 -2
- pydpm_xl-0.2.8/py_dpm/api/dpm_xl/complete_ast.py +0 -208
- {pydpm_xl-0.2.8 → pydpm_xl-0.2.9}/LICENSE +0 -0
- {pydpm_xl-0.2.8 → pydpm_xl-0.2.9}/py_dpm/api/dpm/__init__.py +0 -0
- {pydpm_xl-0.2.8 → pydpm_xl-0.2.9}/py_dpm/api/dpm/data_dictionary.py +0 -0
- {pydpm_xl-0.2.8 → pydpm_xl-0.2.9}/py_dpm/api/dpm/explorer.py +0 -0
- {pydpm_xl-0.2.8 → pydpm_xl-0.2.9}/py_dpm/api/dpm/hierarchical_queries.py +0 -0
- {pydpm_xl-0.2.8 → pydpm_xl-0.2.9}/py_dpm/api/dpm/instance.py +0 -0
- {pydpm_xl-0.2.8 → pydpm_xl-0.2.9}/py_dpm/api/dpm/migration.py +0 -0
- {pydpm_xl-0.2.8 → pydpm_xl-0.2.9}/py_dpm/api/dpm_xl/operation_scopes.py +0 -0
- {pydpm_xl-0.2.8 → pydpm_xl-0.2.9}/py_dpm/api/dpm_xl/semantic.py +0 -0
- {pydpm_xl-0.2.8 → pydpm_xl-0.2.9}/py_dpm/api/dpm_xl/syntax.py +0 -0
- {pydpm_xl-0.2.8 → pydpm_xl-0.2.9}/py_dpm/cli/__init__.py +0 -0
- {pydpm_xl-0.2.8 → pydpm_xl-0.2.9}/py_dpm/cli/commands/__init__.py +0 -0
- {pydpm_xl-0.2.8 → pydpm_xl-0.2.9}/py_dpm/cli/main.py +0 -0
- {pydpm_xl-0.2.8 → pydpm_xl-0.2.9}/py_dpm/dpm/__init__.py +0 -0
- {pydpm_xl-0.2.8 → pydpm_xl-0.2.9}/py_dpm/dpm/migration.py +0 -0
- {pydpm_xl-0.2.8 → pydpm_xl-0.2.9}/py_dpm/dpm/models.py +0 -0
- {pydpm_xl-0.2.8 → pydpm_xl-0.2.9}/py_dpm/dpm/queries/base.py +0 -0
- {pydpm_xl-0.2.8 → pydpm_xl-0.2.9}/py_dpm/dpm/queries/basic_objects.py +0 -0
- {pydpm_xl-0.2.8 → pydpm_xl-0.2.9}/py_dpm/dpm/queries/explorer_queries.py +0 -0
- {pydpm_xl-0.2.8 → pydpm_xl-0.2.9}/py_dpm/dpm/queries/filters.py +0 -0
- {pydpm_xl-0.2.8 → pydpm_xl-0.2.9}/py_dpm/dpm/queries/glossary.py +0 -0
- {pydpm_xl-0.2.8 → pydpm_xl-0.2.9}/py_dpm/dpm/queries/hierarchical_queries.py +0 -0
- {pydpm_xl-0.2.8 → pydpm_xl-0.2.9}/py_dpm/dpm/queries/tables.py +0 -0
- {pydpm_xl-0.2.8 → pydpm_xl-0.2.9}/py_dpm/dpm/utils.py +0 -0
- {pydpm_xl-0.2.8 → pydpm_xl-0.2.9}/py_dpm/dpm_xl/__init__.py +0 -0
- {pydpm_xl-0.2.8 → pydpm_xl-0.2.9}/py_dpm/dpm_xl/ast/__init__.py +0 -0
- {pydpm_xl-0.2.8 → pydpm_xl-0.2.9}/py_dpm/dpm_xl/ast/constructor.py +0 -0
- {pydpm_xl-0.2.8 → pydpm_xl-0.2.9}/py_dpm/dpm_xl/ast/ml_generation.py +0 -0
- {pydpm_xl-0.2.8 → pydpm_xl-0.2.9}/py_dpm/dpm_xl/ast/module_analyzer.py +0 -0
- {pydpm_xl-0.2.8 → pydpm_xl-0.2.9}/py_dpm/dpm_xl/ast/module_dependencies.py +0 -0
- {pydpm_xl-0.2.8 → pydpm_xl-0.2.9}/py_dpm/dpm_xl/ast/nodes.py +0 -0
- {pydpm_xl-0.2.8 → pydpm_xl-0.2.9}/py_dpm/dpm_xl/ast/operands.py +0 -0
- {pydpm_xl-0.2.8 → pydpm_xl-0.2.9}/py_dpm/dpm_xl/ast/template.py +0 -0
- {pydpm_xl-0.2.8 → pydpm_xl-0.2.9}/py_dpm/dpm_xl/ast/visitor.py +0 -0
- {pydpm_xl-0.2.8 → pydpm_xl-0.2.9}/py_dpm/dpm_xl/ast/where_clause.py +0 -0
- {pydpm_xl-0.2.8 → pydpm_xl-0.2.9}/py_dpm/dpm_xl/grammar/__init__.py +0 -0
- {pydpm_xl-0.2.8 → pydpm_xl-0.2.9}/py_dpm/dpm_xl/grammar/generated/__init__.py +0 -0
- {pydpm_xl-0.2.8 → pydpm_xl-0.2.9}/py_dpm/dpm_xl/grammar/generated/dpm_xlLexer.interp +0 -0
- {pydpm_xl-0.2.8 → pydpm_xl-0.2.9}/py_dpm/dpm_xl/grammar/generated/dpm_xlLexer.py +0 -0
- {pydpm_xl-0.2.8 → pydpm_xl-0.2.9}/py_dpm/dpm_xl/grammar/generated/dpm_xlLexer.tokens +0 -0
- {pydpm_xl-0.2.8 → pydpm_xl-0.2.9}/py_dpm/dpm_xl/grammar/generated/dpm_xlParser.interp +0 -0
- {pydpm_xl-0.2.8 → pydpm_xl-0.2.9}/py_dpm/dpm_xl/grammar/generated/dpm_xlParser.py +0 -0
- {pydpm_xl-0.2.8 → pydpm_xl-0.2.9}/py_dpm/dpm_xl/grammar/generated/dpm_xlParser.tokens +0 -0
- {pydpm_xl-0.2.8 → pydpm_xl-0.2.9}/py_dpm/dpm_xl/grammar/generated/dpm_xlParserListener.py +0 -0
- {pydpm_xl-0.2.8 → pydpm_xl-0.2.9}/py_dpm/dpm_xl/grammar/generated/dpm_xlParserVisitor.py +0 -0
- {pydpm_xl-0.2.8 → pydpm_xl-0.2.9}/py_dpm/dpm_xl/grammar/generated/listeners.py +0 -0
- {pydpm_xl-0.2.8 → pydpm_xl-0.2.9}/py_dpm/dpm_xl/operators/__init__.py +0 -0
- {pydpm_xl-0.2.8 → pydpm_xl-0.2.9}/py_dpm/dpm_xl/operators/aggregate.py +0 -0
- {pydpm_xl-0.2.8 → pydpm_xl-0.2.9}/py_dpm/dpm_xl/operators/arithmetic.py +0 -0
- {pydpm_xl-0.2.8 → pydpm_xl-0.2.9}/py_dpm/dpm_xl/operators/base.py +0 -0
- {pydpm_xl-0.2.8 → pydpm_xl-0.2.9}/py_dpm/dpm_xl/operators/boolean.py +0 -0
- {pydpm_xl-0.2.8 → pydpm_xl-0.2.9}/py_dpm/dpm_xl/operators/clause.py +0 -0
- {pydpm_xl-0.2.8 → pydpm_xl-0.2.9}/py_dpm/dpm_xl/operators/comparison.py +0 -0
- {pydpm_xl-0.2.8 → pydpm_xl-0.2.9}/py_dpm/dpm_xl/operators/conditional.py +0 -0
- {pydpm_xl-0.2.8 → pydpm_xl-0.2.9}/py_dpm/dpm_xl/operators/string.py +0 -0
- {pydpm_xl-0.2.8 → pydpm_xl-0.2.9}/py_dpm/dpm_xl/operators/time.py +0 -0
- {pydpm_xl-0.2.8 → pydpm_xl-0.2.9}/py_dpm/dpm_xl/semantic_analyzer.py +0 -0
- {pydpm_xl-0.2.8 → pydpm_xl-0.2.9}/py_dpm/dpm_xl/symbols.py +0 -0
- {pydpm_xl-0.2.8 → pydpm_xl-0.2.9}/py_dpm/dpm_xl/types/__init__.py +0 -0
- {pydpm_xl-0.2.8 → pydpm_xl-0.2.9}/py_dpm/dpm_xl/types/promotion.py +0 -0
- {pydpm_xl-0.2.8 → pydpm_xl-0.2.9}/py_dpm/dpm_xl/types/scalar.py +0 -0
- {pydpm_xl-0.2.8 → pydpm_xl-0.2.9}/py_dpm/dpm_xl/types/time.py +0 -0
- {pydpm_xl-0.2.8 → pydpm_xl-0.2.9}/py_dpm/dpm_xl/utils/__init__.py +0 -0
- {pydpm_xl-0.2.8 → pydpm_xl-0.2.9}/py_dpm/dpm_xl/utils/data_handlers.py +0 -0
- {pydpm_xl-0.2.8 → pydpm_xl-0.2.9}/py_dpm/dpm_xl/utils/operands_mapping.py +0 -0
- {pydpm_xl-0.2.8 → pydpm_xl-0.2.9}/py_dpm/dpm_xl/utils/operator_mapping.py +0 -0
- {pydpm_xl-0.2.8 → pydpm_xl-0.2.9}/py_dpm/dpm_xl/utils/scopes_calculator.py +0 -0
- {pydpm_xl-0.2.8 → pydpm_xl-0.2.9}/py_dpm/dpm_xl/utils/tokens.py +0 -0
- {pydpm_xl-0.2.8 → pydpm_xl-0.2.9}/py_dpm/exceptions/__init__.py +0 -0
- {pydpm_xl-0.2.8 → pydpm_xl-0.2.9}/py_dpm/exceptions/exceptions.py +0 -0
- {pydpm_xl-0.2.8 → pydpm_xl-0.2.9}/py_dpm/exceptions/messages.py +0 -0
- {pydpm_xl-0.2.8 → pydpm_xl-0.2.9}/py_dpm/instance/__init__.py +0 -0
- {pydpm_xl-0.2.8 → pydpm_xl-0.2.9}/py_dpm/instance/instance.py +0 -0
- {pydpm_xl-0.2.8 → pydpm_xl-0.2.9}/pydpm_xl.egg-info/SOURCES.txt +0 -0
- {pydpm_xl-0.2.8 → pydpm_xl-0.2.9}/pydpm_xl.egg-info/dependency_links.txt +0 -0
- {pydpm_xl-0.2.8 → pydpm_xl-0.2.9}/pydpm_xl.egg-info/entry_points.txt +0 -0
- {pydpm_xl-0.2.8 → pydpm_xl-0.2.9}/pydpm_xl.egg-info/requires.txt +0 -0
- {pydpm_xl-0.2.8 → pydpm_xl-0.2.9}/pydpm_xl.egg-info/top_level.txt +0 -0
- {pydpm_xl-0.2.8 → pydpm_xl-0.2.9}/setup.cfg +0 -0
- {pydpm_xl-0.2.8 → pydpm_xl-0.2.9}/tests/test_cli_semantic.py +0 -0
- {pydpm_xl-0.2.8 → pydpm_xl-0.2.9}/tests/test_data_dictionary_releases.py +0 -0
- {pydpm_xl-0.2.8 → pydpm_xl-0.2.9}/tests/test_db_connection_handling.py +0 -0
- {pydpm_xl-0.2.8 → pydpm_xl-0.2.9}/tests/test_get_table_details.py +0 -0
- {pydpm_xl-0.2.8 → pydpm_xl-0.2.9}/tests/test_get_tables_date_filter.py +0 -0
- {pydpm_xl-0.2.8 → pydpm_xl-0.2.9}/tests/test_get_tables_release_code.py +0 -0
- {pydpm_xl-0.2.8 → pydpm_xl-0.2.9}/tests/test_hierarchical_query.py +0 -0
- {pydpm_xl-0.2.8 → pydpm_xl-0.2.9}/tests/test_query_refactor.py +0 -0
- {pydpm_xl-0.2.8 → pydpm_xl-0.2.9}/tests/test_release_filters_semantic.py +0 -0
- {pydpm_xl-0.2.8 → pydpm_xl-0.2.9}/tests/test_semantic_release.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pydpm_xl
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.9
|
|
4
4
|
Summary: Python library for DPM-XL data processing and analysis
|
|
5
5
|
Author-email: "MeaningfulData S.L." <info@meaningfuldata.eu>
|
|
6
6
|
License: GPL-3.0-or-later
|
|
@@ -210,22 +210,21 @@ else:
|
|
|
210
210
|
print(f"Error: {result.error}")
|
|
211
211
|
```
|
|
212
212
|
|
|
213
|
-
####
|
|
213
|
+
#### Validations Script Generation
|
|
214
214
|
|
|
215
215
|
```python
|
|
216
|
-
from py_dpm.api import
|
|
216
|
+
from py_dpm.api import generate_validations_script
|
|
217
217
|
|
|
218
|
-
# Generate
|
|
219
|
-
result =
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
218
|
+
# Generate engine-ready validations script
|
|
219
|
+
result = generate_validations_script(
|
|
220
|
+
"{tT_01.00, r0010, c0010}",
|
|
221
|
+
database_path="data.db",
|
|
222
|
+
release_code="4.2"
|
|
223
|
+
)
|
|
224
|
+
if result["success"]:
|
|
225
|
+
print(f"Enriched AST: {result['enriched_ast']}")
|
|
223
226
|
else:
|
|
224
|
-
print(f"
|
|
225
|
-
|
|
226
|
-
# Generate enriched AST (ready for execution engine)
|
|
227
|
-
enriched = generate_enriched_ast("{tT_01.00, r0010, c0010}", release_id=123)
|
|
228
|
-
print(f"Enriched AST: {enriched}")
|
|
227
|
+
print(f"Error: {result['error']}")
|
|
229
228
|
```
|
|
230
229
|
|
|
231
230
|
#### Migration
|
|
@@ -177,22 +177,21 @@ else:
|
|
|
177
177
|
print(f"Error: {result.error}")
|
|
178
178
|
```
|
|
179
179
|
|
|
180
|
-
####
|
|
180
|
+
#### Validations Script Generation
|
|
181
181
|
|
|
182
182
|
```python
|
|
183
|
-
from py_dpm.api import
|
|
183
|
+
from py_dpm.api import generate_validations_script
|
|
184
184
|
|
|
185
|
-
# Generate
|
|
186
|
-
result =
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
185
|
+
# Generate engine-ready validations script
|
|
186
|
+
result = generate_validations_script(
|
|
187
|
+
"{tT_01.00, r0010, c0010}",
|
|
188
|
+
database_path="data.db",
|
|
189
|
+
release_code="4.2"
|
|
190
|
+
)
|
|
191
|
+
if result["success"]:
|
|
192
|
+
print(f"Enriched AST: {result['enriched_ast']}")
|
|
190
193
|
else:
|
|
191
|
-
print(f"
|
|
192
|
-
|
|
193
|
-
# Generate enriched AST (ready for execution engine)
|
|
194
|
-
enriched = generate_enriched_ast("{tT_01.00, r0010, c0010}", release_id=123)
|
|
195
|
-
print(f"Enriched AST: {enriched}")
|
|
194
|
+
print(f"Error: {result['error']}")
|
|
196
195
|
```
|
|
197
196
|
|
|
198
197
|
#### Migration
|
|
@@ -41,7 +41,7 @@ Available packages:
|
|
|
41
41
|
- pydpm.api: Main APIs for migration, syntax, and semantic analysis
|
|
42
42
|
"""
|
|
43
43
|
|
|
44
|
-
__version__ = "0.2.
|
|
44
|
+
__version__ = "0.2.9"
|
|
45
45
|
__author__ = "MeaningfulData S.L."
|
|
46
46
|
__email__ = "info@meaningfuldata.eu"
|
|
47
47
|
__license__ = "GPL-3.0-or-later"
|
|
@@ -11,10 +11,7 @@ from py_dpm.api.dpm_xl import (
|
|
|
11
11
|
SemanticAPI,
|
|
12
12
|
ASTGeneratorAPI,
|
|
13
13
|
OperationScopesAPI,
|
|
14
|
-
|
|
15
|
-
generate_enriched_ast,
|
|
16
|
-
enrich_ast_with_metadata,
|
|
17
|
-
parse_with_data_fields,
|
|
14
|
+
generate_validations_script,
|
|
18
15
|
)
|
|
19
16
|
|
|
20
17
|
# Import from general DPM API
|
|
@@ -40,9 +37,6 @@ __all__ = [
|
|
|
40
37
|
"SemanticAPI",
|
|
41
38
|
"ASTGeneratorAPI",
|
|
42
39
|
"OperationScopesAPI",
|
|
43
|
-
#
|
|
44
|
-
"
|
|
45
|
-
"generate_enriched_ast",
|
|
46
|
-
"enrich_ast_with_metadata",
|
|
47
|
-
"parse_with_data_fields",
|
|
40
|
+
# Standalone function
|
|
41
|
+
"generate_validations_script",
|
|
48
42
|
]
|
|
@@ -9,13 +9,7 @@ from py_dpm.api.dpm_xl.semantic import SemanticAPI
|
|
|
9
9
|
from py_dpm.api.dpm_xl.ast_generator import ASTGeneratorAPI
|
|
10
10
|
from py_dpm.api.dpm_xl.operation_scopes import OperationScopesAPI
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
from py_dpm.api.dpm_xl.complete_ast import (
|
|
14
|
-
generate_complete_ast,
|
|
15
|
-
generate_enriched_ast,
|
|
16
|
-
enrich_ast_with_metadata,
|
|
17
|
-
parse_with_data_fields,
|
|
18
|
-
)
|
|
12
|
+
from py_dpm.api.dpm_xl.complete_ast import generate_validations_script
|
|
19
13
|
|
|
20
14
|
__all__ = [
|
|
21
15
|
# Class-based APIs
|
|
@@ -23,9 +17,6 @@ __all__ = [
|
|
|
23
17
|
"SemanticAPI",
|
|
24
18
|
"ASTGeneratorAPI",
|
|
25
19
|
"OperationScopesAPI",
|
|
26
|
-
# Standalone
|
|
27
|
-
"
|
|
28
|
-
"generate_enriched_ast",
|
|
29
|
-
"enrich_ast_with_metadata",
|
|
30
|
-
"parse_with_data_fields",
|
|
20
|
+
# Standalone function
|
|
21
|
+
"generate_validations_script",
|
|
31
22
|
]
|
|
@@ -32,7 +32,7 @@ class ASTGeneratorAPI:
|
|
|
32
32
|
- Returns: AST with data fields populated (datapoint IDs, operand references)
|
|
33
33
|
- Use for: AST analysis with complete metadata, matching json_scripts/*.json format
|
|
34
34
|
|
|
35
|
-
3. **
|
|
35
|
+
3. **Validations Script** (generate_validations_script):
|
|
36
36
|
- Requires database connection
|
|
37
37
|
- Extends complete AST with framework structure for execution engines
|
|
38
38
|
- Returns: Engine-ready AST with operations, variables, tables, preconditions sections
|
|
@@ -90,7 +90,7 @@ class ASTGeneratorAPI:
|
|
|
90
90
|
|
|
91
91
|
**What you DON'T get:**
|
|
92
92
|
- Data fields (datapoint IDs, operand references) - use generate_complete_ast()
|
|
93
|
-
- Framework structure - use
|
|
93
|
+
- Framework structure - use generate_validations_script()
|
|
94
94
|
|
|
95
95
|
Args:
|
|
96
96
|
expression: DPM-XL expression string
|
|
@@ -347,7 +347,7 @@ class ASTGeneratorAPI:
|
|
|
347
347
|
return [(expressions, "default_code", None)]
|
|
348
348
|
return expressions
|
|
349
349
|
|
|
350
|
-
def
|
|
350
|
+
def generate_validations_script(
|
|
351
351
|
self,
|
|
352
352
|
expressions: Union[str, List[Tuple[str, str, Optional[str]]]],
|
|
353
353
|
release_code: Optional[str] = None,
|
|
@@ -360,9 +360,9 @@ class ASTGeneratorAPI:
|
|
|
360
360
|
module_version_number: Optional[str] = None,
|
|
361
361
|
) -> Dict[str, Any]:
|
|
362
362
|
"""
|
|
363
|
-
Generate
|
|
363
|
+
Generate validations script with engine-ready AST and framework structure.
|
|
364
364
|
|
|
365
|
-
This
|
|
365
|
+
This method generates the complete validations script by wrapping ASTs in an engine-ready
|
|
366
366
|
framework structure with operations, variables, tables, and preconditions sections.
|
|
367
367
|
This is the format required by business rule execution engines.
|
|
368
368
|
|
|
@@ -370,7 +370,7 @@ class ASTGeneratorAPI:
|
|
|
370
370
|
expression/operation/precondition tuples for generating scripts with multiple operations.
|
|
371
371
|
|
|
372
372
|
**What you get:**
|
|
373
|
-
-
|
|
373
|
+
- Complete AST with data fields PLUS:
|
|
374
374
|
- Framework structure: operations, variables, tables, preconditions
|
|
375
375
|
- Module metadata: version, release info, dates
|
|
376
376
|
- Dependency information (including cross-module dependencies)
|
|
@@ -428,14 +428,14 @@ class ASTGeneratorAPI:
|
|
|
428
428
|
|
|
429
429
|
Example:
|
|
430
430
|
>>> generator = ASTGeneratorAPI(database_path="data.db")
|
|
431
|
-
>>> # Single expression
|
|
432
|
-
>>> result = generator.
|
|
431
|
+
>>> # Single expression
|
|
432
|
+
>>> result = generator.generate_validations_script(
|
|
433
433
|
... "{tF_01.00, r0010, c0010}",
|
|
434
434
|
... release_code="4.2",
|
|
435
435
|
... )
|
|
436
436
|
>>>
|
|
437
437
|
>>> # Multiple expressions with operations and preconditions
|
|
438
|
-
>>> result = generator.
|
|
438
|
+
>>> result = generator.generate_validations_script(
|
|
439
439
|
... [
|
|
440
440
|
... ("{tF_01.00, r0010, c0010} = 0", "v1234_m", None),
|
|
441
441
|
... ("{tF_01.00, r0020, c0010} > 0", "v1235_m", "{v_F_44_04}"),
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""
|
|
3
|
+
Validations Script API - Generate engine-ready ASTs for validation frameworks.
|
|
4
|
+
|
|
5
|
+
This module provides a standalone function that delegates to ASTGeneratorAPI.
|
|
6
|
+
|
|
7
|
+
For direct class usage:
|
|
8
|
+
from py_dpm.api.dpm_xl import ASTGeneratorAPI
|
|
9
|
+
|
|
10
|
+
generator = ASTGeneratorAPI(database_path="data.db")
|
|
11
|
+
result = generator.generate_validations_script(expressions)
|
|
12
|
+
"""
|
|
13
|
+
|
|
14
|
+
from typing import Dict, Any, Optional, List, Union, Tuple
|
|
15
|
+
from py_dpm.api.dpm_xl.ast_generator import ASTGeneratorAPI
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def generate_validations_script(
|
|
19
|
+
expressions: Union[str, List[Tuple[str, str, Optional[str]]]],
|
|
20
|
+
database_path: Optional[str] = None,
|
|
21
|
+
connection_url: Optional[str] = None,
|
|
22
|
+
release_code: Optional[str] = None,
|
|
23
|
+
table_context: Optional[Dict[str, Any]] = None,
|
|
24
|
+
release_id: Optional[int] = None,
|
|
25
|
+
primary_module_vid: Optional[int] = None,
|
|
26
|
+
module_code: Optional[str] = None,
|
|
27
|
+
preferred_module_dependencies: Optional[List[str]] = None,
|
|
28
|
+
) -> Dict[str, Any]:
|
|
29
|
+
"""
|
|
30
|
+
Generate validations script with engine-ready AST from DPM-XL expression(s).
|
|
31
|
+
|
|
32
|
+
This function delegates to ASTGeneratorAPI.generate_validations_script().
|
|
33
|
+
|
|
34
|
+
Supports both single expressions and multiple expression/operation/precondition
|
|
35
|
+
tuples for generating scripts with multiple operations.
|
|
36
|
+
|
|
37
|
+
Args:
|
|
38
|
+
expressions: Either a single DPM-XL expression string,
|
|
39
|
+
or a list of tuples: [(expression, operation_code, precondition), ...].
|
|
40
|
+
Each tuple contains:
|
|
41
|
+
- expression (str): The DPM-XL expression (required)
|
|
42
|
+
- operation_code (str): The operation code (required)
|
|
43
|
+
- precondition (Optional[str]): Optional precondition reference (e.g., {v_F_44_04})
|
|
44
|
+
database_path: Path to SQLite database (or None for PostgreSQL)
|
|
45
|
+
connection_url: PostgreSQL connection URL (takes precedence over database_path)
|
|
46
|
+
release_code: DPM release code (e.g., "4.0", "4.1", "4.2")
|
|
47
|
+
table_context: Optional table context dict with keys: 'table', 'columns', 'rows', 'sheets', 'default', 'interval'
|
|
48
|
+
release_id: Optional release ID to filter database lookups by specific release.
|
|
49
|
+
If None, uses all available data (release-agnostic).
|
|
50
|
+
primary_module_vid: Optional module version ID of the module being exported.
|
|
51
|
+
When provided, enables detection of cross-module dependencies.
|
|
52
|
+
module_code: Optional module code (e.g., "FINREP9") to specify the main module.
|
|
53
|
+
preferred_module_dependencies: Optional list of module codes to prefer when
|
|
54
|
+
multiple dependency scopes are possible.
|
|
55
|
+
|
|
56
|
+
Returns:
|
|
57
|
+
dict: {
|
|
58
|
+
'success': bool,
|
|
59
|
+
'enriched_ast': dict, # Engine-ready AST with framework structure
|
|
60
|
+
'error': str # Error message if failed
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
Example:
|
|
64
|
+
>>> # Single expression
|
|
65
|
+
>>> result = generate_validations_script(
|
|
66
|
+
... "{tF_01.00, r0010, c0010}",
|
|
67
|
+
... database_path="data.db",
|
|
68
|
+
... release_code="4.2",
|
|
69
|
+
... )
|
|
70
|
+
>>>
|
|
71
|
+
>>> # Multiple expressions
|
|
72
|
+
>>> result = generate_validations_script(
|
|
73
|
+
... [
|
|
74
|
+
... ("{tF_01.00, r0010, c0010} = 0", "v1234_m", None),
|
|
75
|
+
... ("{tF_01.00, r0020, c0010} > 0", "v1235_m", "{v_F_44_04}"),
|
|
76
|
+
... ],
|
|
77
|
+
... database_path="data.db",
|
|
78
|
+
... release_code="4.2",
|
|
79
|
+
... module_code="FINREP9",
|
|
80
|
+
... )
|
|
81
|
+
"""
|
|
82
|
+
generator = ASTGeneratorAPI(
|
|
83
|
+
database_path=database_path,
|
|
84
|
+
connection_url=connection_url,
|
|
85
|
+
enable_semantic_validation=True
|
|
86
|
+
)
|
|
87
|
+
return generator.generate_validations_script(
|
|
88
|
+
expressions=expressions,
|
|
89
|
+
release_code=release_code,
|
|
90
|
+
table_context=table_context,
|
|
91
|
+
release_id=release_id,
|
|
92
|
+
primary_module_vid=primary_module_vid,
|
|
93
|
+
module_code=module_code,
|
|
94
|
+
preferred_module_dependencies=preferred_module_dependencies,
|
|
95
|
+
)
|
|
@@ -452,6 +452,21 @@ class ASTToJSONVisitor(NodeVisitor):
|
|
|
452
452
|
'shift_number': node.shift_number
|
|
453
453
|
}
|
|
454
454
|
|
|
455
|
+
def visit_RenameOp(self, node):
|
|
456
|
+
"""Visit RenameOp nodes and serialize as RenameClauseOp."""
|
|
457
|
+
return {
|
|
458
|
+
'class_name': 'RenameClauseOp',
|
|
459
|
+
'operand': self.visit(node.operand),
|
|
460
|
+
'clauses': [self._serialize_rename_node(rn) for rn in node.rename_nodes]
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
def _serialize_rename_node(self, node):
|
|
464
|
+
"""Serialize a RenameNode as a clause dictionary."""
|
|
465
|
+
return {
|
|
466
|
+
'from_component': node.old_name,
|
|
467
|
+
'to_component': node.new_name
|
|
468
|
+
}
|
|
469
|
+
|
|
455
470
|
def visit_PreconditionItem(self, node):
|
|
456
471
|
"""Visit PreconditionItem nodes."""
|
|
457
472
|
result = {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pydpm_xl
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.9
|
|
4
4
|
Summary: Python library for DPM-XL data processing and analysis
|
|
5
5
|
Author-email: "MeaningfulData S.L." <info@meaningfuldata.eu>
|
|
6
6
|
License: GPL-3.0-or-later
|
|
@@ -210,22 +210,21 @@ else:
|
|
|
210
210
|
print(f"Error: {result.error}")
|
|
211
211
|
```
|
|
212
212
|
|
|
213
|
-
####
|
|
213
|
+
#### Validations Script Generation
|
|
214
214
|
|
|
215
215
|
```python
|
|
216
|
-
from py_dpm.api import
|
|
216
|
+
from py_dpm.api import generate_validations_script
|
|
217
217
|
|
|
218
|
-
# Generate
|
|
219
|
-
result =
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
218
|
+
# Generate engine-ready validations script
|
|
219
|
+
result = generate_validations_script(
|
|
220
|
+
"{tT_01.00, r0010, c0010}",
|
|
221
|
+
database_path="data.db",
|
|
222
|
+
release_code="4.2"
|
|
223
|
+
)
|
|
224
|
+
if result["success"]:
|
|
225
|
+
print(f"Enriched AST: {result['enriched_ast']}")
|
|
223
226
|
else:
|
|
224
|
-
print(f"
|
|
225
|
-
|
|
226
|
-
# Generate enriched AST (ready for execution engine)
|
|
227
|
-
enriched = generate_enriched_ast("{tT_01.00, r0010, c0010}", release_id=123)
|
|
228
|
-
print(f"Enriched AST: {enriched}")
|
|
227
|
+
print(f"Error: {result['error']}")
|
|
229
228
|
```
|
|
230
229
|
|
|
231
230
|
#### Migration
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "pydpm_xl"
|
|
3
|
-
version = "0.2.
|
|
3
|
+
version = "0.2.9"
|
|
4
4
|
description = "Python library for DPM-XL data processing and analysis"
|
|
5
5
|
authors = [
|
|
6
6
|
{name = "MeaningfulData S.L.", email = "info@meaningfuldata.eu"}
|
|
@@ -52,7 +52,7 @@ exclude = []
|
|
|
52
52
|
|
|
53
53
|
[tool.poetry]
|
|
54
54
|
name = "pydpm_xl"
|
|
55
|
-
version = "0.2.
|
|
55
|
+
version = "0.2.9"
|
|
56
56
|
description = "Python library for DPM-XL data processing and analysis"
|
|
57
57
|
authors = ["MeaningfulData S.L. <info@meaningfuldata.eu>"]
|
|
58
58
|
readme = "README.md"
|
|
@@ -1,208 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env python3
|
|
2
|
-
"""
|
|
3
|
-
Complete AST API - Generate ASTs exactly like the JSON examples
|
|
4
|
-
|
|
5
|
-
This module provides backwards-compatible standalone functions that delegate to ASTGeneratorAPI.
|
|
6
|
-
All AST-related functionality is now consolidated in the ASTGeneratorAPI class.
|
|
7
|
-
|
|
8
|
-
For new code, prefer using ASTGeneratorAPI directly:
|
|
9
|
-
from py_dpm.api.dpm_xl import ASTGeneratorAPI
|
|
10
|
-
|
|
11
|
-
generator = ASTGeneratorAPI(database_path="data.db")
|
|
12
|
-
result = generator.generate_complete_ast(expression)
|
|
13
|
-
"""
|
|
14
|
-
|
|
15
|
-
from typing import Dict, Any, Optional, List, Union, Tuple
|
|
16
|
-
from py_dpm.api.dpm_xl.ast_generator import ASTGeneratorAPI
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
def generate_complete_ast(
|
|
20
|
-
expression: str,
|
|
21
|
-
database_path: str = None,
|
|
22
|
-
connection_url: str = None,
|
|
23
|
-
release_id: Optional[int] = None,
|
|
24
|
-
):
|
|
25
|
-
"""
|
|
26
|
-
Generate complete AST with all data fields, exactly like json_scripts examples.
|
|
27
|
-
|
|
28
|
-
This function delegates to ASTGeneratorAPI for backwards compatibility.
|
|
29
|
-
|
|
30
|
-
Args:
|
|
31
|
-
expression: DPM-XL expression string
|
|
32
|
-
database_path: Path to SQLite database file (e.g., "./database.db")
|
|
33
|
-
connection_url: SQLAlchemy connection URL for PostgreSQL (optional)
|
|
34
|
-
release_id: Optional release ID to filter database lookups by specific release.
|
|
35
|
-
If None, uses all available data (release-agnostic).
|
|
36
|
-
|
|
37
|
-
Returns:
|
|
38
|
-
dict with keys:
|
|
39
|
-
success, ast, context, error, data_populated, semantic_result
|
|
40
|
-
"""
|
|
41
|
-
generator = ASTGeneratorAPI(
|
|
42
|
-
database_path=database_path,
|
|
43
|
-
connection_url=connection_url,
|
|
44
|
-
enable_semantic_validation=True
|
|
45
|
-
)
|
|
46
|
-
return generator.generate_complete_ast(expression, release_id=release_id)
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
# Convenience function with cleaner interface
|
|
50
|
-
def parse_with_data_fields(
|
|
51
|
-
expression: str,
|
|
52
|
-
database_path: str = None,
|
|
53
|
-
connection_url: str = None,
|
|
54
|
-
release_id: Optional[int] = None,
|
|
55
|
-
):
|
|
56
|
-
"""
|
|
57
|
-
Simple function to parse expression and get AST with data fields.
|
|
58
|
-
|
|
59
|
-
This function delegates to ASTGeneratorAPI for backwards compatibility.
|
|
60
|
-
|
|
61
|
-
Args:
|
|
62
|
-
expression: DPM-XL expression string
|
|
63
|
-
database_path: Path to SQLite database file
|
|
64
|
-
connection_url: SQLAlchemy connection URL for PostgreSQL (optional)
|
|
65
|
-
release_id: Optional release ID to filter database lookups by specific release.
|
|
66
|
-
If None, uses all available data (release-agnostic).
|
|
67
|
-
|
|
68
|
-
Returns:
|
|
69
|
-
dict: AST dictionary with data fields, or None if failed
|
|
70
|
-
"""
|
|
71
|
-
result = generate_complete_ast(
|
|
72
|
-
expression, database_path, connection_url, release_id=release_id
|
|
73
|
-
)
|
|
74
|
-
return result["ast"] if result["success"] else None
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
# ============================================================================
|
|
78
|
-
# AST Enrichment Functions - Create engine-ready ASTs
|
|
79
|
-
# ============================================================================
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
def generate_enriched_ast(
|
|
83
|
-
expressions: Union[str, List[Tuple[str, str, Optional[str]]]],
|
|
84
|
-
database_path: Optional[str] = None,
|
|
85
|
-
connection_url: Optional[str] = None,
|
|
86
|
-
release_code: Optional[str] = None,
|
|
87
|
-
table_context: Optional[Dict[str, Any]] = None,
|
|
88
|
-
release_id: Optional[int] = None,
|
|
89
|
-
primary_module_vid: Optional[int] = None,
|
|
90
|
-
module_code: Optional[str] = None,
|
|
91
|
-
preferred_module_dependencies: Optional[List[str]] = None,
|
|
92
|
-
) -> Dict[str, Any]:
|
|
93
|
-
"""
|
|
94
|
-
Generate enriched, engine-ready AST from DPM-XL expression(s).
|
|
95
|
-
|
|
96
|
-
This function delegates to ASTGeneratorAPI for backwards compatibility.
|
|
97
|
-
|
|
98
|
-
Supports both single expressions (for backward compatibility) and multiple
|
|
99
|
-
expression/operation/precondition tuples for generating scripts with multiple operations.
|
|
100
|
-
|
|
101
|
-
Args:
|
|
102
|
-
expressions: Either a single DPM-XL expression string (backward compatible),
|
|
103
|
-
or a list of tuples: [(expression, operation_code, precondition), ...].
|
|
104
|
-
Each tuple contains:
|
|
105
|
-
- expression (str): The DPM-XL expression (required)
|
|
106
|
-
- operation_code (str): The operation code (required)
|
|
107
|
-
- precondition (Optional[str]): Optional precondition reference (e.g., {v_F_44_04})
|
|
108
|
-
database_path: Path to SQLite database (or None for PostgreSQL)
|
|
109
|
-
connection_url: PostgreSQL connection URL (takes precedence over database_path)
|
|
110
|
-
release_code: DPM release code (e.g., "4.0", "4.1", "4.2")
|
|
111
|
-
table_context: Optional table context dict with keys: 'table', 'columns', 'rows', 'sheets', 'default', 'interval'
|
|
112
|
-
release_id: Optional release ID to filter database lookups by specific release.
|
|
113
|
-
If None, uses all available data (release-agnostic).
|
|
114
|
-
primary_module_vid: Optional module version ID of the module being exported.
|
|
115
|
-
When provided, enables detection of cross-module dependencies.
|
|
116
|
-
module_code: Optional module code (e.g., "FINREP9") to specify the main module.
|
|
117
|
-
preferred_module_dependencies: Optional list of module codes to prefer when
|
|
118
|
-
multiple dependency scopes are possible.
|
|
119
|
-
|
|
120
|
-
Returns:
|
|
121
|
-
dict: {
|
|
122
|
-
'success': bool,
|
|
123
|
-
'enriched_ast': dict, # Engine-ready AST with framework structure
|
|
124
|
-
'error': str # Error message if failed
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
Example:
|
|
128
|
-
>>> # Single expression (backward compatible)
|
|
129
|
-
>>> result = generate_enriched_ast(
|
|
130
|
-
... "{tF_01.00, r0010, c0010}",
|
|
131
|
-
... database_path="data.db",
|
|
132
|
-
... release_code="4.2",
|
|
133
|
-
... )
|
|
134
|
-
>>>
|
|
135
|
-
>>> # Multiple expressions
|
|
136
|
-
>>> result = generate_enriched_ast(
|
|
137
|
-
... [
|
|
138
|
-
... ("{tF_01.00, r0010, c0010} = 0", "v1234_m", None),
|
|
139
|
-
... ("{tF_01.00, r0020, c0010} > 0", "v1235_m", "{v_F_44_04}"),
|
|
140
|
-
... ],
|
|
141
|
-
... database_path="data.db",
|
|
142
|
-
... release_code="4.2",
|
|
143
|
-
... module_code="FINREP9",
|
|
144
|
-
... )
|
|
145
|
-
"""
|
|
146
|
-
generator = ASTGeneratorAPI(
|
|
147
|
-
database_path=database_path,
|
|
148
|
-
connection_url=connection_url,
|
|
149
|
-
enable_semantic_validation=True
|
|
150
|
-
)
|
|
151
|
-
return generator.generate_enriched_ast(
|
|
152
|
-
expressions=expressions,
|
|
153
|
-
release_code=release_code,
|
|
154
|
-
table_context=table_context,
|
|
155
|
-
release_id=release_id,
|
|
156
|
-
primary_module_vid=primary_module_vid,
|
|
157
|
-
module_code=module_code,
|
|
158
|
-
preferred_module_dependencies=preferred_module_dependencies,
|
|
159
|
-
)
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
def enrich_ast_with_metadata(
|
|
163
|
-
ast_dict: Dict[str, Any],
|
|
164
|
-
expression: str,
|
|
165
|
-
context: Optional[Dict[str, Any]],
|
|
166
|
-
database_path: Optional[str] = None,
|
|
167
|
-
connection_url: Optional[str] = None,
|
|
168
|
-
release_code: Optional[str] = None,
|
|
169
|
-
operation_code: Optional[str] = None,
|
|
170
|
-
precondition: Optional[str] = None,
|
|
171
|
-
release_id: Optional[int] = None,
|
|
172
|
-
primary_module_vid: Optional[int] = None,
|
|
173
|
-
) -> Dict[str, Any]:
|
|
174
|
-
"""
|
|
175
|
-
Add framework structure (operations, variables, tables, preconditions) to complete AST.
|
|
176
|
-
|
|
177
|
-
This function delegates to ASTGeneratorAPI for backwards compatibility.
|
|
178
|
-
|
|
179
|
-
Args:
|
|
180
|
-
ast_dict: Complete AST dictionary (from generate_complete_ast)
|
|
181
|
-
expression: Original DPM-XL expression
|
|
182
|
-
context: Context dict with table, rows, columns, sheets, default, interval
|
|
183
|
-
database_path: Path to SQLite database
|
|
184
|
-
connection_url: PostgreSQL connection URL (takes precedence)
|
|
185
|
-
release_code: DPM release code (e.g., "4.2")
|
|
186
|
-
operation_code: Operation code (defaults to "default_code")
|
|
187
|
-
precondition: Precondition variable reference (e.g., {v_F_44_04})
|
|
188
|
-
release_id: Optional release ID to filter database lookups
|
|
189
|
-
primary_module_vid: Optional module VID of the module being exported
|
|
190
|
-
|
|
191
|
-
Returns:
|
|
192
|
-
dict: Engine-ready AST with framework structure
|
|
193
|
-
"""
|
|
194
|
-
generator = ASTGeneratorAPI(
|
|
195
|
-
database_path=database_path,
|
|
196
|
-
connection_url=connection_url,
|
|
197
|
-
enable_semantic_validation=True
|
|
198
|
-
)
|
|
199
|
-
return generator._enrich_ast_with_metadata(
|
|
200
|
-
ast_dict=ast_dict,
|
|
201
|
-
expression=expression,
|
|
202
|
-
context=context,
|
|
203
|
-
release_code=release_code,
|
|
204
|
-
operation_code=operation_code,
|
|
205
|
-
precondition=precondition,
|
|
206
|
-
release_id=release_id,
|
|
207
|
-
primary_module_vid=primary_module_vid,
|
|
208
|
-
)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|