Add Pretty Table project: plan, accepted documents and code
Business Case, Stakeholder Analysis, Project Plan and milestone MIL-001 with review records RC-001 to RC-003, then the Python project: PrettyTable Pokemon table, constants, pytest tests, pyproject.toml, Doxyfile, CI workflow and README. Task: MIL-001#1 Task: MIL-001#2 Task: MIL-001#3 Task: MIL-001#4 Task: MIL-001#5 Task: MIL-001#6 Task: MIL-001#7 Task: MIL-001#8
This commit is contained in:
@@ -0,0 +1,4 @@
|
||||
"""!
|
||||
@file __init__.py
|
||||
@brief Pokemon type table built with PrettyTable.
|
||||
"""
|
||||
@@ -0,0 +1,8 @@
|
||||
"""!
|
||||
@file __main__.py
|
||||
@brief Entry point for `python -m pretty_table`.
|
||||
"""
|
||||
|
||||
from pretty_table.main import main
|
||||
|
||||
main()
|
||||
@@ -0,0 +1,20 @@
|
||||
"""!
|
||||
@file constants.py
|
||||
@brief Constants of the Pokemon table: column titles and the rows shown.
|
||||
"""
|
||||
|
||||
## Title of the column holding the Pokemon name.
|
||||
COLUMN_NAME: str = "Pokemon Name"
|
||||
|
||||
## Title of the column holding the Pokemon type.
|
||||
COLUMN_TYPE: str = "Type"
|
||||
|
||||
## Column titles in display order.
|
||||
COLUMN_TITLES: tuple[str, str] = (COLUMN_NAME, COLUMN_TYPE)
|
||||
|
||||
## Pokemon names in display order, paired with their type.
|
||||
POKEMON: tuple[tuple[str, str], ...] = (
|
||||
("Pikachu", "Electric"),
|
||||
("Squirtle", "Water"),
|
||||
("Charmander", "Fire"),
|
||||
)
|
||||
@@ -0,0 +1,30 @@
|
||||
"""!
|
||||
@file main.py
|
||||
@brief Builds and prints the Pokemon type table with PrettyTable.
|
||||
"""
|
||||
|
||||
from prettytable import PrettyTable
|
||||
|
||||
from pretty_table.constants import COLUMN_NAME, COLUMN_TYPE, POKEMON
|
||||
|
||||
|
||||
def create_table() -> PrettyTable:
|
||||
"""!
|
||||
@brief Build the table of Pokemon names and their types.
|
||||
@return A PrettyTable with one row per Pokemon in POKEMON.
|
||||
"""
|
||||
table = PrettyTable()
|
||||
table.add_column(COLUMN_NAME, [name for name, _ in POKEMON])
|
||||
table.add_column(COLUMN_TYPE, [type_ for _, type_ in POKEMON])
|
||||
return table
|
||||
|
||||
|
||||
def main() -> None:
|
||||
"""!
|
||||
@brief Print the Pokemon type table to standard output.
|
||||
"""
|
||||
print(create_table())
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user