aboutsummaryrefslogtreecommitdiff
path: root/src/wikiget/parse.py
diff options
context:
space:
mode:
authorCody Logan <cody@lokken.dev>2023-10-27 11:44:26 -0700
committerCody Logan <cody@lokken.dev>2023-10-27 11:44:26 -0700
commit78937820a82931baffb02c145b37c95af71b44bc (patch)
tree401caca42901d67c8a4b84c0c9e4ce9e0a2d845b /src/wikiget/parse.py
parent648496c1492c3e54f8b8965d9511d652d18ee8cd (diff)
downloadwikiget-78937820a82931baffb02c145b37c95af71b44bc.tar.gz
wikiget-78937820a82931baffb02c145b37c95af71b44bc.zip
Move batch file processing to parse module
Diffstat (limited to 'src/wikiget/parse.py')
-rw-r--r--src/wikiget/parse.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/wikiget/parse.py b/src/wikiget/parse.py
index 52cc262..998136a 100644
--- a/src/wikiget/parse.py
+++ b/src/wikiget/parse.py
@@ -59,3 +59,19 @@ def get_dest(dl: str, args: Namespace) -> File:
file = File(filename, dest, site_name)
return file
+
+
+def read_batch_file(batch_file: str) -> dict[int, str]:
+ dl_list = {}
+
+ logger.info(f"Using batch file '{batch_file}'.")
+
+ with open(batch_file) as fd:
+ # read the file into memory and process each line as we go
+ for line_num, line in enumerate(fd, start=1):
+ line_s = line.strip()
+ # ignore blank lines and lines starting with "#" (for comments)
+ if line_s and not line_s.startswith("#"):
+ dl_list[line_num] = line_s
+
+ return dl_list