Skip to content
This repository was archived by the owner on Oct 10, 2024. It is now read-only.

Commit bc1e9f8

Browse files
committed
Merge branch 'develop'
2 parents d682c0e + 9de6668 commit bc1e9f8

File tree

117 files changed

+8385
-2562
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

117 files changed

+8385
-2562
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
*.egg-info
2+
*.dist-info
23
dist
34
cover
45
.coverage

avalon/__main__.py

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
import argparse
22

3-
from . import pipeline
3+
from . import pipeline, version
44

55

6-
if __name__ == '__main__':
6+
def main():
77
parser = argparse.ArgumentParser()
8+
parser.add_argument("--version", action="store_true", help=(
9+
"Print version and exit"))
10+
parser.add_argument("--root",
11+
help="Absolute path to root directory of assets")
812
parser.add_argument("--creator", action="store_true",
913
help="Launch Instance Creator in standalone mode")
1014
parser.add_argument("--loader", action="store_true",
@@ -13,14 +17,16 @@
1317
help="Launch Manager in standalone mode")
1418
parser.add_argument("--projectmanager", action="store_true",
1519
help="Launch Manager in standalone mode")
16-
parser.add_argument("--root",
17-
help="Absolute path to root directory of assets")
1820

1921
args, unknown = parser.parse_known_args()
2022
host = pipeline.debug_host()
2123
pipeline.register_host(host)
2224

23-
if args.creator:
25+
if args.version:
26+
print("avalon==%s" % version.version)
27+
exit(0)
28+
29+
elif args.creator:
2430
from .tools import creator
2531
creator.show(debug=True)
2632

@@ -35,3 +41,10 @@
3541
elif args.projectmanager:
3642
from .tools import projectmanager
3743
projectmanager.cli(unknown)
44+
45+
else:
46+
parser.print_help()
47+
48+
49+
if __name__ == '__main__':
50+
main()

avalon/aport/__init__.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
"""Public API
2+
3+
Anything that isn't defined here is INTERNAL and unreliable for external use.
4+
5+
"""
6+
7+
from .pipeline import (
8+
install,
9+
uninstall,
10+
reload_pipeline,
11+
ls
12+
)
13+
14+
__all__ = [
15+
"install",
16+
"uninstall",
17+
"reload_pipeline",
18+
"ls"
19+
]

avalon/aport/pipeline.py

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
import os
2+
import importlib
3+
from pyblish import api as pyblish
4+
from avalon import api
5+
import logging
6+
7+
8+
log = logging.getLogger(__name__)
9+
10+
AVALON_CONFIG = os.environ["AVALON_CONFIG"]
11+
12+
13+
def ls():
14+
pass
15+
16+
17+
def reload_pipeline():
18+
"""Attempt to reload pipeline at run-time.
19+
20+
CAUTION: This is primarily for development and debugging purposes.
21+
22+
"""
23+
24+
import importlib
25+
26+
api.uninstall()
27+
28+
for module in ("avalon.io",
29+
"avalon.lib",
30+
"avalon.pipeline",
31+
"avalon.api",
32+
"avalon.tools",
33+
34+
"avalon.tools.loader.app",
35+
"avalon.tools.creator.app",
36+
"avalon.tools.manager.app",
37+
38+
"avalon.aport",
39+
"avalon.aport.pipeline",
40+
"{}".format(AVALON_CONFIG)
41+
):
42+
log.info("Reloading module: {}...".format(module))
43+
module = importlib.import_module(module)
44+
reload(module)
45+
46+
import avalon.aport
47+
api.install(avalon.aport)
48+
49+
50+
def install(config):
51+
"""Install Aport-specific functionality of avalon-core.
52+
53+
This is where you install menus and register families, data
54+
and loaders into Aport.
55+
56+
It is called automatically when installing via `api.install(avalon.aport)`.
57+
58+
See the Maya equivalent for inspiration on how to implement this.
59+
60+
"""
61+
62+
pyblish.register_host("aport")
63+
# Trigger install on the config's "aport" package
64+
config = find_host_config(config)
65+
66+
if hasattr(config, "install"):
67+
config.install()
68+
69+
log.info("config.aport installed")
70+
71+
72+
def find_host_config(config):
73+
try:
74+
config = importlib.import_module(config.__name__ + ".aport")
75+
except ImportError as exc:
76+
if str(exc) != "No module name {}".format(
77+
config.__name__ + ".aport"):
78+
raise
79+
config = None
80+
81+
return config
82+
83+
84+
def uninstall(config):
85+
"""Uninstall all tha was installed
86+
87+
This is where you undo everything that was done in `install()`.
88+
That means, removing menus, deregistering families and data
89+
and everything. It should be as though `install()` was never run,
90+
because odds are calling this function means the user is interested
91+
in re-installing shortly afterwards. If, for example, he has been
92+
modifying the menu or registered families.
93+
94+
"""
95+
config = find_host_config(config)
96+
if hasattr(config, "uninstall"):
97+
config.uninstall()
98+
99+
pyblish.deregister_host("aport")

avalon/fusion/__init__.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,15 @@
1515
get_current_comp,
1616
comp_lock_and_undo_chunk
1717

18+
)
1819

20+
from .workio import (
21+
open,
22+
save,
23+
current_file,
24+
has_unsaved_changes,
25+
file_extensions,
26+
work_root
1927
)
2028

2129
from .lib import (
@@ -33,6 +41,14 @@
3341
"get_current_comp",
3442
"comp_lock_and_undo_chunk",
3543

44+
# Workfiles API
45+
"open",
46+
"save",
47+
"current_file",
48+
"has_unsaved_changes",
49+
"file_extensions",
50+
"work_root",
51+
3652
"maintained_selection"
3753

3854
]

avalon/fusion/workio.py

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
"""Host API required Work Files tool"""
2+
import sys
3+
import os
4+
5+
6+
def file_extensions():
7+
return [".comp"]
8+
9+
10+
def has_unsaved_changes():
11+
from avalon.fusion.pipeline import get_current_comp
12+
13+
comp = get_current_comp()
14+
return comp.GetAttrs()["COMPB_Modified"]
15+
16+
17+
def save(filepath):
18+
from avalon.fusion.pipeline import get_current_comp
19+
20+
comp = get_current_comp()
21+
comp.Save(filepath)
22+
23+
24+
def open(filepath):
25+
# Hack to get fusion, see avalon.fusion.pipeline.get_current_comp()
26+
fusion = getattr(sys.modules["__main__"], "fusion", None)
27+
28+
return fusion.LoadComp(filepath)
29+
30+
31+
def current_file():
32+
from avalon.fusion.pipeline import get_current_comp
33+
34+
comp = get_current_comp()
35+
current_filepath = comp.GetAttrs()["COMPS_FileName"]
36+
if not current_filepath:
37+
return None
38+
39+
return current_filepath
40+
41+
42+
def work_root():
43+
from avalon import api
44+
45+
work_dir = api.Session["AVALON_WORKDIR"]
46+
scene_dir = api.Session.get("AVALON_SCENEDIR")
47+
if scene_dir:
48+
return os.path.join(work_dir, scene_dir)
49+
else:
50+
return work_dir

avalon/houdini/__init__.py

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,15 @@
99

1010
)
1111

12+
from .workio import (
13+
open,
14+
save,
15+
current_file,
16+
has_unsaved_changes,
17+
file_extensions,
18+
work_root
19+
)
20+
1221
from .lib import (
1322
lsattr,
1423
lsattrs,
@@ -28,11 +37,19 @@
2837
"ls",
2938
"containerise",
3039

31-
# Utility functions
32-
"maintained_selection",
40+
# Workfiles API
41+
"open",
42+
"save",
43+
"current_file",
44+
"has_unsaved_changes",
45+
"file_extensions",
46+
"work_root",
3347

48+
# Utility functions
3449
"lsattr",
3550
"lsattrs",
3651
"read",
52+
53+
"maintained_selection",
3754
"unique_name"
3855
]

avalon/houdini/lib.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -174,9 +174,11 @@ def maintained_selection():
174174
try:
175175
yield
176176
finally:
177+
# Clear the selection
178+
# todo: does hou.clearAllSelected() do the same?
179+
for node in hou.selectedNodes():
180+
node.setSelected(on=False)
181+
177182
if previous_selection:
178183
for node in previous_selection:
179184
node.setSelected(on=True)
180-
else:
181-
for node in previous_selection:
182-
node.setSelected(on=False)

0 commit comments

Comments
 (0)