Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 11 additions & 10 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ on:
push:
branches:
- main
- dev
pull_request:
branches:
- main
Expand All @@ -21,7 +20,7 @@ concurrency:

jobs:
build:
runs-on: ubuntu-latest
runs-on: macos-latest

steps:
- name: Checkout repository
Expand All @@ -31,26 +30,27 @@ jobs:
uses: actions/setup-python@v5
with:
python-version: '3.11'
cache: 'pip'

- name: Install uv
uses: astral-sh/setup-uv@v5
with:
enable-cache: true

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install sphinx pydata-sphinx-theme
pip install -e .
run: uv sync

- name: Build documentation
- name: Build documentation with make
run: |
cd docs
sphinx-build -b html . _build/html
uv run make html

- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: docs/_build/html

deploy:
# Only deploy on pushes to main branch
# Only deploy on pushes to main
if: github.event_name == 'push' && github.ref == 'refs/heads/main'

environment:
Expand All @@ -64,3 +64,4 @@ jobs:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4

10 changes: 4 additions & 6 deletions .github/workflows/publish-to-pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,15 @@ jobs:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: "3.11"

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build
- name: Install uv
uses: astral-sh/setup-uv@v5

- name: Build package
run: python -m build
run: uv build

- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
Expand Down
619 changes: 122 additions & 497 deletions README.md

Large diffs are not rendered by default.

14 changes: 12 additions & 2 deletions dftt_timecode/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,18 @@
from dftt_timecode.core.dftt_timecode import DfttTimecode
from dftt_timecode.core.dftt_timerange import DfttTimeRange

# Read version from package metadata (populated from pyproject.toml)
try:
from importlib.metadata import version, PackageNotFoundError
try:
__version__ = version("dftt-timecode")
except PackageNotFoundError:
# Package is not installed, use a fallback version
__version__ = "0.0.0+dev"
except ImportError:
# Python < 3.8 fallback (though we require 3.11+)
__version__ = "0.0.0+dev"


# Aliases for easier importing
def timecode(*args, **kwargs) -> DfttTimecode:
Expand Down Expand Up @@ -101,9 +113,7 @@ def dtr(*args, **kwargs) -> DfttTimeRange:
"""
return DfttTimeRange(*args, **kwargs)


name = "dftt_timecode"
__author__ = "You Ziyuan"
__version__ = "0.0.15a2"

__all__ = ["DfttTimecode", "DfttTimeRange", "timecode", "timerange", "dtc", "dtr"]
56 changes: 1 addition & 55 deletions docs/api/dftt_timecode.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
DfttTimecode API
================

.. currentmodule:: dftt_timecode
.. currentmodule:: dftt_timecode.core.dftt_timecode
Comment thread
WheheoHu marked this conversation as resolved.

.. autoclass:: DfttTimecode
:members:
Expand All @@ -14,60 +14,6 @@ Core Class

The :class:`DfttTimecode` class is the main interface for working with timecodes in various formats.

Constructor
~~~~~~~~~~~

.. automethod:: DfttTimecode.__init__

Properties
~~~~~~~~~~

.. autoproperty:: DfttTimecode.type
.. autoproperty:: DfttTimecode.fps
.. autoproperty:: DfttTimecode.framecount
.. autoproperty:: DfttTimecode.timestamp
.. autoproperty:: DfttTimecode.is_drop_frame
.. autoproperty:: DfttTimecode.is_strict
.. autoproperty:: DfttTimecode.precise_timestamp

Methods
~~~~~~~

.. automethod:: DfttTimecode.set_fps
.. automethod:: DfttTimecode.set_type
.. automethod:: DfttTimecode.set_strict
.. automethod:: DfttTimecode.timecode_output

Operators
~~~~~~~~~

Arithmetic Operators
^^^^^^^^^^^^^^^^^^^^

.. automethod:: DfttTimecode.__add__
.. automethod:: DfttTimecode.__sub__
.. automethod:: DfttTimecode.__mul__
.. automethod:: DfttTimecode.__truediv__
.. automethod:: DfttTimecode.__neg__

Comparison Operators
^^^^^^^^^^^^^^^^^^^^

.. automethod:: DfttTimecode.__eq__
.. automethod:: DfttTimecode.__ne__
.. automethod:: DfttTimecode.__lt__
.. automethod:: DfttTimecode.__le__
.. automethod:: DfttTimecode.__gt__
.. automethod:: DfttTimecode.__ge__

Type Conversion Operators
^^^^^^^^^^^^^^^^^^^^^^^^^^

.. automethod:: DfttTimecode.__int__
.. automethod:: DfttTimecode.__float__
.. automethod:: DfttTimecode.__str__
.. automethod:: DfttTimecode.__repr__

Supported Timecode Types
-------------------------

Expand Down
50 changes: 7 additions & 43 deletions docs/api/dftt_timerange.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
DfttTimeRange API
=================

.. currentmodule:: dftt_timecode
.. currentmodule:: dftt_timecode.core.dftt_timerange
Comment thread
WheheoHu marked this conversation as resolved.

.. autoclass:: DfttTimeRange
:members:
Expand All @@ -14,34 +14,6 @@ Core Class

The :class:`DfttTimeRange` class represents a time range with start and end points, built on top of :class:`DfttTimecode`.

Constructor
~~~~~~~~~~~

.. automethod:: DfttTimeRange.__init__

Properties
~~~~~~~~~~

.. autoproperty:: DfttTimeRange.start
.. autoproperty:: DfttTimeRange.end
.. autoproperty:: DfttTimeRange.duration

Methods
~~~~~~~

.. automethod:: DfttTimeRange.contains
.. automethod:: DfttTimeRange.overlaps
.. automethod:: DfttTimeRange.intersect

Operators
~~~~~~~~~

.. automethod:: DfttTimeRange.__contains__
.. automethod:: DfttTimeRange.__eq__
.. automethod:: DfttTimeRange.__ne__
.. automethod:: DfttTimeRange.__str__
.. automethod:: DfttTimeRange.__repr__

Examples
--------

Expand All @@ -60,8 +32,8 @@ Basic Usage
# Get duration
print(range1.duration.timecode_output('smpte')) # '01:00:00:00'

Checking Containment
~~~~~~~~~~~~~~~~~~~~
Checking Containment and Intersection
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

.. code-block:: python

Expand All @@ -71,20 +43,12 @@ Checking Containment
if tc in range1:
print("Timecode is within range")

Checking Overlaps
~~~~~~~~~~~~~~~~~

.. code-block:: python

# Create another range
range2 = DfttTimeRange(
DfttTimecode('01:30:00:00', 'auto', fps=24),
DfttTimecode('02:30:00:00', 'auto', fps=24)
)

# Check if ranges overlap
if range1.overlaps(range2):
print("Ranges overlap")

# Get intersection
intersection = range1.intersect(range2)
print(intersection)
# Get intersection of two ranges
intersection = range1.intersect(range2)
print(intersection)
Loading