Changeset View
Changeset View
Standalone View
Standalone View
rigify/rig_lists.py
| Show All 12 Lines | |||||
| # You should have received a copy of the GNU General Public License | # You should have received a copy of the GNU General Public License | ||||
| # along with this program; if not, write to the Free Software Foundation, | # along with this program; if not, write to the Free Software Foundation, | ||||
| # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||||
| # | # | ||||
| #======================= END GPL LICENSE BLOCK ======================== | #======================= END GPL LICENSE BLOCK ======================== | ||||
| import os | import os | ||||
| import traceback | import traceback | ||||
| import importlib | |||||
| from . import utils | from . import utils | ||||
| from . import feature_set_list | from . import feature_set_list | ||||
| def get_rigs(base_dir, base_path, *, path=[], feature_set=feature_set_list.DEFAULT_NAME): | def get_rigs(base_dir, base_path, *, path=[], feature_set=feature_set_list.DEFAULT_NAME): | ||||
| """ Recursively searches for rig types, and returns a list. | """ Recursively searches for rig types, and returns a list. | ||||
| Show All 29 Lines | for f in files: | ||||
| # Check for sub-rigs | # Check for sub-rigs | ||||
| sub_rigs, sub_impls = get_rigs(base_dir, base_path, path=[*path, f], feature_set=feature_set) | sub_rigs, sub_impls = get_rigs(base_dir, base_path, path=[*path, f], feature_set=feature_set) | ||||
| rigs.update(sub_rigs) | rigs.update(sub_rigs) | ||||
| impl_rigs.update(sub_impls) | impl_rigs.update(sub_impls) | ||||
| elif f.endswith(".py"): | elif f.endswith(".py"): | ||||
| # Check straight-up python files | # Check straight-up python files | ||||
| subpath = [*path, f[:-3]] | subpath = [*path, f[:-3]] | ||||
| key = '.'.join(subpath) | key = '.'.join(subpath) | ||||
| rig_module = utils.get_resource('.'.join(base_path + subpath)) | # Don't reload rig modules - it breaks isinstance | ||||
| rig_module = importlib.import_module('.'.join(base_path + subpath)) | |||||
| if hasattr(rig_module, "Rig"): | if hasattr(rig_module, "Rig"): | ||||
| rigs[key] = {"module": rig_module, | rigs[key] = {"module": rig_module, | ||||
| "feature_set": feature_set} | "feature_set": feature_set} | ||||
| if hasattr(rig_module, 'IMPLEMENTATION') and rig_module.IMPLEMENTATION: | if hasattr(rig_module, 'IMPLEMENTATION') and rig_module.IMPLEMENTATION: | ||||
| impl_rigs[key] = rig_module | impl_rigs[key] = rig_module | ||||
| return rigs, impl_rigs | return rigs, impl_rigs | ||||
| Show All 34 Lines | |||||