generate Python code and execute in a new environment return a dict of structures {name: class} Rmw: Since the code is generated on the fly, in case of error the stack trace is not available and debugging is very hard...
(model, env=None)
| 306 | |
| 307 | |
| 308 | def _generate_python_class(model, env=None): |
| 309 | """ |
| 310 | generate Python code and execute in a new environment |
| 311 | return a dict of structures {name: class} |
| 312 | Rmw: Since the code is generated on the fly, in case of error the stack trace is |
| 313 | not available and debugging is very hard... |
| 314 | """ |
| 315 | if env is None: |
| 316 | env = {} |
| 317 | # Add the required libraries to dict |
| 318 | if "ua" not in env: |
| 319 | env['ua'] = ua |
| 320 | if "datetime" not in env: |
| 321 | env['datetime'] = datetime |
| 322 | if "uuid" not in env: |
| 323 | env['uuid'] = uuid |
| 324 | if "enum" not in env: |
| 325 | env['IntEnum'] = IntEnum |
| 326 | # generate classes one by one and add them to dict |
| 327 | for element in model: |
| 328 | code = element.get_code() |
| 329 | exec(code, env) |
| 330 | return env |
| 331 | |
| 332 | |
| 333 | def load_enums(server, env=None): |
no test coverage detected