diff --git a/gnssanalysis/gn_download.py b/gnssanalysis/gn_download.py index b2ca796..d41ed77 100644 --- a/gnssanalysis/gn_download.py +++ b/gnssanalysis/gn_download.py @@ -25,7 +25,7 @@ import ftplib as _ftplib from ftplib import FTP_TLS as _FTP_TLS from pathlib import Path as _Path -from typing import Optional as _Optional, Union as _Union, Tuple as _Tuple, List as _List +from typing import Optional as _Optional, Tuple as _Tuple, List as _List from urllib import request as _request from urllib.error import HTTPError as _HTTPError @@ -147,7 +147,7 @@ def request_metadata(url: str, max_retries: int = 5, metadata_header: str = "x-a return None -def download_url(url: str, destfile: _Union[str, _os.PathLike], max_retries: int = 5) -> _Optional[_Path]: +def download_url(url: str, destfile: str | _os.PathLike, max_retries: int = 5) -> _Optional[_Path]: logging.info(f'requesting "{url}"') for retry in range(1, max_retries + 1): try: @@ -369,16 +369,14 @@ def generate_product_filename( return product_filename, gps_date, reference_start -def check_whether_to_download( - filename: str, download_dir: _Path, if_file_present: str = "prompt_user" -) -> _Union[_Path, None]: +def check_whether_to_download(filename: str, download_dir: _Path, if_file_present: str = "prompt_user") -> _Path | None: """Determine whether to download given file (filename) to the desired location (download_dir) based on whether it is already present and what action to take if it is (if_file_present) :param str filename: Filename of the downloaded file :param _Path download_dir: Where to download files (local directory) :param str if_file_present: What to do if file already present: "replace", "dont_replace", defaults to "prompt_user" - :return _Union[_Path, None]: Path obj to the downloaded file if file should be downloaded, otherwise returns None + :return _Path | None: Path obj to the downloaded file if file should be downloaded, otherwise returns None """ # Flag to determine whether to download: download = None @@ -840,6 +838,7 @@ def download_atx(download_dir: _Path, reference_frame: str = "IGS20", if_file_pr :param _Path download_dir: Where to download files (local directory) :param str reference_frame: Coordinate reference frame file to download, defaults to "IGS20" :param str if_file_present: What to do if file already present: "replace", "dont_replace", defaults to "prompt_user" + :raises ValueError: If an invalid option is given for reference_frame variable :return _Path: The pathlib.Path of the downloaded file """ match reference_frame: diff --git a/gnssanalysis/gn_utils.py b/gnssanalysis/gn_utils.py index 54999a2..6dbd974 100644 --- a/gnssanalysis/gn_utils.py +++ b/gnssanalysis/gn_utils.py @@ -5,7 +5,7 @@ import click as _click -from typing import List as _List, Union as _Union +from typing import List as _List def diffutil_verify_input(input): @@ -52,12 +52,12 @@ def get_filetype(path): return suffix -def configure_logging(verbose: bool, output_logger: bool = False) -> _Union[_logging.Logger, None]: +def configure_logging(verbose: bool, output_logger: bool = False) -> _logging.Logger | None: """Configure the logger object with the level of verbosity requested and output if desired :param bool verbose: Verbosity of logger object to use for encoding logging strings, True: DEBUG, False: INFO :param bool output_logger: Flag to indicate whether to output the Logger object, defaults to False - :return _Union[_logging.Logger, None]: Return the logger object or None (based on output_logger) + :return _logging.Logger | None: Return the logger object or None (based on output_logger) """ if verbose: logging_level = _logging.DEBUG