Skip to content

Commit

Permalink
Refactor to find_submodule (needed after merge of getavalon#501)
Browse files Browse the repository at this point in the history
  • Loading branch information
jasperges committed Jan 8, 2020
1 parent d14d97b commit 23331c4
Showing 1 changed file with 3 additions and 29 deletions.
32 changes: 3 additions & 29 deletions avalon/blender/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,13 @@
import pyblish.util

from .. import api, schema
from ..lib import logger
from ..lib import find_submodule, logger
from ..pipeline import AVALON_CONTAINER_ID
from . import lib, ops

self = sys.modules[__name__]
self._events = dict() # Registered Blender callbacks
self._parent = None # Main window
self._ignore_lock = False

AVALON_CONTAINERS = "AVALON_CONTAINERS"
AVALON_PROPERTY = 'avalon'
Expand Down Expand Up @@ -92,18 +91,6 @@ def _register_events():
logger.info("Installed event callback for 'taskChanged'...")


def find_host_config(config: ModuleType) -> Optional[ModuleType]:
"""Find the config for the current host (Blender)."""

config_name = f"{config.__name__}.blender"
try:
return importlib.import_module(config_name)
except ImportError as exc:
if str(exc) != f"No module named '{config_name}'":
raise
return None


def install(config: ModuleType):
"""Install Blender-specific functionality for Avalon.
Expand All @@ -118,10 +105,6 @@ def install(config: ModuleType):

pyblish.api.register_host("blender")

host_config = find_host_config(config)
if hasattr(host_config, "install"):
host_config.install()


def uninstall(config: ModuleType):
"""Uninstall Blender-specific functionality of avalon-core.
Expand All @@ -132,10 +115,6 @@ def uninstall(config: ModuleType):
config: configuration module
"""

host_config = find_host_config(config)
if hasattr(config, "uninstall"):
host_config.uninstall()

if not IS_HEADLESS:
ops.unregister()

Expand Down Expand Up @@ -364,13 +343,8 @@ def ls() -> Iterator:

containers = _ls()

has_metadata_collector = False
config = find_host_config(api.registered_config())
if config is None:
logger.error("Could not find host config for Blender")
return tuple()
if hasattr(config, "collect_container_metadata"):
has_metadata_collector = True
config = find_submodule(api.registered_config(), "blender")
has_metadata_collector = hasattr(config, "collect_container_metadata")

for container in containers:
data = parse_container(container)
Expand Down

0 comments on commit 23331c4

Please sign in to comment.