mirror of
https://github.com/ynput/ayon-core.git
synced 2026-01-01 16:34:53 +01:00
it is possible to retrieve settings with metadata and with or without local settings
This commit is contained in:
parent
1b7e705419
commit
f5830d9b15
1 changed files with 55 additions and 19 deletions
|
|
@ -645,13 +645,22 @@ def apply_local_settings_on_project_settings(
|
|||
sync_server_config["remote_site"] = remote_site
|
||||
|
||||
|
||||
def get_system_settings(clear_metadata=True):
|
||||
def get_system_settings(clear_metadata=True, exclude_locals=None):
|
||||
"""System settings with applied studio overrides."""
|
||||
default_values = get_default_settings()[SYSTEM_SETTINGS_KEY]
|
||||
studio_values = get_studio_system_settings_overrides()
|
||||
result = apply_overrides(default_values, studio_values)
|
||||
|
||||
# Clear overrides metadata from settings
|
||||
if clear_metadata:
|
||||
clear_metadata_from_settings(result)
|
||||
|
||||
# Apply local settings
|
||||
# Default behavior is based on `clear_metadata` value
|
||||
if exclude_locals is None:
|
||||
exclude_locals = not clear_metadata
|
||||
|
||||
if not exclude_locals:
|
||||
# TODO local settings may be required to apply for environments
|
||||
local_settings = get_local_settings()
|
||||
apply_local_settings_on_system_settings(result, local_settings)
|
||||
|
|
@ -659,40 +668,52 @@ def get_system_settings(clear_metadata=True):
|
|||
return result
|
||||
|
||||
|
||||
def get_default_project_settings(clear_metadata=True, exclude_locals=False):
|
||||
def get_default_project_settings(clear_metadata=True, exclude_locals=None):
|
||||
"""Project settings with applied studio's default project overrides."""
|
||||
default_values = get_default_settings()[PROJECT_SETTINGS_KEY]
|
||||
studio_values = get_studio_project_settings_overrides()
|
||||
result = apply_overrides(default_values, studio_values)
|
||||
# Clear overrides metadata from settings
|
||||
if clear_metadata:
|
||||
clear_metadata_from_settings(result)
|
||||
if not exclude_locals:
|
||||
local_settings = get_local_settings()
|
||||
apply_local_settings_on_project_settings(
|
||||
result, local_settings, None
|
||||
)
|
||||
|
||||
# Apply local settings
|
||||
if exclude_locals is None:
|
||||
exclude_locals = not clear_metadata
|
||||
|
||||
if not exclude_locals:
|
||||
local_settings = get_local_settings()
|
||||
apply_local_settings_on_project_settings(
|
||||
result, local_settings, None
|
||||
)
|
||||
return result
|
||||
|
||||
|
||||
def get_default_anatomy_settings(clear_metadata=True, exclude_locals=False):
|
||||
def get_default_anatomy_settings(clear_metadata=True, exclude_locals=None):
|
||||
"""Project anatomy data with applied studio's default project overrides."""
|
||||
default_values = get_default_settings()[PROJECT_ANATOMY_KEY]
|
||||
studio_values = get_studio_project_anatomy_overrides()
|
||||
|
||||
# TODO uncomment and remove hotfix result when overrides of anatomy
|
||||
# are stored correctly.
|
||||
result = apply_overrides(default_values, studio_values)
|
||||
# Clear overrides metadata from settings
|
||||
if clear_metadata:
|
||||
clear_metadata_from_settings(result)
|
||||
if not exclude_locals:
|
||||
local_settings = get_local_settings()
|
||||
apply_local_settings_on_anatomy_settings(
|
||||
result, local_settings, None
|
||||
)
|
||||
|
||||
# Apply local settings
|
||||
if exclude_locals is None:
|
||||
exclude_locals = not clear_metadata
|
||||
|
||||
if not exclude_locals:
|
||||
local_settings = get_local_settings()
|
||||
apply_local_settings_on_anatomy_settings(
|
||||
result, local_settings, None
|
||||
)
|
||||
return result
|
||||
|
||||
|
||||
def get_anatomy_settings(project_name, site_name=None, exclude_locals=False):
|
||||
def get_anatomy_settings(
|
||||
project_name, site_name=None, clear_metadata=True, exclude_locals=None
|
||||
):
|
||||
"""Project anatomy data with applied studio and project overrides."""
|
||||
if not project_name:
|
||||
raise ValueError(
|
||||
|
|
@ -709,7 +730,13 @@ def get_anatomy_settings(project_name, site_name=None, exclude_locals=False):
|
|||
for key, value in project_overrides.items():
|
||||
result[key] = value
|
||||
|
||||
clear_metadata_from_settings(result)
|
||||
# Clear overrides metadata from settings
|
||||
if clear_metadata:
|
||||
clear_metadata_from_settings(result)
|
||||
|
||||
# Apply local settings
|
||||
if exclude_locals is None:
|
||||
exclude_locals = not clear_metadata
|
||||
|
||||
if not exclude_locals:
|
||||
local_settings = get_local_settings()
|
||||
|
|
@ -719,7 +746,9 @@ def get_anatomy_settings(project_name, site_name=None, exclude_locals=False):
|
|||
return result
|
||||
|
||||
|
||||
def get_project_settings(project_name, exclude_locals=False):
|
||||
def get_project_settings(
|
||||
project_name, clear_metadata=True, exclude_locals=None
|
||||
):
|
||||
"""Project settings with applied studio and project overrides."""
|
||||
if not project_name:
|
||||
raise ValueError(
|
||||
|
|
@ -733,7 +762,14 @@ def get_project_settings(project_name, exclude_locals=False):
|
|||
)
|
||||
|
||||
result = apply_overrides(studio_overrides, project_overrides)
|
||||
clear_metadata_from_settings(result)
|
||||
|
||||
# Clear overrides metadata from settings
|
||||
if clear_metadata:
|
||||
clear_metadata_from_settings(result)
|
||||
|
||||
# Apply local settings
|
||||
if exclude_locals is None:
|
||||
exclude_locals = not clear_metadata
|
||||
|
||||
if not exclude_locals:
|
||||
local_settings = get_local_settings()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue