Skip to content
This repository has been archived by the owner on Jan 18, 2025. It is now read-only.

Commit

Permalink
chore: improve print console output
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinNitroG committed Jan 15, 2025
1 parent c789ae4 commit 1e20b4a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/check_phat_nguoi/context/plates/models/plate_detail.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def __str__(self) -> str:
plate_detail
+ "\n"
+ "\n".join(
f"Lỗi vi phạm #{order}:\n" + str(violation)
f"Lỗi vi phạm #{order}:\n{violation}\n"
for order, violation in enumerate(self.violations, start=1)
)
)
Expand Down
10 changes: 8 additions & 2 deletions src/check_phat_nguoi/context/plates/models/violation_detail.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class ViolationDetail(BaseModel):
@override
def __str__(self) -> str:
return (
(f"Biển: {self.plate}" if self.plate else "")
(f"Biển vi phạm: {self.plate}" if self.plate else "")
+ (f"\nMàu biển: {self.color}" if self.color else "")
+ (f"\nLoại xe: {get_vehicle_str_vie(self.type)}" if self.type else "")
+ (f"\nThời điểm vi phạm: {self.date}" if self.date else "")
Expand All @@ -71,7 +71,13 @@ def __str__(self) -> str:
else ""
)
+ (
"\n" + "\n".join(self.resolution_offices)
(
"\n"
+ "\n".join(
f"- {resolution_office}"
for resolution_office in self.resolution_offices
)
)
if self.resolution_offices
else ""
)
Expand Down
4 changes: 2 additions & 2 deletions src/check_phat_nguoi/print_console/print_console.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ def print_console(self) -> None:
if not self.plate_details:
logger.info("No plate details. Skip printing")
return
for plate_detail in self.plate_details:
print(plate_detail)
# HACK: Have to convert each plate detail to str to use join method :v
print("\n---\n".join(str(plate_detail) for plate_detail in self.plate_details))

0 comments on commit 1e20b4a

Please sign in to comment.