From 2b8977cb2ea57a7c26726f6998f6967ab4096315 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20F=C3=A4hrmann?= Date: Tue, 22 Dec 2015 01:49:25 +0100 Subject: [PATCH] script to easily create testdata --- test/create_test_data.py | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 test/create_test_data.py diff --git a/test/create_test_data.py b/test/create_test_data.py new file mode 100644 index 00000000..2dc35c06 --- /dev/null +++ b/test/create_test_data.py @@ -0,0 +1,37 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- + +# Copyright 2015 Mike Fährmann +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 2 as +# published by the Free Software Foundation. + +"""Create testdata for extractor tests""" + +import argparse +from gallery_dl import jobs, config + +TESTDATA_FMT = """ + test = [("{}", {{ + "url": "{}", + "keyword": "{}", + "content": "{}", + }})] +""" + +def main(): + parser = argparse.ArgumentParser() + parser.add_argument("--content", action="store_true") + parser.add_argument("urls", nargs="*") + args = parser.parse_args() + + config.load() + for url in args.urls: + job = jobs.HashJob(url, content=args.content) + job.run() + print(TESTDATA_FMT.format(url, job.hash_url.hexdigest(), + job.hash_keyword.hexdigest(), job.hash_content.hexdigest())) + +if __name__ == '__main__': + main()