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

fix #406: Unified attributes names #413

Merged
merged 7 commits into from
Aug 9, 2019
Merged
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
8 changes: 4 additions & 4 deletions avalon/inventory.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,13 @@
"film": [
{
"name": "shot1",
"edit_in": 1000,
"edit_out": 1143
"frameStart": 1000,
"frameEnd": 1143
},
{
"name": "shot2",
"edit_in": 1000,
"edit_out": 1081
"frameStart": 1000,
"frameEnd": 1081
},
]
}
Expand Down
39 changes: 28 additions & 11 deletions avalon/maya/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,17 @@ def reset_frame_range():
shot = io.find_one({"name": shot, "type": "asset"})

try:
edit_in = shot["data"]["edit_in"]
edit_out = shot["data"]["edit_out"]

frame_start = shot["data"].get(
"frameStart",
# backwards compatibility
shot["data"].get("edit_in")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider this a question, but should we maybe explicitly comment with these fallbacks that they are due to "Backwards compatibility" - I can imagine newcomers or ourselves in 1-2 years looking at this code and be like "why the hell does it also allow edit_in?"

I'd rather have it clear that it's only allowing that fallback due to backwards compatibility.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can really imagine myself in 1-2 weeks looking at this code and be like "who the hell wrote this?" Agree

)
frame_end = shot["data"].get(
"frameEnd",
# backwards compatibility
shot["data"].get("edit_out")
)
except KeyError:
cmds.warning("No edit information found for %s" % shot["name"])
return
Expand All @@ -38,21 +47,29 @@ def reset_frame_range():

cmds.currentUnit(time=fps)

cmds.playbackOptions(minTime=edit_in)
cmds.playbackOptions(maxTime=edit_out)
cmds.playbackOptions(animationStartTime=edit_in)
cmds.playbackOptions(animationEndTime=edit_out)
cmds.playbackOptions(minTime=edit_in)
cmds.playbackOptions(maxTime=edit_out)
cmds.currentTime(edit_in)
cmds.playbackOptions(minTime=frame_start)
cmds.playbackOptions(maxTime=frame_end)
cmds.playbackOptions(animationStartTime=frame_start)
cmds.playbackOptions(animationEndTime=frame_end)
cmds.playbackOptions(minTime=frame_start)
cmds.playbackOptions(maxTime=frame_end)
cmds.currentTime(frame_start)


def reset_resolution():
project = io.find_one({"type": "project"})

try:
resolution_width = project["data"].get("resolution_width", 1920)
resolution_height = project["data"].get("resolution_height", 1080)
resolution_width = project["data"].get(
"resolutionWidth",
# backwards compatibility
project["data"].get("resolution_width", 1920)
)
resolution_height = project["data"].get(
"resolutionHeight",
# backwards compatibility
project["data"].get("resolution_height", 1080)
)
except KeyError:
cmds.warning("No resolution information found for %s"
% project["name"])
Expand Down
6 changes: 3 additions & 3 deletions avalon/schema/subset-2.0.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@
"type": "object",
"description": "Document metadata",
"example": {
"startFrame": 1000,
"endFrame": 1201
"frameStart": 1000,
"frameEnd": 1201
}
}
}
}
}
33 changes: 24 additions & 9 deletions avalon/tools/cbloader/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,16 +72,31 @@ def set_version(self, index, version):
version_data = version.get("data", dict())

# Compute frame ranges (if data is present)
start = version_data.get("startFrame", None)
end = version_data.get("endFrame", None)
handles = version_data.get("handles", None)
if start is not None and end is not None:
frame_start = version_data.get(
"frameStart",
# backwards compatibility
version_data.get("startFrame", None)
)
frame_end = version_data.get(
"frameEnd",
# backwards compatibility
version_data.get("endFrame", None)
)

handle_start = version_data.get("handleStart", None)
handle_end = version_data.get("handleEnd", None)
if handle_start is not None and handle_end is not None:
handles = "{}-{}".format(str(handle_start), str(handle_end))
else:
handles = version_data.get("handles", None)

if frame_start is not None and frame_end is not None:
# Remove superfluous zeros from numbers (3.0 -> 3) to improve
# readability for most frame ranges
start_clean = ('%f' % start).rstrip('0').rstrip('.')
end_clean = ('%f' % end).rstrip('0').rstrip('.')
start_clean = ('%f' % frame_start).rstrip('0').rstrip('.')
end_clean = ('%f' % frame_end).rstrip('0').rstrip('.')
frames = "{0}-{1}".format(start_clean, end_clean)
duration = end - start + 1
duration = frame_end - frame_start + 1
else:
frames = None
duration = None
Expand All @@ -99,8 +114,8 @@ def set_version(self, index, version):
"familyLabel": family_config.get("label", family),
"familyIcon": family_config.get('icon', None),
"families": set(families),
"startFrame": start,
"endFrame": end,
"frameStart": frame_start,
"frameEnd": frame_end,
"duration": duration,
"handles": handles,
"frames": frames,
Expand Down