示例#1
0
文件: idol_mar.py 项目: corps/idol
 def map_field_composer(self) -> Alt["FieldExpressionComposer"]:
     if self.ts_decon.get_map():
         return Alt.lift(
             FieldExpressionComposer(
                 import_expr(
                     self.idol_mar.marshmallow_field_exported("Dict"))))
     return Alt.empty()
示例#2
0
    def default_factory_expr(self) -> Alt[Expression]:
        for declared_enum in self.codegen_file.declared_field_constructor:

            def inner(state: GeneratorAcc, path: Path) -> str:
                return scripter.thunk(
                    scripter.invocation(
                        "next",
                        scripter.invocation(
                            "iter", state.import_ident(path, declared_enum))))

            return Alt.lift(inner)

        return Alt.empty()
示例#3
0
文件: idol_mar.py 项目: corps/idol
    def declared_field(self) -> Alt[Exported]:
        for declared_schema in self.declared_schema:
            schema_expr: Expression = import_expr(declared_schema)

            if self.codegen_file.t.named.qualified_name in self.config.params.scaffold_types.obj:
                for scaffold_declared_schema in self.codegen_file.idol_mar.scaffold_file(
                        self.codegen_file.t.named).declared_schema:

                    def lazy_import(state: GeneratorAcc, path: Path) -> str:
                        import_module = state.import_ident(
                            path, Exported(Path("importlib"), "import_module"))

                        return scripter.prop_access(
                            scripter.invocation(
                                import_module,
                                scripter.literal(
                                    ImportPath.as_python_module_path(
                                        path.import_path_to(
                                            scaffold_declared_schema.path).
                                        rel_path)),
                                "__package__",
                            ),
                            scaffold_declared_schema.ident,
                        )

                    schema_expr = lazy_import

            return Alt.lift(
                self.export(
                    self.codegen_file.default_field_name,
                    scripter.assignable(
                        self.apply_expr(
                            FieldExpressionComposer(
                                import_expr(
                                    self.codegen_file.idol_mar.
                                    marshmallow_field_exported("Nested")),
                                [self.apply_expr(schema_expr)],
                            ).curried_field_declaration_expr(
                                self.codegen_file.default_field_name,
                                self.codegen_file.idol_mar))),
                ))

        return Alt.empty()
示例#4
0
文件: idol_mar.py 项目: corps/idol
 def declared_default_factory(self) -> Alt[Exported]:
     return Alt.empty()