Skip to content

refactor(uvc): move get_avail_uvc out of init_camera_type - #365

Merged
mryel00 merged 2 commits into
mainsail-crew:developfrom
mryel00:refactor/uvc
Aug 2, 2026
Merged

mryel00 merged 2 commits into
mainsail-crew:developfrom
mryel00:refactor/uvc

Conversation

@mryel00

@mryel00 mryel00 commented Aug 2, 2026

Copy link
Copy Markdown
Member

This moves get_avail_uvc out of init_camera_type.

Signed-off-by: Patrick Gehrsitz <github@mryel.de>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors UVC camera discovery by extracting the /dev/v4l enumeration helper (get_avail_uvc) out of init_camera_type, making the discovery logic reusable and easier to read.

Changes:

  • Extracted get_avail_uvc from the local nested function into a dedicated UVC class method.
  • Updated init_camera_type to call the extracted helper when building the available UVC camera map.
Suppressed comments (2)

crowsnest/camera/types/uvc.py:117

  • Same as above: avoid hard-coding UVC for this helper call; use cls for consistency within a @classmethod.
                "by_id": avail_by_id.get(dev_path, None),
            }
            for dev_path, by_path in UVC.get_avail_uvc("/dev/v4l/by-path").items()
            if "usb" in by_path

crowsnest/camera/types/uvc.py:110

  • init_camera_type is a @classmethod, but this call hard-codes UVC instead of using cls, which makes future renames/subclassing harder (and is inconsistent once get_avail_uvc is a static/class method).
    def init_camera_type(cls) -> Sequence[UVC]:
        avail_by_id = UVC.get_avail_uvc("/dev/v4l/by-id/")


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread crowsnest/camera/types/uvc.py Resolved
Signed-off-by: Patrick Gehrsitz <github@mryel.de>
@mryel00
mryel00 merged commit 4360424 into mainsail-crew:develop Aug 2, 2026
4 checks passed
@mryel00
mryel00 deleted the refactor/uvc branch August 2, 2026 10:04
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