Skip to content

Commit

Permalink
Format code with black
Browse files Browse the repository at this point in the history
  • Loading branch information
Tian-Jionglu committed Aug 3, 2023
1 parent 046e6fb commit a57190c
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions can/io/asc.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def __init__(
raise ValueError("The given file cannot be None")
self.base = base
self._converted_base = self._check_base(base)
self.version = '0.0.0'
self.version = "0.0.0"
# TODO: what is relative timestamp? Seems it should be timestamps_format
self.relative_timestamp = relative_timestamp
self.date: Optional[str] = None
Expand All @@ -74,7 +74,7 @@ def _extract_header(self) -> None:
datetime_match = re.match(
r"date\s+\w+\s+(?P<datetime_string>.+)", line, re.IGNORECASE
)

# parse base
base_match = re.match(
r"base\s+(?P<base>hex|dec)(?:\s+timestamps\s+"
Expand All @@ -84,11 +84,7 @@ def _extract_header(self) -> None:
)

# parse version
version_match = re.match(
r"// version (?P<version>.+)",
line,
re.IGNORECASE
)
version_match = re.match(r"// version (?P<version>.+)", line, re.IGNORECASE)

comment_match = re.match(r"//.*", line)
events_match = re.match(
Expand Down Expand Up @@ -135,7 +131,7 @@ def _extract_header(self) -> None:
datetime_str = trigger_match.group("datetime_string")
self.start_time = (
0.0
if self.timestamps_format == 'relative'
if self.timestamps_format == "relative"
else self._datetime_to_timestamp(datetime_str)
)
break
Expand Down Expand Up @@ -297,9 +293,12 @@ def _process_fd_can_frame_2(self, line: str, msg_kwargs: Dict[str, Any]) -> Mess
# TODO: maybe use regex to parse BRS, ESI, etc?
msg_kwargs["is_error_frame"] = True
else:
can_id_str, symbolic_name, frame_name_or_brs, rest_of_message = rest_of_message.split(
None, 3
)
(
can_id_str,
symbolic_name,
frame_name_or_brs,
rest_of_message,
) = rest_of_message.split(None, 3)

if frame_name_or_brs.isdigit():
brs = frame_name_or_brs
Expand Down Expand Up @@ -332,7 +331,6 @@ def _process_fd_can_frame_2(self, line: str, msg_kwargs: Dict[str, Any]) -> Mess

return Message(**msg_kwargs)


def __iter__(self) -> Generator[Message, None, None]:
# extract head in initial
# self._extract_header()
Expand Down Expand Up @@ -368,7 +366,7 @@ def __iter__(self) -> Generator[Message, None, None]:

if "is_fd" not in msg_kwargs:
msg = self._process_classic_can_frame(rest_of_message, msg_kwargs)
elif self.version < '8.1':
elif self.version < "8.1":
msg = self._process_fd_can_frame(rest_of_message, msg_kwargs)
else:
msg = self._process_fd_can_frame_2(rest_of_message, msg_kwargs)
Expand Down

0 comments on commit a57190c

Please sign in to comment.