Adds namespace references to the module that exposes the api itself.
(namespace, autograph_module)
| 603 | |
| 604 | # TODO(mdan): Move into core or replace with an actual importable module. |
| 605 | def _add_self_references(namespace, autograph_module): |
| 606 | """Adds namespace references to the module that exposes the api itself.""" |
| 607 | global ag_internal |
| 608 | if ag_internal is None: |
| 609 | # Craft a module that exposes parts of the external API as well as certain |
| 610 | # internal modules. |
| 611 | ag_internal = imp.new_module('autograph') |
| 612 | ag_internal.__dict__.update(autograph_module.__dict__) |
| 613 | ag_internal.ConversionOptions = converter.ConversionOptions |
| 614 | ag_internal.STD = converter.STANDARD_OPTIONS |
| 615 | ag_internal.Feature = converter.Feature |
| 616 | ag_internal.utils = utils |
| 617 | ag_internal.FunctionScope = function_wrappers.FunctionScope |
| 618 | ag_internal.with_function_scope = function_wrappers.with_function_scope |
| 619 | # TODO(mdan): Add safeguards against name clashes. |
| 620 | # We don't want to create a submodule because we want the operators to be |
| 621 | # accessible as ag__.<operator> |
| 622 | ag_internal.__dict__.update(special_functions.__dict__) |
| 623 | ag_internal.__dict__.update(operators.__dict__) |
| 624 | |
| 625 | _add_reserved_symbol(namespace, 'ag__', ag_internal) |
| 626 | |
| 627 | |
| 628 | def convert_func_to_ast(f, program_ctx, do_rename=True): |
no test coverage detected