From 15c03de4852ee337cc4f80a46543929bb9a559d2 Mon Sep 17 00:00:00 2001 From: iLLiCiTiT Date: Tue, 3 Nov 2020 10:54:10 +0100 Subject: [PATCH] moved `get_avalon_database` and `set_io_database` to deprecated --- pype/lib/__init__.py | 10 ++++++++-- pype/lib/deprecated.py | 26 ++++++++++++++++++++++++++ pype/lib/lib_old.py | 10 +--------- 3 files changed, 35 insertions(+), 11 deletions(-) diff --git a/pype/lib/__init__.py b/pype/lib/__init__.py index 12633959aa..4ca5fa999c 100644 --- a/pype/lib/__init__.py +++ b/pype/lib/__init__.py @@ -1,5 +1,10 @@ # -*- coding: utf-8 -*- """Pype lib module.""" + +from .deprecated import ( + get_avalon_database, + set_io_database +) from .lib_old import ( _subprocess, get_paths_from_environ, @@ -19,8 +24,6 @@ from .lib_old import ( get_project, get_version_from_path, get_last_version_from_path, - get_avalon_database, - set_io_database, get_subsets, CustomNone, get_linked_assets, @@ -38,6 +41,9 @@ from .hooks import PypeHook, execute_hook from .plugin_tools import filter_pyblish_plugins __all__ = [ + "get_avalon_database", + "set_io_database", + "PypeHook", "execute_hook", diff --git a/pype/lib/deprecated.py b/pype/lib/deprecated.py index e69de29bb2..e7296f67ef 100644 --- a/pype/lib/deprecated.py +++ b/pype/lib/deprecated.py @@ -0,0 +1,26 @@ +import os + +from avalon import io + + +def get_avalon_database(): + """Mongo database used in avalon's io. + + * Function is not used in pype 3.0 where was replaced with usage of + AvalonMongoDB. + """ + if io._database is None: + set_io_database() + return io._database + + +def set_io_database(): + """Set avalon's io context with environemnts. + + * Function is not used in pype 3.0 where was replaced with usage of + AvalonMongoDB. + """ + required_keys = ["AVALON_PROJECT", "AVALON_ASSET", "AVALON_SILO"] + for key in required_keys: + os.environ[key] = os.environ.get(key, "") + io.install() diff --git a/pype/lib/lib_old.py b/pype/lib/lib_old.py index 08146309cc..7284a1026d 100644 --- a/pype/lib/lib_old.py +++ b/pype/lib/lib_old.py @@ -13,6 +13,7 @@ import getpass import acre import platform from pype.lib.hooks import execute_hook +from .deprecated import get_avalon_database from avalon import io, pipeline import avalon.api @@ -535,17 +536,8 @@ def get_last_version_from_path(path_dir, filter): return None -def get_avalon_database(): - if io._database is None: - set_io_database() - return io._database -def set_io_database(): - required_keys = ["AVALON_PROJECT", "AVALON_ASSET", "AVALON_SILO"] - for key in required_keys: - os.environ[key] = os.environ.get(key, "") - io.install() def get_subsets(asset_name,