codegen-2 2.8.2__tar.gz → 2.9.0__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.
- {codegen_2-2.8.2 → codegen_2-2.9.0}/PKG-INFO +1 -1
- {codegen_2-2.8.2 → codegen_2-2.9.0}/codegen/models/expr.py +14 -3
- {codegen_2-2.8.2 → codegen_2-2.9.0}/pyproject.toml +1 -1
- {codegen_2-2.8.2 → codegen_2-2.9.0}/LICENSE +0 -0
- {codegen_2-2.8.2 → codegen_2-2.9.0}/README.md +0 -0
- {codegen_2-2.8.2 → codegen_2-2.9.0}/codegen/__init__.py +0 -0
- {codegen_2-2.8.2 → codegen_2-2.9.0}/codegen/models/__init__.py +0 -0
- {codegen_2-2.8.2 → codegen_2-2.9.0}/codegen/models/ast.py +0 -0
- {codegen_2-2.8.2 → codegen_2-2.9.0}/codegen/models/program.py +0 -0
- {codegen_2-2.8.2 → codegen_2-2.9.0}/codegen/models/statement.py +0 -0
- {codegen_2-2.8.2 → codegen_2-2.9.0}/codegen/models/types.py +0 -0
- {codegen_2-2.8.2 → codegen_2-2.9.0}/codegen/models/var.py +0 -0
|
@@ -254,7 +254,7 @@ class ExprTernary(Expr):
|
|
|
254
254
|
return f"{self.true_expr.to_python()} if {self.condition.to_python()} else {self.false_expr.to_python()}"
|
|
255
255
|
|
|
256
256
|
def to_typescript(self):
|
|
257
|
-
return f"{self.
|
|
257
|
+
return f"{self.condition.to_typescript()} ? {self.true_expr.to_typescript()} : {self.false_expr.to_typescript()}"
|
|
258
258
|
|
|
259
259
|
|
|
260
260
|
class PredefinedFn:
|
|
@@ -361,15 +361,26 @@ class PredefinedFn:
|
|
|
361
361
|
class map_list(Expr):
|
|
362
362
|
collection: Expr
|
|
363
363
|
func: Expr
|
|
364
|
-
|
|
365
|
-
|
|
364
|
+
filter: Optional[Expr] = None
|
|
365
|
+
|
|
366
|
+
def __init__(
|
|
367
|
+
self,
|
|
368
|
+
collection: Expr,
|
|
369
|
+
func: Callable[[ExprIdent], Expr],
|
|
370
|
+
filter: Optional[Callable[[ExprIdent], Expr]] = None,
|
|
371
|
+
):
|
|
366
372
|
self.collection = collection
|
|
367
373
|
self.func = func(ExprIdent("_x"))
|
|
374
|
+
self.filter = filter(ExprIdent("_x")) if filter is not None else None
|
|
368
375
|
|
|
369
376
|
def to_python(self):
|
|
377
|
+
if self.filter is not None:
|
|
378
|
+
return f"[{self.func.to_python()} for _x in {self.collection.to_python()} if {self.filter.to_python()}]"
|
|
370
379
|
return f"[{self.func.to_python()} for _x in {self.collection.to_python()}]"
|
|
371
380
|
|
|
372
381
|
def to_typescript(self):
|
|
382
|
+
if self.filter is not None:
|
|
383
|
+
return f"{self.collection.to_typescript()}.filter((_x: any) => {self.filter.to_typescript()}).map((_x: any) => {self.func.to_typescript()})"
|
|
373
384
|
return f"{self.collection.to_typescript()}.map((_x: any) => {self.func.to_typescript()})"
|
|
374
385
|
|
|
375
386
|
@dataclass
|
|
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
|