1
0
mirror of https://git.kernel.org/pub/scm/libs/libgpiod/libgpiod.git synced 2026-10-25 12:39:18 +03:00
Files
libgpiod/bindings/python/gpiod/edge_event.py
Bartosz Golaszewski 4687bcc4f4 bindings: python: specify the symbols to export explicitly
We're currently unintentionally exporting a bunch of symbols that should
remain local to sub-modules. Use __all__ where appropriate so that we
don't re-export standard library functions such as select() etc. in the
gpiod module.

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2023-05-25 15:30:25 +02:00

49 lines
1.3 KiB
Python

# SPDX-License-Identifier: LGPL-2.1-or-later
# SPDX-FileCopyrightText: 2022 Bartosz Golaszewski <brgl@bgdev.pl>
from . import _ext
from dataclasses import dataclass
from enum import Enum
__all__ = "EdgeEvent"
@dataclass(frozen=True, init=False, repr=False)
class EdgeEvent:
"""
Immutable object containing data about a single edge event.
"""
class Type(Enum):
RISING_EDGE = _ext.EDGE_EVENT_TYPE_RISING
FALLING_EDGE = _ext.EDGE_EVENT_TYPE_FALLING
event_type: Type
timestamp_ns: int
line_offset: int
global_seqno: int
line_seqno: int
def __init__(
self,
event_type: int,
timestamp_ns: int,
line_offset: int,
global_seqno: int,
line_seqno: int,
):
object.__setattr__(self, "event_type", EdgeEvent.Type(event_type))
object.__setattr__(self, "timestamp_ns", timestamp_ns)
object.__setattr__(self, "line_offset", line_offset)
object.__setattr__(self, "global_seqno", global_seqno)
object.__setattr__(self, "line_seqno", line_seqno)
def __str__(self):
return "<EdgeEvent type={} timestamp_ns={} line_offset={} global_seqno={} line_seqno={}>".format(
self.event_type,
self.timestamp_ns,
self.line_offset,
self.global_seqno,
self.line_seqno,
)