forked from AFPy/potodo
Simplify 'hide_reserved' handling.
This commit is contained in:
parent
7b566e0e4b
commit
f224a10fa5
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue
Block a user