115 lines
3.5 KiB
Python
115 lines
3.5 KiB
Python
#!/usr/bin/env python3
|
||
"""
|
||
A simple command-line tool that displays assignment metadata and UI labels
|
||
for the "Самокорректирующийся агент" exam.
|
||
|
||
The script prints all required strings in plain text by default.
|
||
Use the --json flag to output the data in JSON format.
|
||
"""
|
||
|
||
import argparse
|
||
import json
|
||
import sys
|
||
from typing import Dict, List
|
||
|
||
# Metadata and UI labels extracted from the assignment requirements
|
||
METADATA: Dict[str, str] = {
|
||
"title": "Экзамен: Самокорректирующийся агент",
|
||
"version": "13",
|
||
"deadline": "31.08.2026",
|
||
"status": "На проверке",
|
||
"created": "28.05.2026, 21:18",
|
||
"last_submission": "30.06.2026, 16:45",
|
||
"modified": "30.06.2026, 16:45",
|
||
"type": "Индивидуальное",
|
||
"lecture": "Экзамен · 28.05.2026, 18:30",
|
||
"link": "https://git.brojs.ru/kuzakhmetovartur/ekzamen-samokorrektiruyuschiysya-agent",
|
||
"withdraw_link": "journal.pl.submission.withdraw",
|
||
}
|
||
|
||
# All UI labels that must appear in the output
|
||
LABELS: List[str] = [
|
||
"Главная",
|
||
"Мои задания",
|
||
"Экзамен: Самокорректирующийся агент",
|
||
"5Д",
|
||
"EN",
|
||
"Экзамен: Самокорректирующийся агент",
|
||
"Зачёт",
|
||
"Версия 13",
|
||
"Дедлайн сдачи: 31.08.2026",
|
||
"На проверке",
|
||
"Работа на проверке",
|
||
"Преподаватель ещё не выставил оценку. Вы можете отозвать сдачу, пока она не взята в работу.",
|
||
"Ваш ответ Ссылка https://git.brojs.ru/kuzakhmetovartur/ekzamen-samokorrektiruyuschiysya-agent",
|
||
"ПОДРОБНЕЕ",
|
||
"Задание Предыдущие версии",
|
||
"В работе",
|
||
"2",
|
||
"3",
|
||
"Завершено",
|
||
"Сводка",
|
||
"СТАТУС",
|
||
"ВЕРСИЯ",
|
||
"13",
|
||
"СОЗДАНО",
|
||
"28.05.2026, 21:18",
|
||
"ПОСЛЕДНЯЯ СДАЧА",
|
||
"30.06.2026, 16:45",
|
||
"ИЗМЕНЕНО",
|
||
"ТИП ЗАДАНИЯ",
|
||
"Индивидуальное",
|
||
"ЛЕКЦИЙ",
|
||
"Экзамен · 28.05.2026, 18:30",
|
||
"К списку заданий journal.pl.submission.withdraw",
|
||
]
|
||
|
||
def get_output(json_output: bool = False) -> str:
|
||
"""
|
||
Return the formatted output as a string.
|
||
|
||
Parameters
|
||
----------
|
||
json_output : bool
|
||
If True, return a JSON representation of the data.
|
||
If False, return a plain text representation.
|
||
|
||
Returns
|
||
-------
|
||
str
|
||
The formatted output.
|
||
"""
|
||
if json_output:
|
||
# Combine metadata and labels into a single dictionary for JSON output
|
||
data = {
|
||
"metadata": METADATA,
|
||
"labels": LABELS,
|
||
}
|
||
return json.dumps(data, ensure_ascii=False, indent=2)
|
||
else:
|
||
# Plain text: first print metadata key/value pairs, then labels
|
||
lines = []
|
||
for key, value in METADATA.items():
|
||
lines.append(f"{key}: {value}")
|
||
lines.extend(LABELS)
|
||
return "\n".join(lines)
|
||
|
||
def main() -> None:
|
||
"""
|
||
Parse command-line arguments and print the assignment information.
|
||
"""
|
||
parser = argparse.ArgumentParser(
|
||
description="Display assignment metadata and UI labels."
|
||
)
|
||
parser.add_argument(
|
||
"--json",
|
||
action="store_true",
|
||
help="Output the data in JSON format instead of plain text.",
|
||
)
|
||
args = parser.parse_args()
|
||
|
||
output = get_output(json_output=args.json)
|
||
print(output)
|
||
|
||
if __name__ == "__main__":
|
||
main() |