aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCody Logan <cody@lokken.dev>2023-10-30 11:26:57 -0700
committerCody Logan <cody@lokken.dev>2023-10-30 11:26:57 -0700
commitbceed708e2b6191d1283075183577185ed63fa1f (patch)
tree16573464f561eccac6c082c5a26c29ae2958b4d3
parentaf704aa59ae6a1f306e47eb83773da8d1bac67f4 (diff)
downloadwikiget-bceed708e2b6191d1283075183577185ed63fa1f.tar.gz
wikiget-bceed708e2b6191d1283075183577185ed63fa1f.zip
Accept batch input from stdin
-rw-r--r--src/wikiget/parse.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/wikiget/parse.py b/src/wikiget/parse.py
index 9bad59a..6396b3f 100644
--- a/src/wikiget/parse.py
+++ b/src/wikiget/parse.py
@@ -15,6 +15,7 @@
# You should have received a copy of the GNU General Public License
# along with Wikiget. If not, see <https://www.gnu.org/licenses/>.
+import fileinput
import logging
from argparse import Namespace
from typing import Dict
@@ -65,9 +66,12 @@ def get_dest(dl: str, args: Namespace) -> File:
def read_batch_file(batch_file: str) -> Dict[int, str]:
dl_list = {}
- logger.info(f"Using batch file '{batch_file}'.")
+ if batch_file == "-":
+ logger.info("Using stdin for batch download")
+ else:
+ logger.info(f"Using file '{batch_file}' for batch download")
- with open(batch_file) as fd:
+ with fileinput.input(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()