Project Name: nbedos+termtosvg
Language: Python
Statement Type: API

Source Code:
def timed_frames(records, min_frame_dur=1, max_frame_dur=None, last_frame_dur=1000):
    """Return a tuple made of the geometry of the screen and a generator of
    instances of TimedFrame computed from asciicast records

    Asciicast records are first coalesced so that the mininum duration between
    two frames is at least `min_frame_dur` milliseconds. Events with a duration
    greater than `max_frame_dur` will see their duration reduced to that value.

    The duration of all frames lasting until the end of the animation
    will be adjusted so that the last frame of the animation lasts
    `last_frame_dur`

    :param records: Terminal session record in Asciicast v2 format
    :param min_frame_dur: Minimum frame duration in milliseconds (integer)
    :param min_frame_dur: Minimum frame duration in milliseconds (integer)
    :param max_frame_dur: Maximum frame duration in milliseconds (None or
    integer)
    :param last_frame_dur: Duration of the last frame of the animation
    (integer)
    """
    if not isinstance(records, Iterator):
        records = iter(records)

    header = next(records)
    assert isinstance(header, AsciiCastV2Header)

    if not max_frame_dur and header.idle_time_limit:
        max_frame_dur = int(header.idle_time_limit * 1000)

    def generator():
        screen = pyte.Screen(header.width, header.height)
        stream = pyte.Stream(screen)
        timed_records = _group_by_time(records, min_frame_dur, max_frame_dur,
                                       last_frame_dur)

        for record_ in timed_records:
            assert isinstance(record_, AsciiCastV2Event)
            for char in record_.event_data:
                stream.feed(char)
            yield TimedFrame(int(1000 * record_.time),
                             int(1000 * record_.duration),
                             _screen_buffer(screen))

    return (header.width, header.height), generator()

timed_frames(records=[AsciiCastV2Header(version=2, width=80, height=24, theme=AsciiCastV2Theme(fg='#000000', bg='#FFFFFF', palette='#123456:#123456:#123456:#123456:#123456:#123456:#123456:#123456:#123456:#123456:#123456:#123456:#123456:#123456:#123456:#123456'), idle_time_limit=None), AsciiCastV2Event(time=0, event_type='o', event_data='0\r\n', duration=None), AsciiCastV2Event(time=1, event_type='o', event_data='1\r\n', duration=None)], min_frame_dur=1, max_frame_dur=None, last_frame_dur=42)

Selected Statement: records = iter(records)

Function Input:
records: [AsciiCastV2Header(version=2, width=80, height=24, theme=AsciiCastV2Theme(fg='#000000', bg='#FFFFFF', palette='#123456:#123456:#123456:#123456:#123456:#123456:#123456:#123456:#123456:#123456:#123456:#123456:#123456:#123456:#123456:#123456'), idle_time_limit=None), AsciiCastV2Event(time=0, event_type='o', event_data='0\r\n', duration=None), AsciiCastV2Event(time=1, event_type='o', event_data='1\r\n', duration=None)]
min_frame_dur: 1
max_frame_dur: None
last_frame_dur: 42

Variable Values Before Statement:
records: [AsciiCastV2Header(version=2, width=80, height=24, theme=AsciiCastV2Theme(fg='#000000', bg='#FFFFFF', palette='#123456:#123456:#123456:#123456:#123456:#123456:#123456:#123456:#123456:#123456:#123456:#123456:#123456:#123456:#123456:#123456'), idle_time_limit=None), AsciiCastV2Event(time=0, event_type='o', event_data='0\r\n', duration=None), AsciiCastV2Event(time=1, event_type='o', event_data='1\r\n', duration=None)]

Value After Statement Execution: REPR FAILED

Variable States During Runtime (line, value):
records: 1
[AsciiCastV2Header(version=2, width=80, height=24, theme=AsciiCastV2Theme(fg='#000000', bg='#FFFFFF', palette='#123456:#123456:#123456:#123456:#123456:#123456:#123456:#123456:#123456:#123456:#123456:#123456:#123456:#123456:#123456:#123456'), idle_time_limit=None), AsciiCastV2Event(time=0, event_type='o', event_data='0\r\n', duration=None), AsciiCastV2Event(time=1, event_type='o', event_data='1\r\n', duration=None)]
22
REPR FAILED
min_frame_dur: 1
1
max_frame_dur: 1
None
last_frame_dur: 1
42
header: 24
AsciiCastV2Header(version=2, width=80, height=24, theme=AsciiCastV2Theme(fg='#000000', bg='#FFFFFF', palette='#123456:#123456:#123456:#123456:#123456:#123456:#123456:#123456:#123456:#123456:#123456:#123456:#123456:#123456:#123456:#123456'), idle_time_limit=None)
generator: 30
<function timed_frames.<locals>.generator at 0x7ff5e9385dc0>