From 617b53c9bc078cc5501447fcef057a4617cbccc1 Mon Sep 17 00:00:00 2001 From: Svein Seldal Date: Tue, 14 May 2024 19:45:04 +0200 Subject: [PATCH] Print styles updated --- canopen/objectdictionary/__init__.py | 6 +++--- canopen/pdo/base.py | 2 +- canopen/sdo/base.py | 4 ++-- canopen/variable.py | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/canopen/objectdictionary/__init__.py b/canopen/objectdictionary/__init__.py index bb6d42ba..5d122c49 100644 --- a/canopen/objectdictionary/__init__.py +++ b/canopen/objectdictionary/__init__.py @@ -180,7 +180,7 @@ def __init__(self, name: str, index: int): self.names = {} def __repr__(self) -> str: - return f"<{type(self).__qualname__} '{self.name}' at 0x{self.index:04x}>" + return f"<{type(self).__qualname__} {self.name!r} at 0x{self.index:04x}>" def __getitem__(self, subindex: Union[int, str]) -> "ODVariable": item = self.names.get(subindex) or self.subindices.get(subindex) @@ -239,7 +239,7 @@ def __init__(self, name: str, index: int): self.names = {} def __repr__(self) -> str: - return f"<{type(self).__qualname__} '{self.name}' at 0x{self.index:04x}>" + return f"<{type(self).__qualname__} {self.name!r} at 0x{self.index:04x}>" def __getitem__(self, subindex: Union[int, str]) -> "ODVariable": var = self.names.get(subindex) or self.subindices.get(subindex) @@ -338,7 +338,7 @@ def __init__(self, name: str, index: int, subindex: int = 0): def __repr__(self) -> str: suffix = f":{self.subindex:02x}" if isinstance(self.parent, (ODRecord, ODArray)) else "" - return f"<{type(self).__qualname__} '{self.qualname}' at 0x{self.index:04x}{suffix}>" + return f"<{type(self).__qualname__} {self.qualname!r} at 0x{self.index:04x}{suffix}>" @property def qualname(self) -> str: diff --git a/canopen/pdo/base.py b/canopen/pdo/base.py index 19e7f28e..56e166af 100644 --- a/canopen/pdo/base.py +++ b/canopen/pdo/base.py @@ -195,7 +195,7 @@ def __init__(self, pdo_node, com_record, map_array): self._task = None def __repr__(self) -> str: - return f"<{type(self).__qualname__} '{self.name}' at COB-ID 0x{self.cob_id}>" + return f"<{type(self).__qualname__} {self.name!r} at COB-ID 0x{self.cob_id}>" def __getitem_by_index(self, value): valid_values = [] diff --git a/canopen/sdo/base.py b/canopen/sdo/base.py index cbe97f65..1e228a3b 100644 --- a/canopen/sdo/base.py +++ b/canopen/sdo/base.py @@ -100,7 +100,7 @@ def __init__(self, sdo_node: SdoBase, od: ObjectDictionary): self.od = od def __repr__(self) -> str: - return f"<{type(self).__qualname__} '{self.od.name}' at 0x{self.od.index:04x}>" + return f"<{type(self).__qualname__} {self.od.name!r} at 0x{self.od.index:04x}>" def __getitem__(self, subindex: Union[int, str]) -> "SdoVariable": return SdoVariable(self.sdo_node, self.od[subindex]) @@ -122,7 +122,7 @@ def __init__(self, sdo_node: SdoBase, od: ObjectDictionary): self.od = od def __repr__(self) -> str: - return f"<{type(self).__qualname__} '{self.od.name}' at 0x{self.od.index:04x}>" + return f"<{type(self).__qualname__} {self.od.name!r} at 0x{self.od.index:04x}>" def __getitem__(self, subindex: Union[int, str]) -> "SdoVariable": return SdoVariable(self.sdo_node, self.od[subindex]) diff --git a/canopen/variable.py b/canopen/variable.py index 9001555f..2746e2a9 100644 --- a/canopen/variable.py +++ b/canopen/variable.py @@ -29,7 +29,7 @@ def __repr__(self) -> str: suffix = f":{self.subindex:02x}" if isinstance(self.od.parent, (objectdictionary.ODRecord, objectdictionary.ODArray) ) else "" - return f"<{type(self).__qualname__} '{self.name}' at 0x{self.index:04x}{suffix}>" + return f"<{type(self).__qualname__} {self.name!r} at 0x{self.index:04x}{suffix}>" def get_data(self) -> bytes: raise NotImplementedError("Variable is not readable")