Skip to content

Commit

Permalink
Merge branch 'develop' of https://github.com/ynput/ayon-core into col…
Browse files Browse the repository at this point in the history
…orbleed

# Conflicts:
#	client/ayon_core/version.py
#	package.py
#	pyproject.toml
  • Loading branch information
BigRoy committed Jan 13, 2025
2 parents e52eac1 + a141237 commit f7f5904
Show file tree
Hide file tree
Showing 55 changed files with 2,079 additions and 1,332 deletions.
73 changes: 16 additions & 57 deletions client/ayon_core/addon/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -370,67 +370,11 @@ def _load_ayon_addons(log):
return all_addon_modules


def _load_addons_in_core(log):
# Add current directory at first place
# - has small differences in import logic
addon_modules = []
modules_dir = os.path.join(AYON_CORE_ROOT, "modules")
if not os.path.exists(modules_dir):
log.warning(
f"Could not find path when loading AYON addons \"{modules_dir}\""
)
return addon_modules

ignored_filenames = IGNORED_FILENAMES | IGNORED_DEFAULT_FILENAMES
for filename in os.listdir(modules_dir):
# Ignore filenames
if filename in ignored_filenames:
continue

fullpath = os.path.join(modules_dir, filename)
basename, ext = os.path.splitext(filename)

# Validations
if os.path.isdir(fullpath):
# Check existence of init file
init_path = os.path.join(fullpath, "__init__.py")
if not os.path.exists(init_path):
log.debug((
"Addon directory does not contain __init__.py"
f" file {fullpath}"
))
continue

elif ext != ".py":
continue

# TODO add more logic how to define if folder is addon or not
# - check manifest and content of manifest
try:
# Don't import dynamically current directory modules
import_str = f"ayon_core.modules.{basename}"
default_module = __import__(import_str, fromlist=("", ))
addon_modules.append(default_module)

except Exception:
log.error(
f"Failed to import in-core addon '{basename}'.",
exc_info=True
)
return addon_modules


def _load_addons():
log = Logger.get_logger("AddonsLoader")

addon_modules = _load_ayon_addons(log)
# All addon in 'modules' folder are tray actions and should be moved
# to tray tool.
# TODO remove
addon_modules.extend(_load_addons_in_core(log))

# Store modules to local cache
_LoadCache.addon_modules = addon_modules
_LoadCache.addon_modules = _load_ayon_addons(log)


class AYONAddon(ABC):
Expand Down Expand Up @@ -950,6 +894,21 @@ def _collect_plugin_paths(self, method_name, *args, **kwargs):
output.extend(paths)
return output

def collect_launcher_action_paths(self):
"""Helper to collect launcher action paths from addons.
Returns:
list: List of paths to launcher actions.
"""
output = self._collect_plugin_paths(
"get_launcher_action_paths"
)
# Add default core actions
actions_dir = os.path.join(AYON_CORE_ROOT, "plugins", "actions")
output.insert(0, actions_dir)
return output

def collect_create_plugin_paths(self, host_name):
"""Helper to collect creator plugin paths from addons.
Expand Down
47 changes: 30 additions & 17 deletions client/ayon_core/addon/interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,13 @@ def _get_plugin_paths_by_type(self, plugin_type):
paths = [paths]
return paths

def get_launcher_action_paths(self):
"""Receive launcher actions paths.
Give addons ability to add launcher actions paths.
"""
return self._get_plugin_paths_by_type("actions")

def get_create_plugin_paths(self, host_name):
"""Receive create plugin paths.
Expand Down Expand Up @@ -125,6 +132,7 @@ class ITrayAddon(AYONInterface):

tray_initialized = False
_tray_manager = None
_admin_submenu = None

@abstractmethod
def tray_init(self):
Expand Down Expand Up @@ -198,6 +206,27 @@ def add_doubleclick_callback(self, callback):
if hasattr(self.manager, "add_doubleclick_callback"):
self.manager.add_doubleclick_callback(self, callback)

@staticmethod
def admin_submenu(tray_menu):
if ITrayAddon._admin_submenu is None:
from qtpy import QtWidgets

admin_submenu = QtWidgets.QMenu("Admin", tray_menu)
admin_submenu.menuAction().setVisible(False)
ITrayAddon._admin_submenu = admin_submenu
return ITrayAddon._admin_submenu

@staticmethod
def add_action_to_admin_submenu(label, tray_menu):
from qtpy import QtWidgets

menu = ITrayAddon.admin_submenu(tray_menu)
action = QtWidgets.QAction(label, menu)
menu.addAction(action)
if not menu.menuAction().isVisible():
menu.menuAction().setVisible(True)
return action


class ITrayAction(ITrayAddon):
"""Implementation of Tray action.
Expand All @@ -211,7 +240,6 @@ class ITrayAction(ITrayAddon):
"""

admin_action = False
_admin_submenu = None
_action_item = None

@property
Expand All @@ -229,12 +257,7 @@ def tray_menu(self, tray_menu):
from qtpy import QtWidgets

if self.admin_action:
menu = self.admin_submenu(tray_menu)
action = QtWidgets.QAction(self.label, menu)
menu.addAction(action)
if not menu.menuAction().isVisible():
menu.menuAction().setVisible(True)

action = self.add_action_to_admin_submenu(self.label, tray_menu)
else:
action = QtWidgets.QAction(self.label, tray_menu)
tray_menu.addAction(action)
Expand All @@ -248,16 +271,6 @@ def tray_start(self):
def tray_exit(self):
return

@staticmethod
def admin_submenu(tray_menu):
if ITrayAction._admin_submenu is None:
from qtpy import QtWidgets

admin_submenu = QtWidgets.QMenu("Admin", tray_menu)
admin_submenu.menuAction().setVisible(False)
ITrayAction._admin_submenu = admin_submenu
return ITrayAction._admin_submenu


class ITrayService(ITrayAddon):
# Module's property
Expand Down
5 changes: 1 addition & 4 deletions client/ayon_core/host/dirmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,7 @@ def get_mappings(self):
It checks if Site Sync is enabled and user chose to use local
site, in that case configuration in Local Settings takes precedence
"""

dirmap_label = "{}-dirmap".format(self.host_name)
mapping_sett = self.project_settings[self.host_name].get(dirmap_label,
{})
mapping_sett = self.project_settings[self.host_name].get("dirmap", {})
local_mapping = self._get_local_sync_dirmap()
mapping_enabled = mapping_sett.get("enabled") or bool(local_mapping)
if not mapping_enabled:
Expand Down
3 changes: 0 additions & 3 deletions client/ayon_core/lib/path_templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -561,9 +561,6 @@ def format(
"""
key = self._template_base
if key in result.really_used_values:
result.add_output(result.really_used_values[key])
return result

# ensure key is properly formed [({})] properly closed.
if not self.validate_key_is_matched(key):
Expand Down
Empty file.
60 changes: 0 additions & 60 deletions client/ayon_core/modules/launcher_action.py

This file was deleted.

68 changes: 0 additions & 68 deletions client/ayon_core/modules/loader_action.py

This file was deleted.

This file was deleted.

42 changes: 0 additions & 42 deletions client/ayon_core/modules/python_console_interpreter/addon.py

This file was deleted.

This file was deleted.

Loading

0 comments on commit f7f5904

Please sign in to comment.