From: Vincent Fazio Date: Thu, 14 Nov 2024 14:50:55 +0000 (-0600) Subject: bindings: python: make internal a private submodule X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=b306ce694ab1acf75502ae1cedf8ab6d8d9e7647;p=qemu-gpiodev%2Flibgpiod.git bindings: python: make internal a private submodule The internal submodule shouldn't be exposed as part of the public interface, so mark it private following PEP 8 convention [0]. [0]: https://peps.python.org/pep-0008/#public-and-internal-interfaces Signed-off-by: Vincent Fazio Link: https://lore.kernel.org/r/20241114145116.2123714-3-vfazio@xes-inc.com Signed-off-by: Bartosz Golaszewski --- diff --git a/bindings/python/gpiod/_internal.py b/bindings/python/gpiod/_internal.py new file mode 100644 index 0000000..d1e95e4 --- /dev/null +++ b/bindings/python/gpiod/_internal.py @@ -0,0 +1,18 @@ +# SPDX-License-Identifier: GPL-2.0-or-later +# SPDX-FileCopyrightText: 2022 Bartosz Golaszewski + +from datetime import timedelta +from select import select +from typing import Optional, Union + +__all__ = ["poll_fd"] + + +def poll_fd(fd: int, timeout: Optional[Union[timedelta, float]] = None) -> bool: + if isinstance(timeout, timedelta): + sec = timeout.total_seconds() + else: + sec = timeout + + readable, _, _ = select([fd], [], [], sec) + return True if fd in readable else False diff --git a/bindings/python/gpiod/chip.py b/bindings/python/gpiod/chip.py index 29c30f5..175fcb0 100644 --- a/bindings/python/gpiod/chip.py +++ b/bindings/python/gpiod/chip.py @@ -6,8 +6,8 @@ from errno import ENOENT from typing import TYPE_CHECKING, Optional, Union from . import _ext +from ._internal import poll_fd from .exception import ChipClosedError -from .internal import poll_fd from .line import Value from .line_request import LineRequest from .line_settings import LineSettings, _line_settings_to_ext diff --git a/bindings/python/gpiod/internal.py b/bindings/python/gpiod/internal.py deleted file mode 100644 index d1e95e4..0000000 --- a/bindings/python/gpiod/internal.py +++ /dev/null @@ -1,18 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0-or-later -# SPDX-FileCopyrightText: 2022 Bartosz Golaszewski - -from datetime import timedelta -from select import select -from typing import Optional, Union - -__all__ = ["poll_fd"] - - -def poll_fd(fd: int, timeout: Optional[Union[timedelta, float]] = None) -> bool: - if isinstance(timeout, timedelta): - sec = timeout.total_seconds() - else: - sec = timeout - - readable, _, _ = select([fd], [], [], sec) - return True if fd in readable else False diff --git a/bindings/python/gpiod/line_request.py b/bindings/python/gpiod/line_request.py index 292fa1b..a8e4a87 100644 --- a/bindings/python/gpiod/line_request.py +++ b/bindings/python/gpiod/line_request.py @@ -4,9 +4,8 @@ from typing import TYPE_CHECKING, Optional, Union from . import _ext - +from ._internal import poll_fd from .exception import RequestReleasedError -from .internal import poll_fd from .line_settings import LineSettings, _line_settings_to_ext if TYPE_CHECKING: