Render Review: Fix Import Errors #122
@ -29,6 +29,7 @@ from collections import OrderedDict
|
||||
import bpy
|
||||
|
||||
from render_review import vars, prefs, opsdata, util, kitsu
|
||||
|
||||
if prefs.is_blender_kitsu_enabled():
|
||||
from blender_kitsu import types as kitsu_types
|
||||
from blender_kitsu import cache
|
||||
@ -68,7 +69,9 @@ class RR_OT_sqe_create_review_session(bpy.types.Operator):
|
||||
or opsdata.is_sequence_dir(render_dir)
|
||||
)
|
||||
|
||||
def load_strip_from_img_seq(self, context, directory, idx: int, frame_start: int = 0):
|
||||
def load_strip_from_img_seq(
|
||||
self, context, directory, idx: int, frame_start: int = 0
|
||||
):
|
||||
try:
|
||||
# Get best preview files sequence.
|
||||
image_sequence = opsdata.get_best_preview_sequence(directory)
|
||||
@ -103,7 +106,7 @@ class RR_OT_sqe_create_review_session(bpy.types.Operator):
|
||||
filepath=image_sequence[0].as_posix(),
|
||||
channel=idx + 1,
|
||||
frame_start=frame_start,
|
||||
fit_method = 'ORIGINAL'
|
||||
fit_method='ORIGINAL',
|
||||
)
|
||||
|
||||
# Extend strip elements with all the available frames.
|
||||
@ -115,7 +118,6 @@ class RR_OT_sqe_create_review_session(bpy.types.Operator):
|
||||
|
||||
return strip
|
||||
|
||||
|
||||
def execute(self, context: bpy.types.Context) -> Set[str]:
|
||||
# Clear existing strips and markers
|
||||
context.scene.sequence_editor_clear()
|
||||
@ -130,7 +132,6 @@ class RR_OT_sqe_create_review_session(bpy.types.Operator):
|
||||
|
||||
prev_frame_end: int = 1
|
||||
for shot_name, shot_version_folders in shot_version_folders_dict.items():
|
||||
|
||||
logger.info("Loading versions of shot %s", shot_name)
|
||||
imported_strips = self.import_shot_versions_as_strips(
|
||||
context,
|
||||
@ -174,8 +175,7 @@ class RR_OT_sqe_create_review_session(bpy.types.Operator):
|
||||
render_resolution_y = vars.RESOLUTION[1]
|
||||
# If Kitsu add-on is enabled, fetch the resolution from the online project
|
||||
if (
|
||||
addon_prefs.enable_blender_kitsu
|
||||
and prefs.is_blender_kitsu_enabled()
|
||||
addon_prefs.enable_blender_kitsu and prefs.is_blender_kitsu_enabled()
|
||||
) and kitsu.is_active_project():
|
||||
# TODO: make the resolution fetching a bit more robust
|
||||
# Assume resolution is a string '<str:width>x<str:height>'
|
||||
@ -209,7 +209,6 @@ class RR_OT_sqe_create_review_session(bpy.types.Operator):
|
||||
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
def get_shot_folder_dict(
|
||||
self,
|
||||
render_dir: str,
|
||||
@ -237,34 +236,43 @@ class RR_OT_sqe_create_review_session(bpy.types.Operator):
|
||||
|
||||
# Sort versions by date
|
||||
for shot_name, shot_folder in shot_version_folders_dict.items():
|
||||
shot_version_folders_dict[shot_name] = sorted(shot_folder, key=lambda dir: dir.stat().st_mtime)
|
||||
shot_version_folders_dict[shot_name] = sorted(shot_folder, reverse=False)
|
||||
# Limit list to max number of versions
|
||||
shot_version_folders_dict[shot_name] = shot_version_folders_dict[shot_name][:max_versions_per_shot]
|
||||
shot_version_folders_dict[shot_name] = shot_version_folders_dict[shot_name][
|
||||
-max_versions_per_shot:
|
||||
]
|
||||
|
||||
# Sort shots by name
|
||||
sorted_dict = OrderedDict(sorted(shot_version_folders_dict.items()))
|
||||
|
||||
return sorted_dict
|
||||
|
||||
|
||||
def import_shot_versions_as_strips(
|
||||
self,
|
||||
context: bpy.types.Context,
|
||||
shot_version_folders: List[Path],
|
||||
frame_start: int,
|
||||
shot_name: str
|
||||
shot_name: str,
|
||||
) -> List[bpy.types.Sequence]:
|
||||
addon_prefs = prefs.addon_prefs_get(context)
|
||||
imported_strips: bpy.types.Sequence = []
|
||||
|
||||
for idx, shot_folder in enumerate(shot_version_folders):
|
||||
if addon_prefs.shot_name_filter and addon_prefs.shot_name_filter not in shot_folder.parent.name:
|
||||
# If there is a filter specified, and the shot doesn't match, skip it.
|
||||
continue
|
||||
shots_folder_to_add = []
|
||||
|
||||
if addon_prefs.shot_name_filter == "":
|
||||
shots_folder_to_add = shot_version_folders
|
||||
else:
|
||||
for shot_folder in shot_version_folders:
|
||||
if addon_prefs.shot_name_filter in shot_folder.parent.name:
|
||||
shots_folder_to_add.append(shot_folder)
|
||||
|
||||
for idx, shot_folder in enumerate(shots_folder_to_add):
|
||||
logger.info("Processing %s", shot_folder.name)
|
||||
|
||||
use_video = addon_prefs.use_video and \
|
||||
not (shot_folder != shot_version_folders[-1] and addon_prefs.use_video_latest_only)
|
||||
use_video = addon_prefs.use_video and not (
|
||||
shot_folder != shot_version_folders[-1]
|
||||
and addon_prefs.use_video_latest_only
|
||||
)
|
||||
|
||||
shot_strip = self.import_shot_as_strip(
|
||||
context,
|
||||
@ -272,13 +280,11 @@ class RR_OT_sqe_create_review_session(bpy.types.Operator):
|
||||
channel_idx=idx,
|
||||
shot_folder=shot_folder,
|
||||
shot_name=shot_name,
|
||||
use_video = use_video
|
||||
use_video=use_video,
|
||||
)
|
||||
imported_strips.append(shot_strip)
|
||||
|
||||
return imported_strips
|
||||
|
||||
|
||||
def import_shot_as_strip(
|
||||
self,
|
||||
context: bpy.types.Context,
|
||||
@ -309,10 +315,12 @@ class RR_OT_sqe_create_review_session(bpy.types.Operator):
|
||||
filepath=video_path.as_posix(),
|
||||
channel=channel_idx + 1,
|
||||
frame_start=frame_start,
|
||||
fit_method = 'ORIGINAL'
|
||||
fit_method='ORIGINAL',
|
||||
)
|
||||
else:
|
||||
strip = self.load_strip_from_img_seq(context, shot_folder, channel_idx, frame_start)
|
||||
strip = self.load_strip_from_img_seq(
|
||||
context, shot_folder, channel_idx, frame_start
|
||||
)
|
||||
|
||||
shot_datetime = datetime.fromtimestamp(shot_folder.stat().st_mtime)
|
||||
time_str = shot_datetime.strftime("%B %d, %I:%M")
|
||||
@ -344,7 +352,7 @@ class RR_OT_setup_review_workspace(bpy.types.Operator):
|
||||
sequence: bpy.props.EnumProperty(
|
||||
name="Sequence",
|
||||
description="Select which sequence to review",
|
||||
items = sequences_enum_items if prefs.is_blender_kitsu_enabled() else []
|
||||
items=sequences_enum_items if prefs.is_blender_kitsu_enabled() else [],
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
@ -372,9 +380,11 @@ class RR_OT_setup_review_workspace(bpy.types.Operator):
|
||||
area.spaces.active.show_overlays = False
|
||||
|
||||
def invoke(self, context, _event):
|
||||
if not prefs.is_blender_kitsu_enabled() or \
|
||||
not prefs.addon_prefs_get(context).enable_blender_kitsu or \
|
||||
not kitsu.is_auth_and_project():
|
||||
if (
|
||||
not prefs.is_blender_kitsu_enabled()
|
||||
or not prefs.addon_prefs_get(context).enable_blender_kitsu
|
||||
or not kitsu.is_auth_and_project()
|
||||
):
|
||||
return self.execute(context)
|
||||
|
||||
return context.window_manager.invoke_props_dialog(self)
|
||||
@ -393,7 +403,6 @@ class RR_OT_setup_review_workspace(bpy.types.Operator):
|
||||
if addon_prefs.use_video:
|
||||
row.prop(addon_prefs, 'use_video_latest_only')
|
||||
|
||||
|
||||
def execute(self, context: bpy.types.Context) -> Set[str]:
|
||||
scripts_path = bpy.utils.script_paths(use_user=False)[0]
|
||||
template_path = "/startup/bl_app_templates_system/Video_Editing/startup.blend"
|
||||
@ -403,7 +412,6 @@ class RR_OT_setup_review_workspace(bpy.types.Operator):
|
||||
filepath=ws_filepath.as_posix(),
|
||||
)
|
||||
|
||||
|
||||
# Pre-fill render directory with farm output shots directory.
|
||||
addon_prefs = prefs.addon_prefs_get(bpy.context)
|
||||
context.scene.rr.render_dir = addon_prefs.farm_output_dir + "/shots"
|
||||
@ -441,9 +449,7 @@ class RR_OT_sqe_inspect_exr_sequence(bpy.types.Operator):
|
||||
active_strip = context.scene.sequence_editor.active_strip
|
||||
image_editor = opsdata.get_image_editor(context)
|
||||
|
||||
if not (active_strip
|
||||
and active_strip.rr.is_render
|
||||
and image_editor):
|
||||
if not (active_strip and active_strip.rr.is_render and image_editor):
|
||||
return False
|
||||
|
||||
output_dir = opsdata.get_strip_folder(active_strip)
|
||||
@ -507,7 +513,6 @@ class RR_OT_sqe_clear_exr_inspect(bpy.types.Operator):
|
||||
|
||||
@classmethod
|
||||
def _get_image_editor(self, context: bpy.types.Context) -> Optional[bpy.types.Area]:
|
||||
|
||||
image_editor = None
|
||||
|
||||
for area in bpy.context.screen.areas:
|
||||
@ -551,7 +556,6 @@ class RR_OT_sqe_approve_render(bpy.types.Operator):
|
||||
|
||||
# Create Shot Frames path if not exists yet.
|
||||
if shot_frames_dir.exists():
|
||||
|
||||
# Delete backup if exists.
|
||||
if shot_frames_backup_path.exists():
|
||||
shutil.rmtree(shot_frames_backup_path)
|
||||
@ -671,7 +675,6 @@ class RR_OT_open_path(bpy.types.Operator):
|
||||
)
|
||||
|
||||
def execute(self, context: bpy.types.Context) -> Set[str]:
|
||||
|
||||
if not self.filepath:
|
||||
self.report({"ERROR"}, "Can't open empty path in explorer")
|
||||
return {"CANCELLED"}
|
||||
@ -714,7 +717,6 @@ class RR_OT_sqe_isolate_strip_exit(bpy.types.Operator):
|
||||
bl_options = {"REGISTER", "UNDO"}
|
||||
|
||||
def execute(self, context: bpy.types.Context) -> Set[str]:
|
||||
|
||||
for i in context.scene.rr.isolate_view:
|
||||
try:
|
||||
strip = context.scene.sequence_editor.sequences[i.name]
|
||||
@ -742,7 +744,6 @@ class RR_OT_sqe_isolate_strip_enter(bpy.types.Operator):
|
||||
return bool(active_strip)
|
||||
|
||||
def execute(self, context: bpy.types.Context) -> Set[str]:
|
||||
|
||||
sequences = list(context.scene.sequence_editor.sequences_all)
|
||||
|
||||
if context.scene.rr.isolate_view.items():
|
||||
@ -964,7 +965,6 @@ addon_keymap_items = []
|
||||
|
||||
|
||||
def register():
|
||||
|
||||
for cls in classes:
|
||||
bpy.utils.register_class(cls)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user