From 385285932a80947f437cf5d473ed7d9f0666703a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20F=C3=A4hrmann?= Date: Fri, 14 Apr 2017 14:45:35 +0200 Subject: [PATCH] add script to collect test results in JSON format --- .gitignore | 2 ++ scripts/build_testresult_db.py | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100755 scripts/build_testresult_db.py diff --git a/.gitignore b/.gitignore index ba746605..28e4a34b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ +archive/ + # Byte-compiled / optimized / DLL files __pycache__/ *.py[cod] diff --git a/scripts/build_testresult_db.py b/scripts/build_testresult_db.py new file mode 100755 index 00000000..0570f2e7 --- /dev/null +++ b/scripts/build_testresult_db.py @@ -0,0 +1,33 @@ +#!/usr/bin/env python + +import sys +import os.path +import datetime + +ROOTDIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) +sys.path.insert(0, os.path.realpath(ROOTDIR)) +from gallery_dl import extractor, job, config + +tests = [ + ([url[0] for url in extr.test], extr) + for extr in extractor.extractors() + if hasattr(extr, "test") +] + +if len(sys.argv) > 1: + tests = [ + (urls, extr) + for urls, extr in tests + if extr.category in sys.argv + ] + +path = os.path.join(ROOTDIR, "archive/testdb", str(datetime.date.today())) +os.makedirs(path, exist_ok=True) +config.load() + +for urls, extr in tests: + for i, url in enumerate(urls): + name = "%s-%s-%d.json" % (extr.category, extr.subcategory, i) + print(name) + with open(os.path.join(path, name), "w") as outfile: + job.DataJob(url, outfile).run()