Skip to content

Use url_utils.url_from_filepath() for file:// URLs in docs/examples#2033

Open
anAirdrop wants to merge 2 commits into
AcademySoftwareFoundation:mainfrom
anAirdrop:fix/target-url-file-scheme-examples
Open

Use url_utils.url_from_filepath() for file:// URLs in docs/examples#2033
anAirdrop wants to merge 2 commits into
AcademySoftwareFoundation:mainfrom
anAirdrop:fix/target-url-file-scheme-examples

Conversation

@anAirdrop

Copy link
Copy Markdown

Summary

Fixes the target_url examples in docs/tutorials/write-an-adapter.md and two example scripts (examples/conform.py, examples/shot_detect.py) that built file:// URLs by string-concatenating "file://" + path. This only produces a valid URI for POSIX-absolute paths; for relative or Windows drive-letter paths, the first path segment is silently parsed as the URL's host (RFC 3986), producing a corrupted URL.

opentimelineio.url_utils.url_from_filepath() already handles this correctly (see tests/test_url_conversions.py), this PR just points the docs and examples at it instead of hand-rolling the URL.

Related to #1985. This is the narrow docs/examples fix mentioned in that thread, scoped separately from the larger Application Integrator's Guide rewrite being discussed there.

Test plan

  • url_utils.py itself is unchanged and already covered by tests/test_url_conversions.py.
  • examples/conform.py and examples/shot_detect.py have no existing dedicated test coverage (they are standalone CLI examples, not part of the installed package), did not want to expand the scope of this PR to add new test infrastructure for the examples directory.
  • Verified python -m py_compile on both edited example scripts.

The adapter-writing tutorial and two example scripts (conform.py,
shot_detect.py) built target_url values by concatenating "file://"
directly onto a filesystem path. Per RFC 3986, this only produces a
correct file URI when the path is POSIX-absolute; for a relative path
or a Windows drive-letter path (e.g. "C:/show/movie.mov"), the first
path segment is parsed as the URL's host/netloc, silently corrupting
the URL (e.g. "file://C:/show/movie.mov" instead of the correct
"file:///C:/show/movie.mov").

opentimelineio.url_utils.url_from_filepath() already handles this
correctly (absolute vs. relative paths, Windows drive letters, UNC
paths) and is covered by tests/test_url_conversions.py. This change
points the docs and examples at that existing utility instead of
hand-rolling the URL.
@linux-foundation-easycla

linux-foundation-easycla Bot commented Jul 13, 2026

Copy link
Copy Markdown

CLA Signed
The committers listed above are authorized under a signed CLA.

  • ✅ login: anAirdrop / name: anAirdrop (91a29e9)

@codecov-commenter

codecov-commenter commented Jul 13, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 83.21%. Comparing base (0eebd21) to head (c551391).

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #2033   +/-   ##
=======================================
  Coverage   83.21%   83.21%           
=======================================
  Files         180      180           
  Lines       13465    13465           
  Branches     1253     1253           
=======================================
  Hits        11205    11205           
  Misses       2088     2088           
  Partials      172      172           
Flag Coverage Δ
py-unittests 83.21% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.


Continue to review full report in Codecov by Harness.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0eebd21...c551391. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@reinecke

Copy link
Copy Markdown
Collaborator

@anAirdrop Thanks for the fixes, these look great! Would you mind just addressing the DCO signoff issue and then I think we should be able to merge!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants