From d1581cd00fa09bc962251821238f0a121783e3d8 Mon Sep 17 00:00:00 2001 From: Guido Draheim Date: Wed, 31 Jul 2024 00:41:41 +0200 Subject: [PATCH] optional report --- jira2data.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/jira2data.py b/jira2data.py index ad2981f..9d64ed7 100755 --- a/jira2data.py +++ b/jira2data.py @@ -6,7 +6,7 @@ __copyright__ = "(C) 2022-2024 Guido Draheim, licensed under the Apache License 2.0""" __version__ = "0.4.3313" -from typing import Union, Dict, List, Any, Optional, Tuple, Iterable, Iterator, cast +from typing import Union, Dict, List, Any, Optional, Tuple, Iterable, Iterator, cast, NamedTuple from requests import Session, Response, HTTPError from requests.packages.urllib3.exceptions import InsecureRequestWarning # type: ignore[import] import warnings @@ -420,7 +420,11 @@ def each_jiraZeitData(api: JiraFrontend, user: str = NIX, days: Optional[dayrang for line in lines: yield {zeit_txt: line} -def run(remote: JiraFrontend, args: List[str]) -> int: +class Report(NamedTuple): + data: JSONList + summary: List[str] + +def report(remote: JiraFrontend, args: List[str]) -> Optional[Report]: global DAYS, OUTPUT if TASKDATA: read_odoo_taskdata(TASKDATA) @@ -446,7 +450,7 @@ def run(remote: JiraFrontend, args: List[str]) -> int: if report_name: print(f"{report_name} {report_func}") report_name = None - return 0 + return None report = arg.lower() if report in ["allprojects"]: result = list(jiraGetProjects(remote)) # list all Jira project trackers (including unused) @@ -473,8 +477,13 @@ def run(remote: JiraFrontend, args: List[str]) -> int: OUTPUT = "wide" else: logg.error("unknown report %s", report) + return Report(result, summary) + +def run(remote: JiraFrontend, args: List[str]) -> int: headers = ["upcreated", "Quantity", "Description", "comment"] - if result: + reportresults = report(remote, args) + if reportresults: + result, summary = reportresults summary += ["found %s items" % (len(result))] done = print_tabtotext(OUTPUT, result, headers, LABELS, legend=summary) if done: