mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-27 14:22:37 +01:00
removed constants from entities
This commit is contained in:
parent
a7ae6ce9cd
commit
08efc48a87
10 changed files with 92 additions and 130 deletions
|
|
@ -1,11 +1,7 @@
|
|||
from . import (
|
||||
constants,
|
||||
base_entity,
|
||||
item_entities,
|
||||
input_entities,
|
||||
lib
|
||||
from .lib import (
|
||||
NOT_SET,
|
||||
OverrideState
|
||||
)
|
||||
from .lib import NOT_SET
|
||||
from .base_entity import (
|
||||
BaseEntity,
|
||||
SystemRootEntity
|
||||
|
|
@ -33,12 +29,6 @@ from .dict_immutable_keys_entity import DictImmutableKeysEntity
|
|||
from .dict_mutable_keys_entity import DictMutableKeysEntity
|
||||
|
||||
__all__ = (
|
||||
"constants",
|
||||
"base_entity",
|
||||
"item_entities",
|
||||
"input_entities",
|
||||
"lib",
|
||||
|
||||
"NOT_SET",
|
||||
|
||||
"BaseEntity",
|
||||
|
|
|
|||
|
|
@ -10,12 +10,9 @@ import six
|
|||
|
||||
from .lib import (
|
||||
NOT_SET,
|
||||
gui_schema
|
||||
)
|
||||
from .constants import (
|
||||
SYSTEM_SETTINGS_KEY,
|
||||
WRAPPER_TYPES,
|
||||
OverrideState
|
||||
OverrideState,
|
||||
gui_schema
|
||||
)
|
||||
from pype.settings.lib import (
|
||||
DEFAULTS_DIR,
|
||||
|
|
@ -30,6 +27,8 @@ from pype.settings.lib import (
|
|||
apply_overrides,
|
||||
DuplicatedEnvGroups
|
||||
)
|
||||
from pype.settings.constants import SYSTEM_SETTINGS_KEY
|
||||
|
||||
|
||||
# from pype.api import Logger
|
||||
class Logger:
|
||||
|
|
|
|||
|
|
@ -1,90 +0,0 @@
|
|||
# Metadata keys for work with studio and project overrides
|
||||
M_OVERRIDEN_KEY = "__overriden_keys__"
|
||||
# Metadata key for storing information about environments
|
||||
M_ENVIRONMENT_KEY = "__environment_keys__"
|
||||
# Metadata key for storing dynamic created labels
|
||||
M_DYNAMIC_KEY_LABEL = "__dynamic_keys_labels__"
|
||||
|
||||
METADATA_KEYS = (
|
||||
M_OVERRIDEN_KEY,
|
||||
M_ENVIRONMENT_KEY,
|
||||
M_DYNAMIC_KEY_LABEL
|
||||
)
|
||||
|
||||
# File where studio's system overrides are stored
|
||||
SYSTEM_SETTINGS_KEY = "system_settings"
|
||||
PROJECT_SETTINGS_KEY = "project_settings"
|
||||
PROJECT_ANATOMY_KEY = "project_anatomy"
|
||||
|
||||
WRAPPER_TYPES = ["form", "collapsible-wrap"]
|
||||
|
||||
__all__ = (
|
||||
"M_OVERRIDEN_KEY",
|
||||
"M_ENVIRONMENT_KEY",
|
||||
"M_DYNAMIC_KEY_LABEL",
|
||||
|
||||
"METADATA_KEYS",
|
||||
|
||||
"SYSTEM_SETTINGS_KEY",
|
||||
"PROJECT_SETTINGS_KEY",
|
||||
"PROJECT_ANATOMY_KEY"
|
||||
)
|
||||
|
||||
|
||||
class OverrideStateItem:
|
||||
values = set()
|
||||
|
||||
def __init__(self, value, name):
|
||||
self.name = name
|
||||
if value in self.__class__.values:
|
||||
raise ValueError(
|
||||
"Implementation bug: Override State with same value as other."
|
||||
)
|
||||
self.__class__.values.add(value)
|
||||
self.value = value
|
||||
|
||||
def __repr__(self):
|
||||
return "<object {}> {} {}".format(
|
||||
self.__class__.__name__, self.value, self.name
|
||||
)
|
||||
|
||||
def __eq__(self, other):
|
||||
"""Defines behavior for the equality operator, ==."""
|
||||
if isinstance(other, OverrideStateItem):
|
||||
return self.value == other.value
|
||||
return self.value == other
|
||||
|
||||
def __gt__(self, other):
|
||||
"""Defines behavior for the greater-than operator, >."""
|
||||
if isinstance(other, OverrideStateItem):
|
||||
return self.value > other.value
|
||||
return self.value > other
|
||||
|
||||
def __lt__(self, other):
|
||||
"""Defines behavior for the less-than operator, <."""
|
||||
if isinstance(other, OverrideStateItem):
|
||||
return self.value < other.value
|
||||
return self.value < other
|
||||
|
||||
def __le__(self, other):
|
||||
"""Defines behavior for the less-than-or-equal-to operator, <=."""
|
||||
if isinstance(other, OverrideStateItem):
|
||||
return self.value == other.value or self.value < other.value
|
||||
return self.value == other or self.value < other
|
||||
|
||||
def __ge__(self, other):
|
||||
"""Defines behavior for the greater-than-or-equal-to operator, >=."""
|
||||
if isinstance(other, OverrideStateItem):
|
||||
return self.value == other.value or self.value > other.value
|
||||
return self.value == other or self.value > other
|
||||
|
||||
|
||||
class OverrideState:
|
||||
"""Enumeration of override states.
|
||||
|
||||
Each state should have unique value.
|
||||
"""
|
||||
NOT_DEFINED = OverrideStateItem(-1, "Not defined")
|
||||
DEFAULTS = OverrideStateItem(0, "Defaults")
|
||||
STUDIO = OverrideStateItem(1, "Studio overrides")
|
||||
PROJECT = OverrideStateItem(2, "Project Overrides")
|
||||
|
|
@ -1,9 +1,11 @@
|
|||
import copy
|
||||
|
||||
from .lib import NOT_SET
|
||||
from .constants import (
|
||||
OverrideState,
|
||||
from .lib import (
|
||||
WRAPPER_TYPES,
|
||||
OverrideState,
|
||||
NOT_SET
|
||||
)
|
||||
from pype.settings.constants import (
|
||||
METADATA_KEYS,
|
||||
M_OVERRIDEN_KEY
|
||||
)
|
||||
|
|
|
|||
|
|
@ -2,15 +2,15 @@ import copy
|
|||
|
||||
from .lib import (
|
||||
NOT_SET,
|
||||
OverrideState,
|
||||
DefaultsNotDefined
|
||||
)
|
||||
from .constants import (
|
||||
OverrideState,
|
||||
from . import ItemEntity
|
||||
from pype.settings.constants import (
|
||||
METADATA_KEYS,
|
||||
M_DYNAMIC_KEY_LABEL,
|
||||
M_ENVIRONMENT_KEY
|
||||
)
|
||||
from . import ItemEntity
|
||||
|
||||
|
||||
class DictMutableKeysEntity(ItemEntity):
|
||||
|
|
|
|||
|
|
@ -2,10 +2,10 @@ import copy
|
|||
from .item_entities import ItemEntity
|
||||
from .lib import (
|
||||
NOT_SET,
|
||||
OverrideState,
|
||||
DefaultsNotDefined
|
||||
)
|
||||
from .constants import (
|
||||
OverrideState,
|
||||
from pype.settings.constants import (
|
||||
METADATA_KEYS,
|
||||
M_DYNAMIC_KEY_LABEL,
|
||||
M_ENVIRONMENT_KEY
|
||||
|
|
|
|||
|
|
@ -3,15 +3,17 @@ from abc import abstractmethod
|
|||
|
||||
from .lib import (
|
||||
NOT_SET,
|
||||
OverrideState,
|
||||
DefaultsNotDefined
|
||||
)
|
||||
from .constants import (
|
||||
OverrideState,
|
||||
|
||||
from .base_entity import BaseEntity
|
||||
|
||||
from pype.settings.constants import (
|
||||
METADATA_KEYS,
|
||||
M_ENVIRONMENT_KEY,
|
||||
M_DYNAMIC_KEY_LABEL
|
||||
)
|
||||
from .base_entity import BaseEntity
|
||||
|
||||
"""
|
||||
# TODO
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ import os
|
|||
import re
|
||||
import json
|
||||
import copy
|
||||
from .constants import (
|
||||
from pype.settings.constants import (
|
||||
M_OVERRIDEN_KEY,
|
||||
M_ENVIRONMENT_KEY,
|
||||
M_DYNAMIC_KEY_LABEL
|
||||
|
|
@ -16,10 +16,7 @@ class DefaultsNotDefined(Exception):
|
|||
super(DefaultsNotDefined, self).__init__(msg)
|
||||
|
||||
|
||||
# Singleton database of available inputs
|
||||
class TypeToKlass:
|
||||
types = {}
|
||||
|
||||
WRAPPER_TYPES = ["form", "collapsible-wrap"]
|
||||
|
||||
DEFAULTS_DIR = os.path.join(
|
||||
os.path.dirname(os.path.abspath(__file__)),
|
||||
|
|
@ -545,3 +542,62 @@ def gui_schema(subfolder, main_schema_name):
|
|||
)
|
||||
validate_schema(main_schema)
|
||||
return main_schema
|
||||
|
||||
|
||||
class OverrideStateItem:
|
||||
values = set()
|
||||
|
||||
def __init__(self, value, name):
|
||||
self.name = name
|
||||
if value in self.__class__.values:
|
||||
raise ValueError(
|
||||
"Implementation bug: Override State with same value as other."
|
||||
)
|
||||
self.__class__.values.add(value)
|
||||
self.value = value
|
||||
|
||||
def __repr__(self):
|
||||
return "<object {}> {} {}".format(
|
||||
self.__class__.__name__, self.value, self.name
|
||||
)
|
||||
|
||||
def __eq__(self, other):
|
||||
"""Defines behavior for the equality operator, ==."""
|
||||
if isinstance(other, OverrideStateItem):
|
||||
return self.value == other.value
|
||||
return self.value == other
|
||||
|
||||
def __gt__(self, other):
|
||||
"""Defines behavior for the greater-than operator, >."""
|
||||
if isinstance(other, OverrideStateItem):
|
||||
return self.value > other.value
|
||||
return self.value > other
|
||||
|
||||
def __lt__(self, other):
|
||||
"""Defines behavior for the less-than operator, <."""
|
||||
if isinstance(other, OverrideStateItem):
|
||||
return self.value < other.value
|
||||
return self.value < other
|
||||
|
||||
def __le__(self, other):
|
||||
"""Defines behavior for the less-than-or-equal-to operator, <=."""
|
||||
if isinstance(other, OverrideStateItem):
|
||||
return self.value == other.value or self.value < other.value
|
||||
return self.value == other or self.value < other
|
||||
|
||||
def __ge__(self, other):
|
||||
"""Defines behavior for the greater-than-or-equal-to operator, >=."""
|
||||
if isinstance(other, OverrideStateItem):
|
||||
return self.value == other.value or self.value > other.value
|
||||
return self.value == other or self.value > other
|
||||
|
||||
|
||||
class OverrideState:
|
||||
"""Enumeration of override states.
|
||||
|
||||
Each state should have unique value.
|
||||
"""
|
||||
NOT_DEFINED = OverrideStateItem(-1, "Not defined")
|
||||
DEFAULTS = OverrideStateItem(0, "Defaults")
|
||||
STUDIO = OverrideStateItem(1, "Studio overrides")
|
||||
PROJECT = OverrideStateItem(2, "Project Overrides")
|
||||
|
|
|
|||
|
|
@ -1,8 +1,11 @@
|
|||
import copy
|
||||
from . import BaseEntity, ItemEntity
|
||||
from .constants import OverrideState
|
||||
from . import (
|
||||
BaseEntity,
|
||||
ItemEntity
|
||||
)
|
||||
from .lib import (
|
||||
NOT_SET,
|
||||
OverrideState,
|
||||
DefaultsNotDefined
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
from Qt import QtWidgets, QtGui, QtCore
|
||||
from pype.settings.entities import constants
|
||||
from pype.settings.entities import OverrideState
|
||||
|
||||
|
||||
class BaseWidget(QtWidgets.QWidget):
|
||||
|
|
@ -72,7 +72,7 @@ class BaseWidget(QtWidgets.QWidget):
|
|||
|
||||
def _set_project_override_action(self, menu, actions_mapping):
|
||||
# Show only when project overrides are set
|
||||
if self.entity.override_state < constants.OverrideState.PROJECT:
|
||||
if self.entity.override_state < OverrideState.PROJECT:
|
||||
return
|
||||
|
||||
# Do not show on items under group item
|
||||
|
|
@ -88,7 +88,7 @@ class BaseWidget(QtWidgets.QWidget):
|
|||
menu.addAction(action)
|
||||
|
||||
def _reset_to_pype_default_action(self, menu, actions_mapping):
|
||||
if self.entity.override_state is not constants.OverrideState.STUDIO:
|
||||
if self.entity.override_state is not OverrideState.STUDIO:
|
||||
return
|
||||
|
||||
if (
|
||||
|
|
@ -102,7 +102,7 @@ class BaseWidget(QtWidgets.QWidget):
|
|||
def _set_studio_default(self, menu, actions_mapping):
|
||||
"""Set values as studio overrides."""
|
||||
# Skip if not in studio overrides
|
||||
if self.entity.override_state is not constants.OverrideState.STUDIO:
|
||||
if self.entity.override_state is not OverrideState.STUDIO:
|
||||
return
|
||||
|
||||
# Skip if entity is under group
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue