8000 Align `ID:` in message string by zariiii9003 · Pull Request #1635 · hardbyte/python-can · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Align ID: in message string #1635

New issue 8000

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

Merged
merged 1 commit into from
Jul 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions can/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,10 @@ def __init__( # pylint: disable=too-many-locals, too-many-arguments
def __str__(self) -> str:
field_strings = [f"Timestamp: {self.timestamp:>15.6f}"]
if self.is_extended_id:
arbitration_id_string = f"ID: {self.arbitration_id:08x}"
arbitration_id_string = f"{self.arbitration_id:08x}"
else:
arbitration_id_string = f"ID: {self.arbitration_id:04x}"
field_strings.append(arbitration_id_string.rjust(12, " "))
arbitration_id_string = f"{self.arbitration_id:03x}"
field_strings.append(f"ID: {arbitration_id_string:>8}")

flag_string = " ".join(
[
Expand Down
4 changes: 2 additions & 2 deletions doc/message.rst
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ Message
2\ :sup:`29` - 1 for 29-bit identifiers).

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


.. attribute:: data
Expand Down Expand Up @@ -106,7 +106,7 @@ Message
Previously this was exposed as `id_type`.

>>> print(Message(is_extended_id=False))
Timestamp: 0.000000 ID: 0000 S Rx DL: 0
Timestamp: 0.000000 ID: 000 S Rx DL: 0
>>> print(Message(is_extended_id=True))
Timestamp: 0.000000 ID: 00000000 X Rx DL: 0

Expand Down
0