Skip to content

Commit 631f7be

Browse files
authored
align ID: in message string (hardbyte#1635)
1 parent ddc7c35 commit 631f7be

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

can/message.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,10 @@ def __init__( # pylint: disable=too-many-locals, too-many-arguments
110110
def __str__(self) -> str:
111111
field_strings = [f"Timestamp: {self.timestamp:>15.6f}"]
112112
if self.is_extended_id:
113-
arbitration_id_string = f"ID: {self.arbitration_id:08x}"
113+
arbitration_id_string = f"{self.arbitration_id:08x}"
114114
else:
115-
arbitration_id_string = f"ID: {self.arbitration_id:04x}"
116-
field_strings.append(arbitration_id_string.rjust(12, " "))
115+
arbitration_id_string = f"{self.arbitration_id:03x}"
116+
field_strings.append(f"ID: {arbitration_id_string:>8}")
117117

118118
flag_string = " ".join(
119119
[

doc/message.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ Message
4444
2\ :sup:`29` - 1 for 29-bit identifiers).
4545

4646
>>> print(Message(is_extended_id=False, arbitration_id=100))
47-
Timestamp: 0.000000 ID: 0064 S Rx DL: 0
47+
Timestamp: 0.000000 ID: 064 S Rx DL: 0
4848

4949

5050
.. attribute:: data
@@ -106,7 +106,7 @@ Message
106106
Previously this was exposed as `id_type`.
107107

108108
>>> print(Message(is_extended_id=False))
109-
Timestamp: 0.000000 ID: 0000 S Rx DL: 0
109+
Timestamp: 0.000000 ID: 000 S Rx DL: 0
110110
>>> print(Message(is_extended_id=True))
111111
Timestamp: 0.000000 ID: 00000000 X Rx DL: 0
112112

0 commit comments

Comments
 (0)