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

Commit 2953ad4

Browse files
committed
Merge branch 'release/2.5-pype'
2 parents ff6d4c8 + 3a51004 commit 2953ad4

File tree

23 files changed

+1696
-185
lines changed

23 files changed

+1696
-185
lines changed

.flake8

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[flake8]
2+
ignore = BLK100

.hound.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
python:
22
enabled: true
33

4+
flake8:
5+
enabled: true
6+
config_file: .flake8
7+
48
fail_on_violations: true

Dockerfile-maya2016

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ RUN wget https://bootstrap.pypa.io/get-pip.py && \
55
mayapy -m pip install \
66
nose \
77
nose-exclude \
8-
coverage \
8+
coverage==4.5.4 \
99
pyblish-base==1.4.2 \
1010
pyblish-maya \
1111
pymongo \

avalon/fusion/pipeline.py

Lines changed: 29 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@
22
import contextlib
33
import importlib
44
import logging
5-
from pyblish import api as pyblish
6-
from avalon import api as avalon
75

6+
import pyblish.api
7+
8+
from .. import api
89
from ..pipeline import AVALON_CONTAINER_ID
10+
from ..lib import find_submodule
911

1012

1113
class CompLogHandler(logging.Handler):
@@ -23,32 +25,30 @@ def ls():
2325
assets on disk, it lists assets already loaded in Fusion; once loaded
2426
they are called 'containers'
2527
28+
Yields:
29+
dict: container
30+
2631
"""
2732

2833
comp = get_current_comp()
2934
tools = comp.GetToolList(False, "Loader").values()
35+
36+
has_metadata_collector = False
37+
config_host = find_submodule(api.registered_config(), "fusion")
38+
if hasattr(config_host, "collect_container_metadata"):
39+
has_metadata_collector = True
40+
3041
for tool in tools:
3142
container = parse_container(tool)
3243
if container:
33-
# Collect custom data if attribute is present
34-
config = find_host_config(avalon.registered_config())
35-
if hasattr(config, "collect_container_metadata"):
36-
metadata = config.collect_container_metadata(container)
44+
45+
if has_metadata_collector:
46+
metadata = config_host.collect_container_metadata(container)
3747
container.update(metadata)
3848

3949
yield container
4050

4151

42-
def find_host_config(config):
43-
config_name = config.__name__
44-
try:
45-
config = importlib.import_module(config_name + ".fusion")
46-
except ImportError:
47-
pass
48-
49-
return config
50-
51-
5252
def install(config):
5353
"""Install Fusion-specific functionality of avalon-core.
5454
@@ -60,7 +60,7 @@ def install(config):
6060
# TODO: Set project
6161
# TODO: Install Fusion menu (this is done with config .fu script actually)
6262

63-
pyblish.register_host("fusion")
63+
pyblish.api.register_host("fusion")
6464

6565
# Remove all handlers associated with the root logger object, because
6666
# that one sometimes logs as "warnings" incorrectly.
@@ -75,10 +75,18 @@ def install(config):
7575
logger.addHandler(handler)
7676
logger.setLevel(logging.DEBUG)
7777

78-
# Trigger install on the config's "fusion" package
79-
config = find_host_config(config)
80-
if hasattr(config, "install"):
81-
config.install()
78+
79+
def uninstall(config):
80+
"""Uninstall Fusion-specific functionality of avalon-core.
81+
82+
This function is called automatically on calling `api.uninstall()`.
83+
84+
Args:
85+
config: configuration module
86+
87+
"""
88+
89+
pyblish.api.deregister_host("fusion")
8290

8391

8492
def imprint_container(tool,

avalon/houdini/lib.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ def imprint(node, data):
6262

6363

6464
def lsattr(attr, value=None):
65-
nodes = list(hou.node("/obj").allNodes())
6665
if value is None:
66+
nodes = list(hou.node("/obj").allNodes())
6767
return [n for n in nodes if n.parm(attr)]
6868
return lsattrs({attr: value})
6969

avalon/houdini/pipeline.py

Lines changed: 9 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010

1111
# Local libraries
1212
from . import lib
13-
from ..lib import logger
14-
from avalon import api, schema
13+
from ..lib import logger, find_submodule
14+
from .. import api
1515

1616
from ..pipeline import AVALON_CONTAINER_ID
1717

@@ -39,10 +39,6 @@ def install(config):
3939

4040
self._has_been_setup = True
4141

42-
config = find_host_config(config)
43-
if hasattr(config, "install"):
44-
config.install()
45-
4642

4743
def uninstall(config):
4844
"""Uninstall Houdini-specific functionality of avalon-core.
@@ -54,27 +50,11 @@ def uninstall(config):
5450
5551
"""
5652

57-
config = find_host_config(config)
58-
if hasattr(config, "uninstall"):
59-
config.uninstall()
60-
6153
pyblish.api.deregister_host("hython")
6254
pyblish.api.deregister_host("hpython")
6355
pyblish.api.deregister_host("houdini")
6456

6557

66-
def find_host_config(config):
67-
config_name = config.__name__
68-
try:
69-
config = importlib.import_module(config_name + ".houdini")
70-
except ImportError as exc:
71-
if str(exc) != "No module name {}".format(config_name + ".houdini"):
72-
raise
73-
config = None
74-
75-
return config
76-
77-
7858
def get_main_window():
7959
"""Acquire Houdini's main window"""
8060
if self._parent is None:
@@ -89,8 +69,6 @@ def reload_pipeline(*args):
8969
9070
"""
9171

92-
import importlib
93-
9472
api.uninstall()
9573

9674
for module in ("avalon.io",
@@ -236,13 +214,17 @@ def ls():
236214
"pyblish.mindbender.container"):
237215
containers += lib.lsattr("id", identifier)
238216

217+
has_metadata_collector = False
218+
config_host = find_submodule(api.registered_config(), "houdini")
219+
if hasattr(config_host, "collect_container_metadata"):
220+
has_metadata_collector = True
221+
239222
for container in sorted(containers):
240223
data = parse_container(container)
241224

242225
# Collect custom data if attribute is present
243-
config = find_host_config(api.registered_config())
244-
if hasattr(config, "collect_container_metadata"):
245-
metadata = config.collect_container_metadata(container)
226+
if has_metadata_collector:
227+
metadata = config_host.collect_container_metadata(container)
246228
data.update(metadata)
247229

248230
yield data

avalon/lib.py

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import json
66
import logging
77
import datetime
8+
import importlib
89
import subprocess
910
import types
1011

@@ -236,7 +237,7 @@ def modules_from_path(path):
236237
"""Get python scripts as modules from a path.
237238
238239
Arguments:
239-
path (str): Path to python scrips.
240+
path (str): Path to folder containing python scripts.
240241
241242
Returns:
242243
List of modules.
@@ -275,9 +276,30 @@ def modules_from_path(path):
275276
sys.modules[mod_name] = module
276277

277278
except Exception as err:
278-
print("Skipped: \"%s\" (%s)", mod_name, err)
279+
print("Skipped: \"{0}\" ({1})".format(mod_name, err))
279280
continue
280281

281282
modules.append(module)
282283

283284
return modules
285+
286+
287+
def find_submodule(module, submodule):
288+
"""Find and return submodule of the module.
289+
290+
Args:
291+
module (types.ModuleType): The module to search in.
292+
submodule (str): The submodule name to find.
293+
294+
Returns:
295+
types.ModuleType or None: The module, if found.
296+
297+
"""
298+
name = "{0}.{1}".format(module.__name__, submodule)
299+
try:
300+
return importlib.import_module(name)
301+
except ImportError as exc:
302+
if str(exc) != "No module name {}".format(name):
303+
log_.warning("Could not find '%s' in module: %s",
304+
submodule,
305+
module)

avalon/maya/commands.py

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -33,17 +33,22 @@ def reset_frame_range():
3333
cmds.warning("No edit information found for %s" % shot["name"])
3434
return
3535

36-
fps = {
37-
"12": "12fps",
38-
"15": "game",
39-
"16": "16fps",
40-
"24": "film",
41-
"25": "pal",
42-
"30": "ntsc",
43-
"48": "show",
44-
"50": "palf",
45-
"60": "ntscf"
46-
}.get(api.Session.get("AVALON_FPS"), "pal") # Default to "pal"
36+
fps = {15: 'game',
37+
24: 'film',
38+
25: 'pal',
39+
30: 'ntsc',
40+
48: 'show',
41+
50: 'palf',
42+
60: 'ntscf',
43+
23.98: '23.976fps',
44+
23.976: '23.976fps',
45+
29.97: '29.97fps',
46+
47.952: '47.952fps',
47+
47.95: '47.952fps',
48+
59.94: '59.94fps',
49+
44100: '44100fps',
50+
48000: '48000fps'
51+
}.get(float(api.Session.get("AVALON_FPS", 25)), "pal")
4752

4853
cmds.currentUnit(time=fps)
4954

0 commit comments

Comments
 (0)