Cleanup: move utility to create a frame path into a static method
Add PlayRenderedAnim._frame_path_with_number_char since mixing this logic inline made the code harder to follow.
This commit is contained in:
parent
c146d75808
commit
fa7bd4c069
|
@ -44,6 +44,23 @@ class PlayRenderedAnim(Operator):
|
|||
bl_label = "Play Rendered Animation"
|
||||
bl_options = {'REGISTER'}
|
||||
|
||||
@staticmethod
|
||||
def _frame_path_with_number_char(rd, ch, **kwargs):
|
||||
# Replace the number with `ch`.
|
||||
|
||||
# NOTE: make an api call for this would be nice, however this isn't needed in many places.
|
||||
file_a = rd.frame_path(frame=0, **kwargs)
|
||||
|
||||
frame_tmp = 9
|
||||
file_b = rd.frame_path(frame=frame_tmp, **kwargs)
|
||||
|
||||
while len(file_a) == len(file_b):
|
||||
frame_tmp = (frame_tmp * 10) + 9
|
||||
file_b = rd.frame_path(frame=frame_tmp, **kwargs)
|
||||
file_b = rd.frame_path(frame=int(frame_tmp / 10), **kwargs)
|
||||
|
||||
return ("".join((c if file_b[i] == c else ch) for i, c in enumerate(file_a)))
|
||||
|
||||
def execute(self, context):
|
||||
import os
|
||||
import subprocess
|
||||
|
@ -71,21 +88,7 @@ class PlayRenderedAnim(Operator):
|
|||
player_path = guess_player_path(preset)
|
||||
|
||||
if is_movie is False and preset in {'FRAMECYCLER', 'RV', 'MPLAYER'}:
|
||||
# replace the number with '#'
|
||||
file_a = rd.frame_path(frame=0, view=view_suffix)
|
||||
|
||||
# TODO, make an api call for this
|
||||
frame_tmp = 9
|
||||
file_b = rd.frame_path(frame=frame_tmp, view=view_suffix)
|
||||
|
||||
while len(file_a) == len(file_b):
|
||||
frame_tmp = (frame_tmp * 10) + 9
|
||||
file_b = rd.frame_path(frame=frame_tmp, view=view_suffix)
|
||||
file_b = rd.frame_path(frame=int(frame_tmp / 10), view=view_suffix)
|
||||
|
||||
file = ("".join((c if file_b[i] == c else "#")
|
||||
for i, c in enumerate(file_a)))
|
||||
del file_a, file_b, frame_tmp
|
||||
file = PlayRenderedAnim._frame_path_with_number_char(rd, "#", view=view_suffix)
|
||||
file = bpy.path.abspath(file) # expand '//'
|
||||
else:
|
||||
path_valid = True
|
||||
|
|
Loading…
Reference in New Issue