diff options
Diffstat (limited to 'src/wikiget/parse.py')
| -rw-r--r-- | src/wikiget/parse.py | 20 |
1 files changed, 20 insertions, 0 deletions
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 == "-": |
