Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pep8 lint #82

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
120 changes: 60 additions & 60 deletions capture.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
from PySide import QtGui
QtWidgets = QtGui

version_info = (2, 3, 0)
VERSION_INFO = (2, 3, 0)

__version__ = "%s.%s.%s" % version_info
__version__ = "%s.%s.%s" % VERSION_INFO
__license__ = "MIT"


Expand Down Expand Up @@ -67,7 +67,7 @@ def capture(camera=None,
viewer (bool, optional): Display results in native player
show_ornaments (bool, optional): Whether or not model view ornaments
(e.g. axis icon, grid and HUD) should be displayed.
sound (str, optional): Specify the sound node to be used during
sound (str, optional): Specify the sound node to be used during
playblast. When None (default) no sound will be used.
isolate (list): List of nodes to isolate upon capturing
maintain_aspect_ratio (bool, optional): Modify height in order to
Expand All @@ -82,13 +82,13 @@ def capture(camera=None,
zero. Defaults to False. When set to True `viewer` can't be used
and will be forced to False.
camera_options (dict, optional): Supplied camera options,
using `CameraOptions`
using `CAMERA_OPTIONS`
display_options (dict, optional): Supplied display
options, using `DisplayOptions`
options, using `DISPLAY_OPTIONS`
viewport_options (dict, optional): Supplied viewport
options, using `ViewportOptions`
options, using `VIEWPORT_OPTIONS`
viewport2_options (dict, optional): Supplied display
options, using `Viewport2Options`
options, using `VIEWPORT_2_OPTIONS`
complete_filename (str, optional): Exact name of output file. Use this
to override the output of `filename` so it excludes frame padding.

Expand Down Expand Up @@ -167,31 +167,31 @@ def capture(camera=None,
cmds.setFocus(panel)

with contextlib.nested(
_disabled_inview_messages(),
_maintain_camera(panel, camera),
_applied_viewport_options(viewport_options, panel),
_applied_camera_options(camera_options, panel),
_applied_display_options(display_options),
_applied_viewport2_options(viewport2_options),
_isolated_nodes(isolate, panel),
_maintained_time()):

output = cmds.playblast(
compression=compression,
format=format,
percent=100,
quality=quality,
viewer=viewer,
startTime=start_frame,
endTime=end_frame,
offScreen=off_screen,
showOrnaments=show_ornaments,
forceOverwrite=overwrite,
filename=filename,
widthHeight=[width, height],
rawFrameNumbers=raw_frame_numbers,
framePadding=frame_padding,
**playblast_kwargs)
_disabled_inview_messages(),
_maintain_camera(panel, camera),
_applied_viewport_options(viewport_options, panel),
_applied_camera_options(camera_options, panel),
_applied_display_options(display_options),
_applied_viewport2_options(viewport2_options),
_isolated_nodes(isolate, panel),
_maintained_time()):

output = cmds.playblast(
compression=compression,
format=format,
percent=100,
quality=quality,
viewer=viewer,
startTime=start_frame,
endTime=end_frame,
offScreen=off_screen,
showOrnaments=show_ornaments,
forceOverwrite=overwrite,
filename=filename,
widthHeight=[width, height],
rawFrameNumbers=raw_frame_numbers,
framePadding=frame_padding,
**playblast_kwargs)

return output

Expand Down Expand Up @@ -240,9 +240,9 @@ def snap(*args, **kwargs):
# perform capture
output = capture(*args, **kwargs)

def replace(m):
def replace(match):
"""Substitute # with frame number"""
return str(int(frame)).zfill(len(m.group()))
return str(int(frame)).zfill(len(match.group()))

output = re.sub("#+", replace, output)

Expand All @@ -253,7 +253,7 @@ def replace(m):
return output


CameraOptions = {
CAMERA_OPTIONS = {
"displayGateMask": False,
"displayResolution": False,
"displayFilmGate": False,
Expand All @@ -266,17 +266,17 @@ def replace(m):
"depthOfField": False,
}

DisplayOptions = {
DISPLAY_OPTIONS = {
"displayGradient": True,
"background": (0.631, 0.631, 0.631),
"backgroundTop": (0.535, 0.617, 0.702),
"backgroundBottom": (0.052, 0.052, 0.052),
}

# These display options require a different command to be queried and set
_DisplayOptionsRGB = set(["background", "backgroundTop", "backgroundBottom"])
_DISPLAY_OPTIONS_RGB = set(["background", "backgroundTop", "backgroundBottom"])

ViewportOptions = {
VIEWPORT_OPTIONS = {
# renderer
"rendererName": "vp2Renderer",
"fogging": False,
Expand Down Expand Up @@ -325,7 +325,7 @@ def replace(m):
"strokes": False
}

Viewport2Options = {
VIEWPORT_2_OPTIONS = {
"consolidateWorld": True,
"enableTextureMaxRes": False,
"bumpBakeResolution": 64,
Expand Down Expand Up @@ -365,7 +365,7 @@ def apply_view(panel, **options):
# Display options
display_options = options.get("display_options", {})
for key, value in display_options.iteritems():
if key in _DisplayOptionsRGB:
if key in _DISPLAY_OPTIONS_RGB:
cmds.displayRGBColor(key, *value)
else:
cmds.displayPref(**{key: value})
Expand Down Expand Up @@ -428,35 +428,35 @@ def parse_view(panel):

# Display options
display_options = {}
for key in DisplayOptions:
if key in _DisplayOptionsRGB:
for key in DISPLAY_OPTIONS:
if key in _DISPLAY_OPTIONS_RGB:
display_options[key] = cmds.displayRGBColor(key, query=True)
else:
display_options[key] = cmds.displayPref(query=True, **{key: True})

# Camera options
camera_options = {}
for key in CameraOptions:
for key in CAMERA_OPTIONS:
camera_options[key] = cmds.getAttr("{0}.{1}".format(camera, key))

# Viewport options
viewport_options = {}
# capture plugin display filters first to ensure we never override
# built-in arguments if ever possible a plugin has similarly named

# capture plugin display filters first to ensure we never override
# built-in arguments if ever possible a plugin has similarly named
# plugin display filters (which it shouldn't!)
plugins = cmds.pluginDisplayFilter(query=True, listFilters=True)
for plugin in plugins:
plugin = str(plugin) # unicode->str for simplicity of the dict
state = cmds.modelEditor(panel, query=True, queryPluginObjects=plugin)
viewport_options[plugin] = state
for key in ViewportOptions:

for key in VIEWPORT_OPTIONS:
viewport_options[key] = cmds.modelEditor(
panel, query=True, **{key: True})

viewport2_options = {}
for key in Viewport2Options.keys():
for key in VIEWPORT_2_OPTIONS:
attr = "hardwareRenderingGlobals.{0}".format(key)
try:
viewport2_options[key] = cmds.getAttr(attr)
Expand Down Expand Up @@ -493,7 +493,7 @@ def parse_active_scene():
"off_screen": (True if cmds.optionVar(query="playblastOffscreen")
else False),
"show_ornaments": (True if cmds.optionVar(query="playblastShowOrnaments")
else False),
else False),
"quality": cmds.optionVar(query="playblastQuality"),
"sound": cmds.timeControl(time_control, q=True, sound=True) or None
}
Expand Down Expand Up @@ -618,7 +618,7 @@ def _applied_camera_options(options, panel):
"""Context manager for applying `options` to `camera`"""

camera = cmds.modelPanel(panel, query=True, camera=True)
options = dict(CameraOptions, **(options or {}))
options = dict(CAMERA_OPTIONS, **(options or {}))

old_options = dict()
for opt in options.copy():
Expand All @@ -644,7 +644,7 @@ def _applied_camera_options(options, panel):
def _applied_display_options(options):
"""Context manager for setting background color display options."""

options = dict(DisplayOptions, **(options or {}))
options = dict(DISPLAY_OPTIONS, **(options or {}))

colors = ['background', 'backgroundTop', 'backgroundBottom']
preferences = ['displayGradient']
Expand Down Expand Up @@ -682,23 +682,23 @@ def _applied_display_options(options):
def _applied_viewport_options(options, panel):
"""Context manager for applying `options` to `panel`"""

options = dict(ViewportOptions, **(options or {}))
options = dict(VIEWPORT_OPTIONS, **(options or {}))

# separate the plugin display filter options since they need to
# be set differently (see #55)
plugins = cmds.pluginDisplayFilter(query=True, listFilters=True)
plugin_options = dict()
for plugin in plugins:
if plugin in options:
plugin_options[plugin] = options.pop(plugin)

# default options
cmds.modelEditor(panel, edit=True, **options)

# plugin display filter options
for plugin, state in plugin_options.items():
cmds.modelEditor(panel, edit=True, pluginObjects=(plugin, state))

yield


Expand All @@ -711,7 +711,7 @@ def _applied_viewport2_options(options):

"""

options = dict(Viewport2Options, **(options or {}))
options = dict(VIEWPORT_2_OPTIONS, **(options or {}))

# Store current settings
original = {}
Expand Down Expand Up @@ -813,9 +813,9 @@ def _in_standalone():
#
# --------------------------------

version = mel.eval("getApplicationVersionAsFloat")
if version > 2015:
Viewport2Options.update({
VERSION = mel.eval("getApplicationVersionAsFloat")
if VERSION > 2015:
VIEWPORT_2_OPTIONS.update({
"hwFogAlpha": 1.0,
"hwFogFalloff": 0,
"hwFogDensity": 0.1,
Expand Down
12 changes: 6 additions & 6 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
import os
import imp

mod_path = os.path.abspath('capture.py')
mod = imp.load_source('capture', mod_path)
version = mod.__version__
MOD_PATH = os.path.abspath('capture.py')
MOD = imp.load_source('capture', MOD_PATH)
VERSION = MOD.__version__


classifiers = [
CLASSIFIERS = [
'Development Status :: 3 - Alpha',
'Intended Audience :: Developers',
'License :: OSI Approved :: MIT License',
Expand All @@ -23,7 +23,7 @@

setup(
name='maya-capture',
version=version,
version=VERSION,
description='Playblasting in Maya done right"',
long_description="Playblasting in Maya done right",
author='Marcus Ottosson',
Expand All @@ -32,5 +32,5 @@
license="MIT",
py_modules=["capture"],
zip_safe=False,
classifiers=classifiers
classifiers=CLASSIFIERS
)
24 changes: 12 additions & 12 deletions tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,25 +104,25 @@ def test_apply_parsed_view_all():
viewport_options = {}
viewport2_options = {}

for key, value in capture.CameraOptions.items():
for key, value in capture.CAMERA_OPTIONS.items():
if isinstance(value, bool):
value = not value
elif isinstance(value, (int, float)):
value = value + 1
else:
raise Exception("Unexpected value in CameraOptions: %s=%s"
raise Exception("Unexpected value in CAMERA_OPTIONS: %s=%s"
% (key, value))

for key, value in capture.DisplayOptions.items():
for key, value in capture.DISPLAY_OPTIONS.items():
if isinstance(value, bool):
value = not value
elif isinstance(value, tuple):
value = (1, 0, 1)
else:
raise Exception("Unexpected value in DisplayOptions: %s=%s"
raise Exception("Unexpected value in DISPLAY_OPTIONS: %s=%s"
% (key, value))

for key, value in capture.ViewportOptions.items():
for key, value in capture.VIEWPORT_OPTIONS.items():
if isinstance(value, bool):
value = not value
elif isinstance(value, (int, float)):
Expand All @@ -132,10 +132,10 @@ def test_apply_parsed_view_all():
elif isinstance(value, basestring):
pass # Don't bother, for now
else:
raise Exception("Unexpected value in ViewportOptions: %s=%s"
raise Exception("Unexpected value in VIEWPORT_OPTIONS: %s=%s"
% (key, value))

for key, value in capture.Viewport2Options.items():
for key, value in capture.VIEWPORT_2_OPTIONS.items():
if isinstance(value, bool):
value = not value
elif isinstance(value, (int, float)):
Expand All @@ -145,14 +145,14 @@ def test_apply_parsed_view_all():
elif isinstance(value, basestring):
pass # Don't bother, for now
else:
raise Exception("Unexpected value in Viewport2Options: %s=%s"
raise Exception("Unexpected value in VIEWPORT_2_OPTIONS: %s=%s"
% (key, value))

defaults = {
"camera_options": capture.CameraOptions.copy(),
"display_options": capture.DisplayOptions.copy(),
"viewport_options": capture.ViewportOptions.copy(),
"viewport2_options": capture.Viewport2Options.copy(),
"camera_options": capture.CAMERA_OPTIONS.copy(),
"display_options": capture.DISPLAY_OPTIONS.copy(),
"viewport_options": capture.VIEWPORT_OPTIONS.copy(),
"viewport2_options": capture.VIEWPORT_2_OPTIONS.copy(),
}

others = {
Expand Down