diff options
author | Campbell Barton <campbell@blender.org> | 2022-02-15 08:50:08 +0300 |
---|---|---|
committer | Campbell Barton <campbell@blender.org> | 2022-02-15 09:16:26 +0300 |
commit | fa7bd4c06954a9d5e9345000ca1d3f929ce67de1 (patch) | |
tree | 5afbe8f776397d53e0ac050258b1205c18560ade /release | |
parent | c146d75808f84fddeffb0059b31e572845a3bc49 (diff) |
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.
Diffstat (limited to 'release')
-rw-r--r-- | release/scripts/startup/bl_operators/screen_play_rendered_anim.py | 33 |
1 files changed, 18 insertions, 15 deletions
diff --git a/release/scripts/startup/bl_operators/screen_play_rendered_anim.py b/release/scripts/startup/bl_operators/screen_play_rendered_anim.py index 1c7b014992a..7ad3cacb395 100644 --- a/release/scripts/startup/bl_operators/screen_play_rendered_anim.py +++ b/release/scripts/startup/bl_operators/screen_play_rendered_anim.py @@ -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 |