remove unused work root function

This commit is contained in:
Kayla Man 2024-04-03 17:01:44 +08:00
parent 9ba450fe8b
commit c57411676c
21 changed files with 11 additions and 135 deletions

View file

@ -23,8 +23,7 @@ from .workio import (
save_file,
current_file,
has_unsaved_changes,
file_extensions,
work_root,
file_extensions
)
from .lib import (
@ -59,7 +58,6 @@ __all__ = [
"current_file",
"has_unsaved_changes",
"file_extensions",
"work_root",
# Utility functions
"maintained_selection",

View file

@ -40,8 +40,7 @@ from .workio import (
save_file,
current_file,
has_unsaved_changes,
file_extensions,
work_root,
file_extensions
)
@ -120,18 +119,6 @@ class BlenderHost(HostBase, IWorkfileHost, IPublishHost, ILoadHost):
"""
return has_unsaved_changes()
def work_root(self, session) -> str:
"""Override work_root method from IWorkfileHost.
Modify workdir per host.
Args:
session (dict): Session context data.
Returns:
str: Path to new workdir.
"""
return work_root(session)
def get_context_data(self) -> dict:
"""Override abstract method from IPublishHost.
Get global data related to creation-publishing from workfile.

View file

@ -77,13 +77,3 @@ def file_extensions() -> List[str]:
"""Return the supported file extensions for Blender scene files."""
return [".blend"]
def work_root(session: dict) -> str:
"""Return the default root to browse for work files."""
work_dir = session["AYON_WORKDIR"]
scene_dir = session.get("AVALON_SCENEDIR")
if scene_dir:
return str(Path(work_dir, scene_dir))
return work_dir

View file

@ -65,8 +65,7 @@ from .workio import (
save_file,
current_file,
has_unsaved_changes,
file_extensions,
work_root
file_extensions
)
from .render_utils import (
export_clip,
@ -146,7 +145,6 @@ __all__ = [
"current_file",
"has_unsaved_changes",
"file_extensions",
"work_root",
# render utils
"export_clip",

View file

@ -31,7 +31,3 @@ def open_file(filepath):
def current_file():
pass
def work_root(session):
return os.path.normpath(session["AYON_WORKDIR"]).replace("\\", "/")

View file

@ -140,15 +140,6 @@ class FusionHost(HostBase, IWorkfileHost, ILoadHost, IPublishHost):
return current_filepath
def work_root(self, session):
work_dir = session["AYON_WORKDIR"]
scene_dir = session.get("AVALON_SCENEDIR")
if scene_dir:
return os.path.join(work_dir, scene_dir)
else:
return work_dir
# endregion
@contextlib.contextmanager
def maintained_selection(self):
from .lib import maintained_selection

View file

@ -42,8 +42,7 @@ from .workio import (
save_file,
current_file,
has_unsaved_changes,
file_extensions,
work_root
file_extensions
)
__all__ = [
@ -84,7 +83,6 @@ __all__ = [
"save_file",
"current_file",
"has_unsaved_changes",
"file_extensions",
"work_root",
"file_extensions"
]

View file

@ -71,7 +71,3 @@ def open_file(filepath):
def current_file():
"""Returning None to make Workfiles app look at first file extension."""
return None
def work_root(session):
return os.path.normpath(session["AYON_WORKDIR"]).replace("\\", "/")

View file

@ -3,8 +3,7 @@ from .workio import (
save_file,
current_file,
has_unsaved_changes,
file_extensions,
work_root
file_extensions
)
from .pipeline import (
@ -84,8 +83,7 @@ __all__ = [
"save_file",
"current_file",
"has_unsaved_changes",
"file_extensions",
"work_root",
"file_extensions"
# Constants
"OPENPYPE_TAG_NAME",

View file

@ -67,7 +67,3 @@ def current_file():
if not current_file:
return None
return os.path.normpath(current_file)
def work_root(session):
return os.path.normpath(session["AYON_WORKDIR"]).replace("\\", "/")

View file

@ -21,8 +21,7 @@ from .workio import (
save_file,
current_file,
has_unsaved_changes,
file_extensions,
work_root
file_extensions
)
from .lib import (
@ -53,8 +52,7 @@ __all__ = [
"save_file",
"current_file",
"has_unsaved_changes",
"file_extensions",
"work_root",
"file_extensions"
# Utility functions
"lsattr",

View file

@ -53,7 +53,6 @@ from .workio import (
save_file,
file_extensions,
has_unsaved_changes,
work_root,
current_file
)
@ -133,9 +132,6 @@ class MayaHost(HostBase, IWorkfileHost, ILoadHost, IPublishHost):
def save_workfile(self, filepath=None):
return save_file(filepath)
def work_root(self, session):
return work_root(session)
def get_current_workfile(self):
return current_file()

View file

@ -32,35 +32,3 @@ def current_file():
return None
return current_filepath
def work_root(session):
work_dir = session["AYON_WORKDIR"]
scene_dir = None
# Query scene file rule from workspace.mel if it exists in WORKDIR
# We are parsing the workspace.mel manually as opposed to temporarily
# setting the Workspace in Maya in a context manager since Maya had a
# tendency to crash on frequently changing the workspace when this
# function was called many times as one scrolled through Work Files assets.
workspace_mel = os.path.join(work_dir, "workspace.mel")
if os.path.exists(workspace_mel):
scene_rule = 'workspace -fr "scene" '
# We need to use builtins as `open` is overridden by the workio API
open_file = __builtins__["open"]
with open_file(workspace_mel, "r") as f:
for line in f:
if line.strip().startswith(scene_rule):
# remainder == "rule";
remainder = line[len(scene_rule):]
# scene_dir == rule
scene_dir = remainder.split('"')[1]
else:
# We can't query a workspace that does not exist
# so we return similar to what we do in other hosts.
scene_dir = session.get("AVALON_SCENEDIR")
if scene_dir:
return os.path.join(work_dir, scene_dir)
else:
return work_dir

View file

@ -3,8 +3,7 @@ from .workio import (
has_unsaved_changes,
save_file,
open_file,
current_file,
work_root,
current_file
)
from .command import (
viewer_update_and_undo_stop
@ -61,7 +60,6 @@ __all__ = (
"save_file",
"open_file",
"current_file",
"work_root",
"viewer_update_and_undo_stop",

View file

@ -64,7 +64,6 @@ from .workio import (
save_file,
file_extensions,
has_unsaved_changes,
work_root,
current_file
)
from .constants import ASSIST
@ -93,9 +92,6 @@ class NukeHost(
def save_workfile(self, filepath=None):
return save_file(filepath)
def work_root(self, session):
return work_root(session)
def get_current_workfile(self):
return current_file()

View file

@ -64,15 +64,3 @@ def current_file():
return None
return os.path.normpath(current_file).replace("\\", "/")
def work_root(session):
work_dir = session["AYON_WORKDIR"]
scene_dir = session.get("AVALON_SCENEDIR")
if scene_dir:
path = os.path.join(work_dir, scene_dir)
else:
path = work_dir
return os.path.normpath(path).replace("\\", "/")

View file

@ -63,9 +63,6 @@ class PhotoshopHost(HostBase, IWorkfileHost, ILoadHost, IPublishHost):
return None
def work_root(self, session):
return os.path.normpath(session["AYON_WORKDIR"]).replace("\\", "/")
def open_workfile(self, filepath):
lib.stub().open(filepath)

View file

@ -58,8 +58,7 @@ from .workio import (
save_file,
current_file,
has_unsaved_changes,
file_extensions,
work_root
file_extensions
)
from .testing_utils import TestGUI
@ -127,7 +126,6 @@ __all__ = [
"current_file",
"has_unsaved_changes",
"file_extensions",
"work_root",
"TestGUI"
]

View file

@ -27,7 +27,6 @@ from .workio import (
save_file,
file_extensions,
has_unsaved_changes,
work_root,
current_file
)
@ -78,9 +77,6 @@ class ResolveHost(HostBase, IWorkfileHost, ILoadHost):
def save_workfile(self, filepath=None):
return save_file(filepath)
def work_root(self, session):
return work_root(session)
def get_current_workfile(self):
return current_file()

View file

@ -90,7 +90,3 @@ def current_file():
# return current file path if it exists
if os.path.exists(current_file_path):
return os.path.normpath(current_file_path)
def work_root(session):
return os.path.normpath(session["AYON_WORKDIR"]).replace("\\", "/")

View file

@ -155,9 +155,6 @@ class TVPaintHost(HostBase, IWorkfileHost, ILoadHost, IPublishHost):
george_script = "tv_SaveProject {}".format(filepath.replace("\\", "/"))
return execute_george(george_script)
def work_root(self, session):
return session["AYON_WORKDIR"]
def get_current_workfile(self):
return execute_george("tv_GetProjectName")