From dfb469d577bef4a2a2fcd5fb021d27d2eae977e6 Mon Sep 17 00:00:00 2001 From: Jamie Hardt Date: Tue, 8 Oct 2019 10:05:32 -0700 Subject: [PATCH] Update broadcast_timecode.py File reformat --- ptulsconv/broadcast_timecode.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/ptulsconv/broadcast_timecode.py b/ptulsconv/broadcast_timecode.py index eb2ca46..5820ee7 100644 --- a/ptulsconv/broadcast_timecode.py +++ b/ptulsconv/broadcast_timecode.py @@ -48,14 +48,14 @@ def smpte_to_frame_count(smpte_rep_string: str, frames_per_logical_second: int, def frame_count_to_smpte(frame_count: int, frames_per_logical_second: int, drop_frame: bool = False, fractional_frame: float = None): - assert frames_per_logical_second in [24,25,30,48,50,60] + assert frames_per_logical_second in [24, 25, 30, 48, 50, 60] assert fractional_frame is None or fractional_frame < 1.0 nominal_frames = frame_count separator = ":" if drop_frame: assert frames_per_logical_second in [30, 60] - mins , _= divmod(nominal_frames, frames_per_logical_second * 60) + mins, _ = divmod(nominal_frames, frames_per_logical_second * 60) frames_dropped_per_inst = (frames_per_logical_second / 15) inst_count = mins - math.floor(mins / 10) dropped_frames = frames_dropped_per_inst * inst_count @@ -72,7 +72,8 @@ def frame_count_to_smpte(frame_count: int, frames_per_logical_second: int, drop_ else: return "%02i:%02i:%02i%s%02i" % (hh, mm, ss, separator, ff) -def footage_to_frame_count(footage_string, include_fractional = False): + +def footage_to_frame_count(footage_string, include_fractional=False): m = re.search("(\d+)\+(\d+)(\.\d+)?", footage_string) feet, frm, frac = m.groups() feet, frm, frac = int(feet), int(frm), float(frac or 0.0) @@ -84,10 +85,12 @@ def footage_to_frame_count(footage_string, include_fractional = False): else: return frames -def frame_count_to_footage(frame_count, fractional_frames = None): - assert fractional_frames < 1.0 or fractional_frames is None + +def frame_count_to_footage(frame_count, fractional_frames=None): + assert fractional_frames is None or fractional_frames < 1.0 feet, frm = divmod(frame_count, 16) - if fractional_frames: + + if fractional_frames is None: return "%i+%02i" % (feet, frm) else: - return "%i+%02i%s" % (feet, frm, ("%.3f" % fractional_frames)[1:]) \ No newline at end of file + return "%i+%02i%s" % (feet, frm, ("%.3f" % fractional_frames)[1:])