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

Commit

Permalink
jobs.py: get_validated_main_subjects_as_jobs(): Print that we exit if…
Browse files Browse the repository at this point in the history
… no more main subjects to go though and no jobs either.

console.py: print_job_statistics(): Guard against jobs list being empty before showing statistics.
  • Loading branch information
dpriskorn committed Jan 16, 2022
1 parent 182df38 commit 9704911
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 11 deletions.
9 changes: 6 additions & 3 deletions src/helpers/console.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,12 @@ def print_finished():
def print_job_statistics(jobs: List[BatchJob] = None):
if jobs is None:
raise ValueError("jobs was None")
console.print(f"The jobs list now contain a total of {len(jobs)} "
f"jobs with a total of "
f"{sum(len(job.items.list) for job in jobs)} items")
if len(jobs) > 0:
console.print("The jobs list is empty")
else:
console.print(f"The jobs list now contain a total of {len(jobs)} "
f"jobs with a total of "
f"{sum(len(job.items.list) for job in jobs)} items")


def ask_discard_existing_job_pickle():
Expand Down
20 changes: 12 additions & 8 deletions src/helpers/jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,14 +165,18 @@ def get_validated_main_subjects_as_jobs(args: argparse.Namespace = None,
if job is not None:
jobs.append(job)
print_job_statistics(jobs=jobs)
if (
args.no_ask_match_more_limit is None or
args.no_ask_match_more_limit < sum(len(job.items.list) for job in jobs)
):
answer_was_yes = ask_yes_no_question("Match one more?")
if not answer_was_yes:
break
if len(subjects_not_picked_yet) > 0:
if (
args.no_ask_match_more_limit is None or
args.no_ask_match_more_limit < sum(len(job.items.list) for job in jobs)
):
answer_was_yes = ask_yes_no_question("Match one more?")
if not answer_was_yes:
break
else:
console.print("No more subjects in the list.")
break
else:
console.print("No more subjects in the list.")
console.print("No more subjects in the list. Exiting.")
break
return jobs

0 comments on commit 9704911

Please sign in to comment.