Esempio n. 1
0
 def inner(state: GeneratorAcc, path: Path) -> str:
     return scripter.index_access(
         state.import_ident(path, Exported(Path("typing"),
                                           "Mapping")),
         "str",
         scalar_typing_expr(state, path),
     )
Esempio n. 2
0
 def inner(state: GeneratorAcc, path: Path) -> str:
     return scripter.invocation(
         scripter.prop_access(
             state.import_ident(
                 path, self.idol_py.idol_py_file.primitive), "of"),
         prim_expr(state, path),
     )
Esempio n. 3
0
 def inner(state: GeneratorAcc, path: Path) -> str:
     return scripter.invocation(
         scripter.prop_access(
             state.import_ident(path,
                                self.idol_py.idol_py_file.literal),
             "of"),
         scripter.literal(value),
     )
Esempio n. 4
0
 def expr(state: GeneratorAcc, path: Path) -> str:
     args, kwds = self.resolve_args_and_kwds(state, path)
     return scripter.invocation(
         state.import_ident(path, idol_mar.idol_mar_file.wrap_field),
         self.constructor_ident(state, path),
         scripter.literal(name),
         *list(scripter.thunk(arg) for arg in args),
         **kwds,
     )
Esempio n. 5
0
        def expr(state: GeneratorAcc, path: Path) -> str:
            kwds = {}
            if default:
                kwds["default"] = default(state, path)
            if default_factory:
                kwds["default_factory"] = default_factory(state, path)

            return scripter.invocation(
                state.import_ident(path, Exported(Path("dataclasses"),
                                                  "field")), **kwds)
Esempio n. 6
0
 def __init__(
     self,
     config: GeneratorConfig,
     scaffold_impl:
     "Callable[[IdolPy, Type, Path], IdolPyScaffoldFile]" = None,
     codegen_impl:
     "Callable[[IdolPy, Type, Path], IdolPyCodegenFile]" = None,
 ):
     super(IdolPy, self).__init__(GeneratorAcc(), config)
     self.scaffolds = {}
     self.codegens = {}
     self.scaffold_impl = scaffold_impl or IdolPyScaffoldFile
     self.codegen_impl = codegen_impl or IdolPyCodegenFile
Esempio n. 7
0
                    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,
                        )
Esempio n. 8
0
 def __init__(self, config: GeneratorConfig):
     super(IdolMarshmallow, self).__init__(GeneratorAcc(), config)
     self.scaffolds = {}
     self.codegens = {}
Esempio n. 9
0
 def __init__(self, config: GeneratorConfig):
     super(IdolDataclass, self).__init__(GeneratorAcc(), config)
     self.scaffolds = {}
     self.codegens = {}
Esempio n. 10
0
 def inner(state: GeneratorAcc, path: Path) -> str:
     return scripter.index_access(
         state.import_ident(path,
                            Exported(Path("typing"), "Optional")),
         inner_expr(state, path),
     )
Esempio n. 11
0
 def inner(state: GeneratorAcc, path: Path) -> str:
     return scripter.thunk(
         scripter.invocation(
             "next",
             scripter.invocation(
                 "iter", state.import_ident(path, declared_enum))))
Esempio n. 12
0
 def any_expr(state: GeneratorAcc, path: Path) -> str:
     return state.import_ident(path, Exported(Path("typing"), "Any"))