Builds an execution environment for a cadquery script. The environment includes the builtins, as well as the other methods the script will need.
| 418 | |
| 419 | |
| 420 | class EnvironmentBuilder(object): |
| 421 | """ |
| 422 | Builds an execution environment for a cadquery script. |
| 423 | The environment includes the builtins, as well as |
| 424 | the other methods the script will need. |
| 425 | """ |
| 426 | |
| 427 | def __init__(self): |
| 428 | self.env = {} |
| 429 | |
| 430 | def with_real_builtins(self): |
| 431 | return self.with_builtins(__builtins__) |
| 432 | |
| 433 | def with_builtins(self, env_dict): |
| 434 | self.env["__builtins__"] = env_dict |
| 435 | return self |
| 436 | |
| 437 | def with_cadquery_objects(self): |
| 438 | self.env["cadquery"] = cadquery |
| 439 | self.env["cq"] = cadquery |
| 440 | return self |
| 441 | |
| 442 | def add_entry(self, name, value): |
| 443 | self.env[name] = value |
| 444 | return self |
| 445 | |
| 446 | def build(self): |
| 447 | return self.env |
| 448 | |
| 449 | |
| 450 | class ParameterDescriptionFinder(ast.NodeTransformer): |