Skip to content

Commit e27470e

Browse files
committed
Merge branch 'master' of https://github.com/getavalon/core into activate_window
# Conflicts: # avalon/tools/contextmanager/app.py
2 parents cf137b2 + a774f04 commit e27470e

File tree

27 files changed

+1121
-711
lines changed

27 files changed

+1121
-711
lines changed

avalon/fusion/pipeline.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ def ls():
4949
yield container
5050

5151

52-
def install(config):
52+
def install():
5353
"""Install Fusion-specific functionality of avalon-core.
5454
5555
This function is called automatically on calling `api.install(fusion)`.
@@ -76,14 +76,10 @@ def install(config):
7676
logger.setLevel(logging.DEBUG)
7777

7878

79-
def uninstall(config):
79+
def uninstall():
8080
"""Uninstall Fusion-specific functionality of avalon-core.
8181
8282
This function is called automatically on calling `api.uninstall()`.
83-
84-
Args:
85-
config: configuration module
86-
8783
"""
8884

8985
pyblish.api.deregister_host("fusion")

avalon/fusion/workio.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,10 @@ def current_file():
3939
return current_filepath
4040

4141

42-
def work_root():
43-
from avalon import Session
42+
def work_root(session):
4443

45-
work_dir = Session["AVALON_WORKDIR"]
46-
scene_dir = Session.get("AVALON_SCENEDIR")
44+
work_dir = session["AVALON_WORKDIR"]
45+
scene_dir = session.get("AVALON_SCENEDIR")
4746
if scene_dir:
4847
return os.path.join(work_dir, scene_dir)
4948
else:

avalon/houdini/pipeline.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
IS_HEADLESS = not hasattr(hou, "ui")
2525

2626

27-
def install(config):
27+
def install():
2828
"""Setup integration
2929
Register plug-ins and integrate into the host
3030
@@ -40,14 +40,10 @@ def install(config):
4040
self._has_been_setup = True
4141

4242

43-
def uninstall(config):
43+
def uninstall():
4444
"""Uninstall Houdini-specific functionality of avalon-core.
4545
4646
This function is called automatically on calling `api.uninstall()`.
47-
48-
Args:
49-
config: configuration module
50-
5147
"""
5248

5349
pyblish.api.deregister_host("hython")

avalon/houdini/workio.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,10 @@ def current_file():
4848
return current_filepath
4949

5050

51-
def work_root():
52-
from avalon import Session
51+
def work_root(session):
5352

54-
work_dir = Session["AVALON_WORKDIR"]
55-
scene_dir = Session.get("AVALON_SCENEDIR")
53+
work_dir = session["AVALON_WORKDIR"]
54+
scene_dir = session.get("AVALON_SCENEDIR")
5655
if scene_dir:
5756
return os.path.join(work_dir, scene_dir)
5857
else:

avalon/io.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,14 @@ def _from_environment():
138138
# Optional path to scenes directory (see Work Files API)
139139
("AVALON_SCENEDIR", None),
140140

141+
# Optional hierarchy for the current Asset. This can be referenced
142+
# as `{hierarchy}` in your file templates.
143+
# This will be (re-)computed when you switch the context to another
144+
# asset. It is computed by checking asset['data']['parents'] and
145+
# joining those together with `os.path.sep`.
146+
# E.g.: ['ep101', 'scn0010'] -> 'ep101/scn0010'.
147+
("AVALON_HIERARCHY", None),
148+
141149
# Name of current Config
142150
# TODO(marcus): Establish a suitable default config
143151
("AVALON_CONFIG", "no_config"),

avalon/maya/pipeline.py

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
IS_HEADLESS = not hasattr(cmds, "about") or cmds.about(batch=True)
3434

3535

36-
def install(config):
36+
def install():
3737
"""Install Maya-specific functionality of avalon-core.
3838
3939
This function is called automatically on calling `api.install(maya)`.
@@ -90,7 +90,7 @@ def get_main_window():
9090
return self._parent
9191

9292

93-
def uninstall(config):
93+
def uninstall():
9494
"""Uninstall Maya-specific functionality of avalon-core.
9595
9696
This function is called automatically on calling `api.uninstall()`.
@@ -110,8 +110,7 @@ def _install_menu():
110110
creator,
111111
loader,
112112
publish,
113-
sceneinventory,
114-
contextmanager
113+
sceneinventory
115114
)
116115

117116
from . import interactive
@@ -125,19 +124,17 @@ def deferred():
125124
parent="MayaWindow")
126125

127126
# Create context menu
128-
context_label = "{}, {}".format(api.Session["AVALON_ASSET"],
129-
api.Session["AVALON_TASK"])
130-
context_menu = cmds.menuItem("currentContext",
131-
label=context_label,
132-
parent=self._menu,
133-
subMenu=True)
134-
135-
cmds.menuItem("setCurrentContext",
136-
label="Edit Context..",
137-
parent=context_menu,
138-
command=lambda *args: contextmanager.show(
139-
parent=self._parent
140-
))
127+
context_label = "{}, {}".format(
128+
api.Session["AVALON_ASSET"],
129+
api.Session["AVALON_TASK"]
130+
)
131+
132+
cmds.menuItem(
133+
"currentContext",
134+
label=context_label,
135+
parent=self._menu,
136+
enable=False
137+
)
141138

142139
cmds.setParent("..", menu=True)
143140

avalon/maya/workio.py

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,33 @@ def current_file():
3030
return current_filepath
3131

3232

33-
def work_root():
34-
35-
# Base the root on the current Maya workspace.
36-
return os.path.join(
37-
cmds.workspace(query=True, rootDirectory=True),
38-
cmds.workspace(fileRuleEntry="scene")
39-
)
33+
def work_root(session):
34+
work_dir = session["AVALON_WORKDIR"]
35+
scene_dir = None
36+
37+
# Query scene file rule from workspace.mel if it exists in WORKDIR
38+
# We are parsing the workspace.mel manually as opposed to temporarily
39+
# setting the Workspace in Maya in a context manager since Maya had a
40+
# tendency to crash on frequently changing the workspace when this
41+
# function was called many times as one scrolled through Work Files assets.
42+
workspace_mel = os.path.join(work_dir, "workspace.mel")
43+
if os.path.exists(workspace_mel):
44+
scene_rule = 'workspace -fr "scene" '
45+
# We need to use builtins as `open` is overridden by the workio API
46+
open_file = __builtins__["open"]
47+
with open_file(workspace_mel, "r") as f:
48+
for line in f:
49+
if line.strip().startswith(scene_rule):
50+
# remainder == "rule";
51+
remainder = line[len(scene_rule):]
52+
# scene_dir == rule
53+
scene_dir = remainder.split('"')[1]
54+
else:
55+
# We can't query a workspace that does not exist
56+
# so we return similar to what we do in other hosts.
57+
scene_dir = session.get("AVALON_SCENEDIR")
58+
59+
if scene_dir:
60+
return os.path.join(work_dir, scene_dir)
61+
else:
62+
return work_dir

avalon/nuke/pipeline.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ def ls():
209209
yield container
210210

211211

212-
def install(config):
212+
def install():
213213
"""Install Nuke-specific functionality of avalon-core.
214214
215215
This is where you install menus and register families, data
@@ -241,7 +241,7 @@ def get_main_window():
241241
return self._parent
242242

243243

244-
def uninstall(config):
244+
def uninstall():
245245
"""Uninstall all that was previously installed
246246
247247
This is where you undo everything that was done in `install()`.
@@ -266,8 +266,7 @@ def _install_menu():
266266
publish,
267267
workfiles,
268268
loader,
269-
sceneinventory,
270-
contextmanager
269+
sceneinventory
271270
)
272271

273272
# Create menu
@@ -277,11 +276,9 @@ def _install_menu():
277276
label = "{0}, {1}".format(
278277
api.Session["AVALON_ASSET"], api.Session["AVALON_TASK"]
279278
)
280-
context_menu = menu.addMenu(label)
281-
context_menu.addCommand("Set Context",
282-
lambda: contextmanager.show(
283-
parent=get_main_window())
284-
)
279+
context_action = menu.addCommand(label)
280+
context_action.setEnabled(False)
281+
285282
menu.addSeparator()
286283
menu.addCommand("Create...",
287284
lambda: creator.show(parent=get_main_window()))

avalon/nuke/workio.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,13 @@ def current_file():
4242
return os.path.normpath(current_file).replace("\\", "/")
4343

4444

45-
def work_root():
46-
from avalon import Session
47-
return os.path.normpath(Session["AVALON_WORKDIR"]).replace("\\", "/")
45+
def work_root(session):
46+
47+
work_dir = session["AVALON_WORKDIR"]
48+
scene_dir = session.get("AVALON_SCENEDIR")
49+
if scene_dir:
50+
path = os.path.join(work_dir, scene_dir)
51+
else:
52+
path = work_dir
53+
54+
return os.path.normpath(path).replace("\\", "/")

0 commit comments

Comments
 (0)