-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Michel Hidalgo <mhidalgo@theaiinstitute.com>
- Loading branch information
1 parent
539c962
commit 8793817
Showing
4 changed files
with
31 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,19 @@ | ||
# Copyright (c) 2024 Boston Dynamics AI Institute Inc. All rights reserved. | ||
|
||
import importlib | ||
import pkgutil | ||
import sys | ||
|
||
sys.modules[__name__] = __import__("synchros2") | ||
|
||
def aliased_import(name, alias): | ||
"""Import a module or a package using an alias for it. | ||
For packages, this function will recursively import all its subpackages and modules. | ||
""" | ||
sys.modules[alias] = module = importlib.import_module(name) | ||
if hasattr(module, "__path__"): | ||
for info in pkgutil.iter_modules(module.__path__): | ||
aliased_import(f"{name}.{info.name}", f"{alias}.{info.name}") | ||
|
||
|
||
aliased_import("synchros2", alias=__name__) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Copyright (c) 2024 Boston Dynamics AI Institute Inc. All rights reserved. | ||
|
||
import bdai_ros2_wrappers.scope | ||
import synchros2.scope | ||
|
||
|
||
def test_submodule_aliasing() -> None: | ||
assert id(bdai_ros2_wrappers.scope) == id(synchros2.scope) | ||
|
||
|
||
def test_global_aliasing() -> None: | ||
with bdai_ros2_wrappers.scope.top(global_=True) as top: | ||
assert synchros2.scope.current() is top |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters