Skip to content

Commit 5b124e2

Browse files
committed
add unload_modules to compas_blender
1 parent 25e2891 commit 5b124e2

File tree

3 files changed

+36
-0
lines changed

3 files changed

+36
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1010
### Added
1111

1212
* Added `RobotModel.remove_link`, `RobotModel.remove_joint`, `RobotModel.to_urdf_string`, and `RobotModel.ensure_geometry`.
13+
* Added `compas_blender.unload_modules`.
1314

1415
### Changed
1516

src/compas_blender/utilities/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@
6565
from .objects import * # noqa: F401 F403
6666
from .collections import * # noqa: F401 F403
6767
from .drawing import * # noqa: F401 F403
68+
from .misc import * # noqa: F401 F403
6869

6970

7071
__all__ = [name for name in dir() if not name.startswith('_')]
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
from __future__ import absolute_import
2+
from __future__ import division
3+
from __future__ import print_function
4+
5+
import sys
6+
7+
8+
__all__ = [
9+
'unload_modules',
10+
]
11+
12+
13+
def unload_modules(top_level_module_name):
14+
"""Unloads all modules named starting with the specified string.
15+
16+
This function eases the development workflow when editing a library that is
17+
used from Blender.
18+
19+
Parameters
20+
----------
21+
top_level_module_name : :obj:`str`
22+
Name of the top-level module to unload.
23+
24+
Returns
25+
-------
26+
list
27+
List of unloaded module names.
28+
"""
29+
modules = list(filter(lambda m: m.startswith(top_level_module_name), sys.modules))
30+
31+
for module in modules:
32+
sys.modules.pop(module)
33+
34+
return modules

0 commit comments

Comments
 (0)