pydpm_xl 0.1.10__py3-none-any.whl

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.
Files changed (94) hide show
  1. py_dpm/AST/ASTConstructor.py +503 -0
  2. py_dpm/AST/ASTObjects.py +827 -0
  3. py_dpm/AST/ASTTemplate.py +101 -0
  4. py_dpm/AST/ASTVisitor.py +13 -0
  5. py_dpm/AST/MLGeneration.py +588 -0
  6. py_dpm/AST/ModuleAnalyzer.py +79 -0
  7. py_dpm/AST/ModuleDependencies.py +203 -0
  8. py_dpm/AST/WhereClauseChecker.py +12 -0
  9. py_dpm/AST/__init__.py +0 -0
  10. py_dpm/AST/check_operands.py +302 -0
  11. py_dpm/DataTypes/ScalarTypes.py +324 -0
  12. py_dpm/DataTypes/TimeClasses.py +370 -0
  13. py_dpm/DataTypes/TypePromotion.py +195 -0
  14. py_dpm/DataTypes/__init__.py +0 -0
  15. py_dpm/Exceptions/__init__.py +0 -0
  16. py_dpm/Exceptions/exceptions.py +84 -0
  17. py_dpm/Exceptions/messages.py +114 -0
  18. py_dpm/OperationScopes/OperationScopeService.py +247 -0
  19. py_dpm/OperationScopes/__init__.py +0 -0
  20. py_dpm/Operators/AggregateOperators.py +138 -0
  21. py_dpm/Operators/BooleanOperators.py +30 -0
  22. py_dpm/Operators/ClauseOperators.py +159 -0
  23. py_dpm/Operators/ComparisonOperators.py +69 -0
  24. py_dpm/Operators/ConditionalOperators.py +362 -0
  25. py_dpm/Operators/NumericOperators.py +101 -0
  26. py_dpm/Operators/Operator.py +388 -0
  27. py_dpm/Operators/StringOperators.py +27 -0
  28. py_dpm/Operators/TimeOperators.py +53 -0
  29. py_dpm/Operators/__init__.py +0 -0
  30. py_dpm/Utils/ValidationsGenerationUtils.py +429 -0
  31. py_dpm/Utils/__init__.py +0 -0
  32. py_dpm/Utils/operands_mapping.py +73 -0
  33. py_dpm/Utils/operator_mapping.py +89 -0
  34. py_dpm/Utils/tokens.py +172 -0
  35. py_dpm/Utils/utils.py +2 -0
  36. py_dpm/ValidationsGeneration/PropertiesConstraintsProcessor.py +190 -0
  37. py_dpm/ValidationsGeneration/Utils.py +364 -0
  38. py_dpm/ValidationsGeneration/VariantsProcessor.py +265 -0
  39. py_dpm/ValidationsGeneration/__init__.py +0 -0
  40. py_dpm/ValidationsGeneration/auxiliary_functions.py +98 -0
  41. py_dpm/__init__.py +61 -0
  42. py_dpm/api/__init__.py +140 -0
  43. py_dpm/api/ast_generator.py +438 -0
  44. py_dpm/api/complete_ast.py +241 -0
  45. py_dpm/api/data_dictionary_validation.py +577 -0
  46. py_dpm/api/migration.py +77 -0
  47. py_dpm/api/semantic.py +224 -0
  48. py_dpm/api/syntax.py +182 -0
  49. py_dpm/client.py +106 -0
  50. py_dpm/data_handlers.py +99 -0
  51. py_dpm/db_utils.py +117 -0
  52. py_dpm/grammar/__init__.py +0 -0
  53. py_dpm/grammar/dist/__init__.py +0 -0
  54. py_dpm/grammar/dist/dpm_xlLexer.interp +428 -0
  55. py_dpm/grammar/dist/dpm_xlLexer.py +804 -0
  56. py_dpm/grammar/dist/dpm_xlLexer.tokens +106 -0
  57. py_dpm/grammar/dist/dpm_xlParser.interp +249 -0
  58. py_dpm/grammar/dist/dpm_xlParser.py +5224 -0
  59. py_dpm/grammar/dist/dpm_xlParser.tokens +106 -0
  60. py_dpm/grammar/dist/dpm_xlParserListener.py +742 -0
  61. py_dpm/grammar/dist/dpm_xlParserVisitor.py +419 -0
  62. py_dpm/grammar/dist/listeners.py +10 -0
  63. py_dpm/grammar/dpm_xlLexer.g4 +435 -0
  64. py_dpm/grammar/dpm_xlParser.g4 +260 -0
  65. py_dpm/migration.py +282 -0
  66. py_dpm/models.py +2139 -0
  67. py_dpm/semantics/DAG/DAGAnalyzer.py +158 -0
  68. py_dpm/semantics/DAG/__init__.py +0 -0
  69. py_dpm/semantics/SemanticAnalyzer.py +320 -0
  70. py_dpm/semantics/Symbols.py +223 -0
  71. py_dpm/semantics/__init__.py +0 -0
  72. py_dpm/utils/__init__.py +0 -0
  73. py_dpm/utils/ast_serialization.py +481 -0
  74. py_dpm/views/data_types.sql +12 -0
  75. py_dpm/views/datapoints.sql +65 -0
  76. py_dpm/views/hierarchy_operand_reference.sql +11 -0
  77. py_dpm/views/hierarchy_preconditions.sql +13 -0
  78. py_dpm/views/hierarchy_variables.sql +26 -0
  79. py_dpm/views/hierarchy_variables_context.sql +14 -0
  80. py_dpm/views/key_components.sql +18 -0
  81. py_dpm/views/module_from_table.sql +11 -0
  82. py_dpm/views/open_keys.sql +13 -0
  83. py_dpm/views/operation_info.sql +27 -0
  84. py_dpm/views/operation_list.sql +18 -0
  85. py_dpm/views/operations_versions_from_module_version.sql +30 -0
  86. py_dpm/views/precondition_info.sql +17 -0
  87. py_dpm/views/report_type_operand_reference_info.sql +18 -0
  88. py_dpm/views/subcategory_info.sql +17 -0
  89. py_dpm/views/table_info.sql +19 -0
  90. pydpm_xl-0.1.10.dist-info/LICENSE +674 -0
  91. pydpm_xl-0.1.10.dist-info/METADATA +50 -0
  92. pydpm_xl-0.1.10.dist-info/RECORD +94 -0
  93. pydpm_xl-0.1.10.dist-info/WHEEL +4 -0
  94. pydpm_xl-0.1.10.dist-info/entry_points.txt +3 -0
@@ -0,0 +1,827 @@
1
+ """
2
+ AST.ASTObjects.py
3
+ =================
4
+
5
+ Description
6
+ -----------
7
+ AST nodes
8
+ """
9
+
10
+
11
+ class AST:
12
+ """
13
+ Superclass of all AST objects
14
+ """
15
+
16
+ def __init__(self):
17
+ self.num = None
18
+ self.prev = None
19
+
20
+ def __str__(self):
21
+ return "<AST(name='{name}')>".format(
22
+ name=self.__class__.__name__
23
+ )
24
+
25
+ __repr__ = __str__
26
+
27
+
28
+ class Start(AST):
29
+ """
30
+ Starting point of the AST.
31
+ """
32
+
33
+ def __init__(self, children):
34
+ super().__init__()
35
+ self.children = children
36
+
37
+ def __str__(self):
38
+ return "<AST(name='{name}', children={children})>".format(
39
+ name=self.__class__.__name__,
40
+ children=self.children
41
+ )
42
+
43
+ __repr__ = __str__
44
+
45
+ def toJSON(self):
46
+ result = {
47
+ 'class_name': self.__class__.__name__
48
+ }
49
+
50
+ # Check if this Start node has left/right/op structure (expanded from WithExpression)
51
+ if hasattr(self, 'left') and hasattr(self, 'right'):
52
+ result['left'] = self.left
53
+ result['right'] = self.right
54
+ if hasattr(self, 'op'):
55
+ result['op'] = self.op
56
+ else:
57
+ # Use original children structure
58
+ result['children'] = self.children
59
+
60
+ return result
61
+
62
+
63
+ class ParExpr(AST):
64
+ """
65
+ ParExpr. Parenthesis Expression used to group expressions inside parenthesis to give more priority.
66
+ Example: (A + B) * C
67
+ """
68
+
69
+ def __init__(self, expression):
70
+ super().__init__()
71
+ self.expression = expression
72
+
73
+ def __str__(self):
74
+ return "<AST(Expression={expression})>".format(expression=self.expression)
75
+
76
+ def toJSON(self):
77
+ return {
78
+ 'class_name': self.__class__.__name__,
79
+ 'expression': self.expression
80
+ }
81
+
82
+ __repr__ = __str__
83
+
84
+
85
+ class BinOp(AST):
86
+ """
87
+ All binary operators are analysed using this AST Object. Check BIN_OP_MAPPING on Utils/operator_mapping.py
88
+ for the complete list.
89
+ """
90
+
91
+ def __init__(self, left, op, right):
92
+ super().__init__()
93
+ self.left = left
94
+ self.op = op
95
+ self.right = right
96
+
97
+ def __str__(self):
98
+ return "<AST(name='{name}', op='{op}', left={left}, right={right})>".format(
99
+ name=self.__class__.__name__,
100
+ op=self.op,
101
+ left=self.left,
102
+ right=self.right
103
+ )
104
+
105
+ __repr__ = __str__
106
+
107
+ def toJSON(self):
108
+ return {
109
+ 'class_name': self.__class__.__name__,
110
+ 'op': self.op,
111
+ 'left': self.left,
112
+ 'right': self.right
113
+ }
114
+
115
+
116
+ class UnaryOp(AST):
117
+ """
118
+ All unary operators are analysed using this AST Object. Check UNARY_OP_MAPPING on Utils/operator_mapping.py
119
+ for the complete list.
120
+ """
121
+
122
+ def __init__(self, op, operand):
123
+ super().__init__()
124
+ self.op = op
125
+ self.operand = operand
126
+
127
+ def __str__(self):
128
+ return "<AST(name='{name}', op='{op}', operand={operand})>".format(
129
+ name=self.__class__.__name__,
130
+ op=self.op,
131
+ operand=self.operand
132
+ )
133
+
134
+ __repr__ = __str__
135
+
136
+ def toJSON(self):
137
+ return {
138
+ 'class_name': self.__class__.__name__,
139
+ 'op': self.op,
140
+ 'operand': self.operand
141
+ }
142
+
143
+
144
+ class CondExpr(AST):
145
+ """
146
+ AST Object for if-then-else operation.
147
+ """
148
+
149
+ def __init__(self, condition, then_expr, else_expr):
150
+ super().__init__()
151
+ self.condition = condition
152
+ self.then_expr = then_expr
153
+ self.else_expr = else_expr
154
+
155
+ def __str__(self):
156
+ return "<AST(name='{name}', condition={condition}, then_expr={then_expr}, else_expr={else_expr})>".format(
157
+ name=self.__class__.__name__,
158
+ condition=self.condition,
159
+ then_expr=self.then_expr,
160
+ else_expr=self.else_expr
161
+ )
162
+
163
+ __repr__ = __str__
164
+
165
+ def toJSON(self):
166
+ return {
167
+ 'class_name': self.__class__.__name__,
168
+ 'condition': self.condition,
169
+ 'then_expr': self.then_expr,
170
+ 'else_expr': self.else_expr
171
+ }
172
+
173
+
174
+ class VarRef(AST):
175
+ """
176
+ Checks the reference to a specific variable in DB.
177
+ """
178
+
179
+ def __init__(self, variable):
180
+ super().__init__()
181
+ self.variable = variable
182
+
183
+ def __str__(self):
184
+ return "<AST(name='{name}', variable={variable})>".format(
185
+ name=self.__class__.__name__,
186
+ variable=self.variable
187
+ )
188
+
189
+ __repr__ = __str__
190
+
191
+ def toJSON(self):
192
+ return {
193
+ 'class_name': self.__class__.__name__,
194
+ 'variable': self.variable
195
+ }
196
+
197
+
198
+ class VarID(AST):
199
+ """
200
+ AST Object for operand including a Cell Reference from DB.
201
+ """
202
+
203
+ def __init__(self, table, rows, cols, sheets, interval, default, is_table_group=False):
204
+ super().__init__()
205
+ self.table = table
206
+ self.rows = rows
207
+ self.cols = cols
208
+ self.sheets = sheets
209
+ self.interval = interval
210
+ self.default = default
211
+ self.label = None
212
+ self.is_table_group = is_table_group
213
+
214
+ def __str__(self):
215
+ return "<AST(name='{name}', table={table}, rows={rows}, cols={cols}, sheets={sheets}, interval={interval}, " \
216
+ "default={default}, is_table_group={is_table_group})>".format(
217
+ name=self.__class__.__name__,
218
+ table=self.table,
219
+ rows=self.rows,
220
+ cols=self.cols,
221
+ sheets=self.sheets,
222
+ interval=self.interval,
223
+ default=self.default,
224
+ is_table_group=self.is_table_group
225
+ )
226
+
227
+ __repr__ = __str__
228
+
229
+ def toJSON(self):
230
+ result = {
231
+ 'class_name': self.__class__.__name__,
232
+ }
233
+
234
+ # If data has been populated (after operand checking), use that
235
+ if hasattr(self, 'data') and self.data is not None:
236
+ # Convert DataFrame to list of dictionaries
237
+ try:
238
+ if hasattr(self.data, 'to_dict'):
239
+ result['data'] = self.data.to_dict('records')
240
+ else:
241
+ result['data'] = self.data
242
+ except Exception:
243
+ # Fallback: try to convert to list if it's iterable
244
+ try:
245
+ result['data'] = list(self.data)
246
+ except Exception:
247
+ result['data'] = str(self.data)
248
+ result['table'] = self.table
249
+ result['interval'] = self.interval
250
+ else:
251
+ # Use original structure for unexpanded VarID
252
+ result.update({
253
+ 'table': self.table,
254
+ 'rows': self.rows,
255
+ 'cols': self.cols,
256
+ 'sheets': self.sheets,
257
+ 'interval': self.interval,
258
+ 'default': self.default,
259
+ 'is_table_group': self.is_table_group
260
+ })
261
+
262
+ return result
263
+
264
+
265
+ class Constant(AST):
266
+ """
267
+ AST Object for Constants included in code. Example: 0, "A"
268
+ :parameter type_: Data Type of the Constant
269
+ :parameter value: Value to be hold by the Constant
270
+ """
271
+
272
+ def __init__(self, type_, value):
273
+ super().__init__()
274
+ self.type = type_
275
+ self.value = value
276
+
277
+ def __str__(self):
278
+ return "<AST(name='{name}', type='{type_}', value={value})>".format(
279
+ name=self.__class__.__name__,
280
+ type_=self.type,
281
+ value=self.value
282
+ )
283
+
284
+ __repr__ = __str__
285
+
286
+ def toJSON(self):
287
+ if self.type == "Integer":
288
+ if isinstance(self.value, str) and '.' in self.value:
289
+ self.value = float(self.value)
290
+ value = int(self.value)
291
+ elif self.type == "Number":
292
+ value = float(self.value)
293
+ else:
294
+ value = self.value
295
+ return {
296
+ 'class_name': self.__class__.__name__,
297
+ 'type_': self.type,
298
+ 'value': value
299
+ }
300
+
301
+
302
+ class WithExpression(AST):
303
+ """
304
+ AST Object for expressions including a With clause, which simplifies the expressions over a common
305
+ group of cell references.
306
+
307
+ Example: {Table 1, row 1} + {Table 1, row 2} -> with {Table 1}: {row 1} + {row 2}
308
+ :parameter partial_selection: Cell reference to be used
309
+ :parameter expression: Expression after the double points to be modified by the partial selection
310
+ """
311
+
312
+ def __init__(self, partial_selection, expression):
313
+ super().__init__()
314
+ self.partial_selection = partial_selection
315
+ self.expression = expression
316
+
317
+ def __str__(self):
318
+ return "<AST(name='{name}', partial_selection={partial_selection}, expression={expression})>".format(
319
+ name=self.__class__.__name__,
320
+ partial_selection=self.partial_selection,
321
+ expression=self.expression
322
+ )
323
+
324
+ __repr__ = __str__
325
+
326
+ def toJSON(self):
327
+ return {
328
+ 'class_name': self.__class__.__name__,
329
+ 'partial_selection': self.partial_selection,
330
+ 'expression': self.expression
331
+ }
332
+
333
+
334
+ class AggregationOp(AST):
335
+ """
336
+ All aggregate operators are analysed using this AST Object. Check AGGR_OP_MAPPING on Utils/operator_mapping.py
337
+ for the complete list.
338
+ """
339
+
340
+ def __init__(self, op, operand, grouping_clause):
341
+ super().__init__()
342
+ self.op = op
343
+ self.operand = operand
344
+ self.grouping_clause = grouping_clause
345
+
346
+ def __str__(self):
347
+ return "<AST(name='{name}', op='{op}', operand={operand}, grouping_clause={grouping_clause})>".format(
348
+ name=self.__class__.__name__,
349
+ op=self.op,
350
+ operand=self.operand,
351
+ grouping_clause=self.grouping_clause
352
+ )
353
+
354
+ __repr__ = __str__
355
+
356
+ def toJSON(self):
357
+ return {
358
+ 'class_name': self.__class__.__name__,
359
+ 'op': self.op,
360
+ 'operand': self.operand,
361
+ 'grouping_clause': self.grouping_clause
362
+ }
363
+
364
+
365
+ class GroupingClause(AST):
366
+ """
367
+ Grouping clause inside an aggregation operation.
368
+ """
369
+
370
+ def __init__(self, components):
371
+ super().__init__()
372
+ self.components = components
373
+
374
+ def __str__(self):
375
+ return "<AST(name='{name}', components={components})>".format(
376
+ name=self.__class__.__name__,
377
+ components=self.components
378
+ )
379
+
380
+ __repr__ = __str__
381
+
382
+ def toJSON(self):
383
+ return {
384
+ 'class_name': self.__class__.__name__,
385
+ 'components': self.components,
386
+ }
387
+
388
+
389
+ class Dimension(AST):
390
+ """
391
+ AST object only included in a Where clause. Specifies the component to be filtered.
392
+ """
393
+
394
+ def __init__(self, dimension_code, property_id=None):
395
+ super().__init__()
396
+ self.dimension_code = dimension_code
397
+ self.property_id = property_id
398
+
399
+ def __str__(self):
400
+ return "<AST(name='{name}', dimension_code='{dimension_code}')>".format(
401
+ name=self.__class__.__name__,
402
+ dimension_code=self.dimension_code,
403
+ property_id=self.property_id
404
+ )
405
+
406
+ __repr__ = __str__
407
+
408
+ def toJSON(self):
409
+ return {
410
+ 'class_name': self.__class__.__name__,
411
+ 'dimension_code': self.dimension_code,
412
+ }
413
+
414
+
415
+ class Set(AST):
416
+ """
417
+ AST object for Set operands. Used only in 'IN' operator.
418
+ """
419
+
420
+ def __init__(self, children):
421
+ super().__init__()
422
+ self.children = children
423
+
424
+ def __str__(self):
425
+ return "<AST(name='{name}', children={children})>".format(
426
+ name=self.__class__.__name__,
427
+ children=self.children
428
+ )
429
+
430
+ __repr__ = __str__
431
+
432
+ def toJSON(self):
433
+ return {
434
+ 'class_name': self.__class__.__name__,
435
+ 'children': self.children,
436
+ }
437
+
438
+
439
+ class Scalar(AST):
440
+ """
441
+ AST object representing an Item. Must be validated against the ItemCategory.Signature column.
442
+
443
+ :parameter item: Item Signature to be validated
444
+ :parameter scalar_type: Data type of the item referenced
445
+ """
446
+
447
+ def __init__(self, item, scalar_type):
448
+ super().__init__()
449
+ self.item = item
450
+ self.scalar_type = scalar_type
451
+
452
+ def __str__(self):
453
+ return "<AST(name='{name}', item={item}, scalar_type='{scalar_type}')>".format(
454
+ name=self.__class__.__name__,
455
+ item=self.item,
456
+ scalar_type=self.scalar_type
457
+ )
458
+
459
+ __repr__ = __str__
460
+
461
+ def toJSON(self):
462
+ return {
463
+ 'class_name': self.__class__.__name__,
464
+ 'item': self.item,
465
+ 'scalar_type': self.scalar_type
466
+ }
467
+
468
+
469
+ class ComplexNumericOp(AST):
470
+ """
471
+ AST Object for max and min operations. Could have more than one operand without any other size restrictions.
472
+ """
473
+
474
+ def __init__(self, op, operands):
475
+ super().__init__()
476
+ self.op = op
477
+ self.operands = operands
478
+
479
+ def __str__(self):
480
+ return "<AST(name='{name}', op='{op}', operands={operands})>".format(
481
+ name=self.__class__.__name__,
482
+ op=self.op,
483
+ operands=self.operands
484
+ )
485
+
486
+ __repr__ = __str__
487
+
488
+ def toJSON(self):
489
+ return {
490
+ 'class_name': self.__class__.__name__,
491
+ 'op': self.op,
492
+ 'operands': self.operands
493
+ }
494
+
495
+
496
+ class FilterOp(AST):
497
+ """
498
+ AST Object for filtering operations.
499
+
500
+ :parameter selection: operand or expression over the filter is applied
501
+ :parameter condition: boolean operation to filter the operand
502
+ """
503
+
504
+ def __init__(self, selection, condition):
505
+ super().__init__()
506
+ self.selection = selection
507
+ self.condition = condition
508
+
509
+ def __str__(self):
510
+ return "<AST(name='{name}', selection={selection}, condition={condition})>".format(
511
+ name=self.__class__.__name__,
512
+ selection=self.selection,
513
+ condition=self.condition
514
+ )
515
+
516
+ __repr__ = __str__
517
+
518
+ def toJSON(self):
519
+ return {
520
+ 'class_name': self.__class__.__name__,
521
+ 'selection': self.selection,
522
+ 'condition': self.condition
523
+ }
524
+
525
+
526
+ class TimeShiftOp(AST):
527
+ """
528
+ AST Object of the TimeShift operator.
529
+
530
+ :parameter operand: Recordset where the operation is applied
531
+ :parameter component: Component inside the Recordset to be selected
532
+ :parameter period_indicator: Period to be used based on specification.
533
+ :parameter shift_number: Number of times to apply the specified time period over the operand.
534
+ """
535
+
536
+ def __init__(self, operand, period_indicator, component, shift_number):
537
+ super().__init__()
538
+ self.operand = operand
539
+ self.component = component
540
+ self.period_indicator = period_indicator
541
+ self.shift_number = shift_number
542
+
543
+ def __str__(self):
544
+ return "<AST(name='{name}', operand={operand}, component={component}, period_indicator={period_indicator}, " \
545
+ "shift_number={shift_number})>".format(
546
+ name=self.__class__.__name__,
547
+ operand=self.operand,
548
+ component=self.component,
549
+ period_indicator=self.period_indicator,
550
+ shift_number=self.shift_number)
551
+
552
+ __repr__ = __str__
553
+
554
+ def toJSON(self):
555
+ return {
556
+ 'class_name': self.__class__.__name__,
557
+ 'operand': self.operand,
558
+ 'period_indicator': self.period_indicator,
559
+ 'component': self.component,
560
+ 'shift_number': self.shift_number
561
+ }
562
+
563
+
564
+ class WhereClauseOp(AST):
565
+ """
566
+ AST object for the Where clause.
567
+
568
+ :parameter operand: Operand where the filter is applied based on condition
569
+ :parameter condition: Boolean expression to be used to filter information in the operand.
570
+ """
571
+
572
+ def __init__(self, operand, condition):
573
+ super().__init__()
574
+ self.operand = operand
575
+ self.condition = condition
576
+ self.key_components = []
577
+
578
+ def __str__(self):
579
+ return "<AST(name='{name}', operand={operand}, condition={condition}, key_components={components})>".format(
580
+ name=self.__class__.__name__,
581
+ operand=self.operand,
582
+ condition=self.condition,
583
+ components=self.key_components
584
+ )
585
+
586
+ __repr__ = __str__
587
+
588
+ def toJSON(self):
589
+ return {
590
+ 'class_name': self.__class__.__name__,
591
+ 'operand': self.operand,
592
+ 'condition': self.condition
593
+ }
594
+
595
+
596
+ class GetOp(AST):
597
+ """
598
+ AST Object for the Get operator. Replaces the Fact component with the specified component.
599
+
600
+ :parameter operand: Recordset to be changed
601
+ :parameter component: Component specified to replace the Fact component.
602
+ """
603
+
604
+ def __init__(self, operand, component):
605
+ super().__init__()
606
+ self.operand = operand
607
+ self.component = component
608
+
609
+ def __str__(self):
610
+ return "<AST(name='{name}', operand={operand}, component='{component}')>".format(
611
+ name=self.__class__.__name__,
612
+ operand=self.operand,
613
+ component=self.component
614
+ )
615
+
616
+ __repr__ = __str__
617
+
618
+ def toJSON(self):
619
+ return {
620
+ 'class_name': self.__class__.__name__,
621
+ 'operand': self.operand,
622
+ 'component': self.component
623
+ }
624
+
625
+
626
+ class PreconditionItem(AST):
627
+ """
628
+ AST Object only used in Preconditions.
629
+
630
+ :parameter value: Sets to True or False if the desired table is present in the DB.
631
+ """
632
+
633
+ def __init__(self, variable_id, variable_code=None):
634
+ super().__init__()
635
+ self.variable_id = variable_id
636
+ self.variable_code = variable_code
637
+
638
+ def __str__(self):
639
+ return "<AST(name='{name}', variable_id='{variable_id}')>".format(
640
+ name=self.__class__.__name__,
641
+ variable_id=self.variable_id
642
+ )
643
+
644
+ __repr__ = __str__
645
+
646
+ def toJSON(self):
647
+ return {
648
+ 'class_name': self.__class__.__name__,
649
+ 'variable_id': self.variable_id,
650
+ 'variable_code': self.variable_code
651
+ }
652
+
653
+
654
+ class RenameOp(AST):
655
+ """
656
+ AST Object for rename operation.
657
+
658
+ :parameter operand: Recordset on which components the rename operation applies.
659
+ :parameter rename_nodes: A collection of Rename Nodes
660
+ """
661
+
662
+ def __init__(self, operand, rename_nodes):
663
+ super().__init__()
664
+ self.operand = operand
665
+ self.rename_nodes = rename_nodes
666
+
667
+ def __str__(self):
668
+ return "<AST(name='{name}', rename_nodes={rename_nodes})>".format(
669
+ name=self.__class__.__name__,
670
+ rename_nodes=self.rename_nodes
671
+ )
672
+
673
+ __repr__ = __str__
674
+
675
+ def toJSON(self):
676
+ return {
677
+ 'class_name': self.__class__.__name__,
678
+ 'operand': self.operand,
679
+ 'rename_nodes': self.rename_nodes
680
+ }
681
+
682
+
683
+ class RenameNode(AST):
684
+ """
685
+ Used only in rename operation, specifies the component and the new name to be used
686
+
687
+ :parameter old_name: Component to be renamed
688
+ :parameter new_name: New name applied to the component
689
+ """
690
+
691
+ def __init__(self, old_name, new_name):
692
+ super().__init__()
693
+ self.old_name = old_name
694
+ self.new_name = new_name
695
+
696
+ def __str__(self):
697
+ return "<AST(name='{name}', old_name='{old_name}', new_name='{new_name}')>".format(
698
+ name=self.__class__.__name__,
699
+ old_name=self.old_name,
700
+ new_name=self.new_name
701
+ )
702
+
703
+ __repr__ = __str__
704
+
705
+ def toJSON(self):
706
+ return {
707
+ 'class_name': self.__class__.__name__,
708
+ 'old_name': self.old_name,
709
+ 'new_name': self.new_name
710
+ }
711
+
712
+
713
+ class PropertyReference(AST):
714
+
715
+ def __init__(self, code):
716
+ super().__init__()
717
+ self.code = code
718
+
719
+ def __str__(self):
720
+ return "<AST(name='{name}', code={code})>".format(
721
+ name=self.__class__.__name__,
722
+ code=self.code
723
+ )
724
+
725
+ __repr__ = __str__
726
+
727
+ def toJSON(self):
728
+ return {
729
+ 'class_name': self.__class__.__name__,
730
+ 'code': self.code
731
+ }
732
+
733
+
734
+ class OperationRef(AST):
735
+
736
+ def __init__(self, operation_code):
737
+ super().__init__()
738
+ self.operation_code = operation_code
739
+
740
+ def __str__(self):
741
+ return "<AST(name='{name}', operation_code='{operation_code}')>".format(
742
+ name=self.__class__.__name__,
743
+ operation_code=self.operation_code
744
+ )
745
+
746
+ __repr__ = __str__
747
+
748
+ def toJSON(self):
749
+ return {
750
+ 'class_name': self.__class__.__name__,
751
+ 'operation_code': self.operation_code
752
+ }
753
+
754
+
755
+ class PersistentAssignment(AST):
756
+
757
+ def __init__(self, left, op, right):
758
+ super().__init__()
759
+ self.left = left
760
+ self.op = op
761
+ self.right = right
762
+
763
+ def __str__(self):
764
+ return "<AST(name='{name}', op='{op}', left={left}, right={right})>".format(
765
+ name=self.__class__.__name__,
766
+ op=self.op,
767
+ left=self.left,
768
+ right=self.right
769
+ )
770
+
771
+ __repr__ = __str__
772
+
773
+ def toJSON(self):
774
+ return {
775
+ 'class_name': self.__class__.__name__,
776
+ 'op': self.op,
777
+ 'left': self.left,
778
+ 'right': self.right
779
+ }
780
+
781
+
782
+ class TemporaryAssignment(AST):
783
+
784
+ def __init__(self, left, op, right):
785
+ super().__init__()
786
+ self.left = left
787
+ self.op = op
788
+ self.right = right
789
+
790
+ def __str__(self):
791
+ return "<AST(name='{name}', op='{op}', left={left}, right={right})>".format(
792
+ name=self.__class__.__name__,
793
+ op=self.op,
794
+ left=self.left,
795
+ right=self.right
796
+ )
797
+
798
+ __repr__ = __str__
799
+
800
+ def toJSON(self):
801
+ return {
802
+ 'class_name': self.__class__.__name__,
803
+ 'op': self.op,
804
+ 'left': self.left,
805
+ 'right': self.right
806
+ }
807
+
808
+
809
+ class TemporaryIdentifier(AST):
810
+
811
+ def __init__(self, value):
812
+ super().__init__()
813
+ self.value = value
814
+
815
+ def __str__(self):
816
+ return "<AST(name='{name}', value='{value}')>".format(
817
+ name=self.__class__.__name__,
818
+ value=self.value
819
+ )
820
+
821
+ __repr__ = __str__
822
+
823
+ def toJSON(self):
824
+ return {
825
+ 'class_name': self.__class__.__name__,
826
+ 'value': self.value
827
+ }