aboutsummaryrefslogtreecommitdiff
path: root/src/wikiget/parse.py
diff options
context:
space:
mode:
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