@darabonba/python-generator 1.2.11 → 1.2.12

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.
package/ChangeLog.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # ChangeLog
2
2
 
3
+ ## 1.2.12 - 2022-07-20
4
+
5
+ * Support infinite loop reference in model.
6
+
3
7
  ## 1.2.11 - 2022-07-11
4
8
 
5
9
  * Support complex list(`array-in-array`).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@darabonba/python-generator",
3
- "version": "1.2.11",
3
+ "version": "1.2.12",
4
4
  "description": "The darabonba generator for Python",
5
5
  "main": "src/generator.js",
6
6
  "directories": {
@@ -393,6 +393,7 @@ class Combinator extends CombinatorBase {
393
393
  if (_contain(this.definedModels, model.name)) {
394
394
  return;
395
395
  }
396
+ this.definedModels.push(model_name);
396
397
  if (model.subObject.length) {
397
398
  model.subObject.forEach(obj => {
398
399
  this.emitModel(emitter, obj);
@@ -401,7 +402,6 @@ class Combinator extends CombinatorBase {
401
402
  model.body.filter(node => node instanceof PropItem && !this.hasModel(node.type, model.name)).forEach(item => {
402
403
  this.findUndefinedModel(emitter, item.type);
403
404
  });
404
- this.definedModels.push(model_name);
405
405
  this.emitClass(emitter, model);
406
406
  emitter.emitln().emitln();
407
407
  }
@@ -468,3 +468,81 @@ class M(TeaModel):
468
468
  return self
469
469
 
470
470
 
471
+ class NodeChildSubChild(TeaModel):
472
+ def __init__(self, child_node=None):
473
+ self.child_node = child_node # type: Node
474
+
475
+ def validate(self):
476
+ if self.child_node:
477
+ self.child_node.validate()
478
+
479
+ def to_map(self):
480
+ _map = super(NodeChildSubChild, self).to_map()
481
+ if _map is not None:
482
+ return _map
483
+
484
+ result = dict()
485
+ if self.child_node is not None:
486
+ result['childNode'] = self.child_node.to_map()
487
+ return result
488
+
489
+ def from_map(self, m=None):
490
+ m = m or dict()
491
+ if m.get('childNode') is not None:
492
+ temp_model = Node()
493
+ self.child_node = temp_model.from_map(m['childNode'])
494
+ return self
495
+
496
+
497
+ class NodeChild(TeaModel):
498
+ def __init__(self, sub_child=None):
499
+ self.sub_child = sub_child # type: NodeChildSubChild
500
+
501
+ def validate(self):
502
+ if self.sub_child:
503
+ self.sub_child.validate()
504
+
505
+ def to_map(self):
506
+ _map = super(NodeChild, self).to_map()
507
+ if _map is not None:
508
+ return _map
509
+
510
+ result = dict()
511
+ if self.sub_child is not None:
512
+ result['subChild'] = self.sub_child.to_map()
513
+ return result
514
+
515
+ def from_map(self, m=None):
516
+ m = m or dict()
517
+ if m.get('subChild') is not None:
518
+ temp_model = NodeChildSubChild()
519
+ self.sub_child = temp_model.from_map(m['subChild'])
520
+ return self
521
+
522
+
523
+ class Node(TeaModel):
524
+ def __init__(self, child=None):
525
+ self.child = child # type: NodeChild
526
+
527
+ def validate(self):
528
+ if self.child:
529
+ self.child.validate()
530
+
531
+ def to_map(self):
532
+ _map = super(Node, self).to_map()
533
+ if _map is not None:
534
+ return _map
535
+
536
+ result = dict()
537
+ if self.child is not None:
538
+ result['child'] = self.child.to_map()
539
+ return result
540
+
541
+ def from_map(self, m=None):
542
+ m = m or dict()
543
+ if m.get('child') is not None:
544
+ temp_model = NodeChild()
545
+ self.child = temp_model.from_map(m['child'])
546
+ return self
547
+
548
+
@@ -513,3 +513,90 @@ class UseBeforeDefineModel(TeaModel):
513
513
  return self
514
514
 
515
515
 
516
+ class NodeChildSubChild(TeaModel):
517
+ def __init__(
518
+ self,
519
+ child_node: Node = None,
520
+ ):
521
+ self.child_node = child_node
522
+
523
+ def validate(self):
524
+ if self.child_node:
525
+ self.child_node.validate()
526
+
527
+ def to_map(self):
528
+ _map = super().to_map()
529
+ if _map is not None:
530
+ return _map
531
+
532
+ result = dict()
533
+ if self.child_node is not None:
534
+ result['childNode'] = self.child_node.to_map()
535
+ return result
536
+
537
+ def from_map(self, m: dict = None):
538
+ m = m or dict()
539
+ if m.get('childNode') is not None:
540
+ temp_model = Node()
541
+ self.child_node = temp_model.from_map(m['childNode'])
542
+ return self
543
+
544
+
545
+ class NodeChild(TeaModel):
546
+ def __init__(
547
+ self,
548
+ sub_child: NodeChildSubChild = None,
549
+ ):
550
+ self.sub_child = sub_child
551
+
552
+ def validate(self):
553
+ if self.sub_child:
554
+ self.sub_child.validate()
555
+
556
+ def to_map(self):
557
+ _map = super().to_map()
558
+ if _map is not None:
559
+ return _map
560
+
561
+ result = dict()
562
+ if self.sub_child is not None:
563
+ result['subChild'] = self.sub_child.to_map()
564
+ return result
565
+
566
+ def from_map(self, m: dict = None):
567
+ m = m or dict()
568
+ if m.get('subChild') is not None:
569
+ temp_model = NodeChildSubChild()
570
+ self.sub_child = temp_model.from_map(m['subChild'])
571
+ return self
572
+
573
+
574
+ class Node(TeaModel):
575
+ def __init__(
576
+ self,
577
+ child: NodeChild = None,
578
+ ):
579
+ self.child = child
580
+
581
+ def validate(self):
582
+ if self.child:
583
+ self.child.validate()
584
+
585
+ def to_map(self):
586
+ _map = super().to_map()
587
+ if _map is not None:
588
+ return _map
589
+
590
+ result = dict()
591
+ if self.child is not None:
592
+ result['child'] = self.child.to_map()
593
+ return result
594
+
595
+ def from_map(self, m: dict = None):
596
+ m = m or dict()
597
+ if m.get('child') is not None:
598
+ temp_model = NodeChild()
599
+ self.child = temp_model.from_map(m['child'])
600
+ return self
601
+
602
+
@@ -47,3 +47,11 @@ model M = {
47
47
  selfArrayMap: [ map[string]M ],
48
48
  selfArrayArray: [ [ M ] ]
49
49
  };
50
+
51
+ model Node {
52
+ child?: {
53
+ subChild?: {
54
+ childNode?: Node(name='childNode'),
55
+ }(name='subChild'),
56
+ }(name='child'),
57
+ }