Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

get_backends() sys.platform check for linux #3223

Open
sonotopes opened this issue Nov 17, 2024 · 3 comments
Open

get_backends() sys.platform check for linux #3223

sonotopes opened this issue Nov 17, 2024 · 3 comments
Assignees

Comments

@sonotopes
Copy link

src_py/camera.py

def get_backends():
    possible_backends = []

    if sys.platform == "win32" and int(platform.win32_ver()[0].split(".")[0]) >= 8:
        possible_backends.append("_camera (MSMF)")

    if "linux" in sys.platform:
        possible_backends.append("_camera (V4L2)")

    if "darwin" in sys.platform:
        possible_backends.append("OpenCV-Mac")

    possible_backends.append("OpenCV")

Sorry if this is a nitpick issue, but since CPython 3.8>= is used, couldn't this line:

    if sys.platform == "linux":
        possible_backends.append("_camera (V4L2)")

be used instead? According to the docs, there isn't really a need to use the 'in' operator since no major version will show up when accessing sys.platform (the string will just be 'linux')? Just a thought!

"Changed in version 3.3: On Linux, sys.platform doesn’t contain the major version anymore. It is always 'linux', instead of 'linux2' or 'linux3'."

@sonotopes sonotopes changed the title get_backends() sys.platform check for linux get_backends() sys.platform check for linux Nov 17, 2024
@oddbookworm
Copy link
Member

You're correct. Although, I think it looks cleaner as-is. I'm not going to block someone from making a pull request though

@sonotopes
Copy link
Author

sonotopes commented Nov 17, 2024

Gotchu. @oddbookworm Is it alright if I make a PR for this?

@oddbookworm
Copy link
Member

Go ahead if you so desire

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

No branches or pull requests

2 participants