Simplify 'hide_reserved' handling.

This commit is contained in:
Julien Palard 2023-03-12 21:54:04 +01:00
parent 7b566e0e4b
commit f224a10fa5
Signed by: mdk
GPG Key ID: 0EFC1AC1006886F8
2 changed files with 6 additions and 24 deletions

View File

@ -6,8 +6,10 @@ from typing import Any, Dict, List, Tuple
import requests
def _get_reservation_list(api_url: str) -> Dict[str, Tuple[Any, Any]]:
"""Will get the repository name then request all the issues and put them in a dict""" # noqa
def get_issue_reservations(api_url: str) -> Dict[str, Tuple[Any, Any]]:
"""Will get the repository name then request all the issues and put them in a dict"""
logging.info("Getting issue reservations from git.afpy.org")
issues: List[Dict[Any, Any]] = []
logging.debug("Getting %s", api_url)
next_url = api_url
@ -40,23 +42,3 @@ def _get_reservation_list(api_url: str) -> Dict[str, Tuple[Any, Any]]:
logging.debug("Found %s reservations", len(reservations))
return reservations
def get_issue_reservations(
hide_reserved: bool,
api_url: str,
) -> Dict[str, Tuple[Any, Any]]:
"""Retrieve info about reservation if needed."""
if api_url and not hide_reserved:
logging.info("Getting issue reservations from git.afpy.org")
# If the reservations are to be displayed, then get them
issue_reservations = _get_reservation_list(api_url)
else:
logging.debug(
"Reservation list set to be empty because Potodo was started offline"
" or hiding the reservations."
)
# Otherwise, an empty dict will do the trick
issue_reservations = {}
return issue_reservations

View File

@ -53,8 +53,8 @@ def scan_path(
if not no_cache:
po_project.write_cache(cache_path)
if api_url:
issue_reservations = get_issue_reservations(hide_reserved, api_url)
if api_url and not hide_reserved:
issue_reservations = get_issue_reservations(api_url)
for po_file_stats in po_project.files.values():
reserved_by, reservation_date = issue_reservations.get(
po_file_stats.filename_dir.lower(), (None, None)