Skip to content

ImageSequenceReference: If target_url_base is empty string, target_url_for_image_number raises IndexError #890

@reinecke

Description

@reinecke

Incorrect Functionality

It is sometimes useful to generate a base file name for an image without the full URL path leading up to the file name. One would expect to be able to set target_url_base to an empty string (the default value) to achieve this. However it does not work as expected:

import opentimelineio as otio

ref = otio.schema.ImageSequenceReference(
    name_prefix="myfilename.",
    name_suffix=".exr",
    start_frame=101,
    rate=24,
    frame_zero_padding=4,
    available_range=otio.opentime.TimeRange(
        otio.opentime.from_timecode("01:25:30:04", rate=24),
        duration=otio.opentime.from_frames(48, 24)
    ),
)

print(ref.target_url_for_image_number(0))

Results in:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
IndexError: basic_string

If we set target_url_base to an string of any length greater than zero, the exception goes away:

>>> ref.target_url_base = " "
>>> ref.target_url_for_image_number(0)
' /myfilename.0101.exr'

Expected Behavior

I would expect to be able to set target_url_base to an empty string and have it generate a bare filename:

>>> ref.target_url_base = ""
>>> ref.target_url_for_image_number(0)
'myfilename.0101.exr'

This has usefulness in cases where your application contains better information about the containing context for the file and wants to generate just the filename itself without a full path.

Metadata

Metadata

Assignees

Labels

bugA problem, flaw, or broken functionality.good first issueIf you're looking for a way to contribute, but not sure where to start. This is a good first issue.

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions