From 5e8aca34204e3c065217e314880ea89b2d2373af Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Mon, 3 Jun 2024 13:36:26 +0200 Subject: [PATCH] added version property to addon class --- client/ayon_core/addon/base.py | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/client/ayon_core/addon/base.py b/client/ayon_core/addon/base.py index d2c072c50c..9eb5773927 100644 --- a/client/ayon_core/addon/base.py +++ b/client/ayon_core/addon/base.py @@ -8,7 +8,7 @@ import inspect import logging import threading import collections - +import warnings from uuid import uuid4 from abc import ABCMeta, abstractmethod @@ -551,6 +551,9 @@ class AYONAddon(object): enabled = True _id = None + # Temporary variable for 'version' property + _missing_version_warned = False + def __init__(self, manager, settings): self.manager = manager @@ -581,6 +584,25 @@ class AYONAddon(object): pass + @property + def version(self): + """Addon version. + + Todo: + Should be abstract property (required). Introduced in + ayon-core 0.3.3 . + + Returns: + str: Addon version as semver compatible string. + + """ + if not self.__class__._missing_version_warned: + self.__class__._missing_version_warned = True + warnings.warn( + f"Addon '{self.name}' does not have defined version." + ) + return "0.0.0" + def initialize(self, settings): """Initialization of addon attributes.