From 96316c8be7bc21617ec5333f87864a0f002ebaa4 Mon Sep 17 00:00:00 2001 From: Cody Logan Date: Wed, 8 Nov 2023 12:53:25 -0800 Subject: Add and refine docstrings in src folder --- src/wikiget/parse.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'src/wikiget/parse.py') diff --git a/src/wikiget/parse.py b/src/wikiget/parse.py index 82e9172..92726f0 100644 --- a/src/wikiget/parse.py +++ b/src/wikiget/parse.py @@ -34,6 +34,16 @@ logger = logging.getLogger(__name__) def get_dest(dl: str, args: Namespace) -> File: + """Parse the given download target for filename, destination, and site host. + + :param dl: download target (filename or URL) + :type dl: str + :param args: command-line arguments and their values + :type args: argparse.Namespace + :raises ParseError: the target was unable to be parsed as a valid file + :return: a File object representing the target, destination, and site + :rtype: File + """ url = urlparse(dl) if url.netloc: @@ -64,6 +74,16 @@ def get_dest(dl: str, args: Namespace) -> File: def read_batch_file(batch_file: str) -> dict[int, str]: + """Parse a batch file or stdin for valid input. + + The contents are returned as a dictionary with line numbers for keys and line + contents for values. Any blank lines or lines starting with '#' are skipped. + + :param batch_file: name of the file to parse or "-" for stdin + :type batch_file: str + :return: a dictionary representation of the input contents + :rtype: dict[int, str] + """ dl_dict = {} if batch_file == "-": -- cgit v1.2.3