Skip to content
New issue

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

chore: Remove tabulate dependency #598

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
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
27 changes: 1 addition & 26 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ aiosqlite = ">=0.18"
argcomplete = ">=2,<4"
zstandard = ">=0.19"
python-can = "^4.2"
tabulate = ">=0.9"
construct = "^2.10"
msgspec = ">=0.11,<0.19"
pydantic = "^2.0"
Expand All @@ -58,7 +57,6 @@ pytest-asyncio = ">=0.20,<0.25"
python-lsp-server = "^1.5"
types-aiofiles = ">=23.1,<25.0"
types-psutil = ">=5.9.5.10,<7.0.0.0"
types-tabulate = "^0.9"
myst-parser = ">=3.0.1,<4.1"
sphinx-rtd-theme = ">=1,<3"
reuse = "^4.0"
Expand Down
14 changes: 6 additions & 8 deletions src/gallia/commands/primitive/uds/dtc.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
from argparse import Namespace
from functools import partial

from tabulate import tabulate

from gallia.command import UDSScanner
from gallia.log import get_logger
from gallia.services.uds.core.constants import (
Expand All @@ -17,7 +15,7 @@
)
from gallia.services.uds.core.service import NegativeResponse
from gallia.services.uds.core.utils import g_repr
from gallia.utils import auto_int
from gallia.utils import auto_int, format_table

logger = get_logger(__name__)

Expand Down Expand Up @@ -167,10 +165,10 @@ def show_bit_legend(self) -> None:
"7 = warningIndicatorRequested: existing warning indicators (e.g. lamp, display)",
]

for line in (
tabulate([[d] for d in bit_descriptions], headers=["bit descriptions"])
).splitlines():
logger.result(line)
logger.result("bit descriptions")
logger.result("----------------")
for bit in bit_descriptions:
logger.result(bit)

def show_summary(self, dtcs: list[list[str]]) -> None:
dtcs.sort()
Expand All @@ -188,7 +186,7 @@ def show_summary(self, dtcs: list[list[str]]) -> None:
"7",
]

for line in tabulate(dtcs, headers=header, tablefmt="fancy_grid").splitlines():
for line in format_table([header + dtcs]).splitlines():
logger.result(line)

async def clear(self, args: Namespace) -> None:
Expand Down
9 changes: 9 additions & 0 deletions src/gallia/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,15 @@ def camel_to_dash(s: str) -> str:
return camel_to_snake(s).replace("_", "-")


def format_table(data: list[list[Any]]) -> str:
out = ""
for row in data:
row_format ="{:>15}" * (len(row) + 1)
row_format += "\n"
out += row_format.format(*row)
return out


def isotp_addr_repr(a: int) -> str:
"""
Default string representation of a CAN id.
Expand Down
Loading