You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
49 lines
1.3 KiB
49 lines
1.3 KiB
9 years ago
|
#!/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
|
||
8 years ago
|
from gallery_dl import job, config, extractor
|
||
9 years ago
|
|
||
|
TESTDATA_FMT = """
|
||
|
test = [("{}", {{
|
||
|
"url": "{}",
|
||
|
"keyword": "{}",
|
||
|
"content": "{}",
|
||
|
}})]
|
||
|
"""
|
||
|
|
||
|
def main():
|
||
|
parser = argparse.ArgumentParser()
|
||
|
parser.add_argument("--content", action="store_true")
|
||
8 years ago
|
parser.add_argument("--recreate", action="store_true")
|
||
9 years ago
|
parser.add_argument("urls", nargs="*")
|
||
|
args = parser.parse_args()
|
||
|
|
||
8 years ago
|
if args.recreate:
|
||
|
urls = [
|
||
|
test[0]
|
||
|
for extr in extractor.extractors() if extr.category in args.urls
|
||
|
for test in extr.test
|
||
|
]
|
||
|
else:
|
||
|
urls = args.urls
|
||
|
|
||
9 years ago
|
config.load()
|
||
8 years ago
|
for url in urls:
|
||
8 years ago
|
hjob = job.HashJob(url, content=args.content)
|
||
|
hjob.run()
|
||
|
print(hjob.extractor.__class__.__name__)
|
||
|
print(TESTDATA_FMT.format(url, hjob.hash_url.hexdigest(),
|
||
|
hjob.hash_keyword.hexdigest(), hjob.hash_content.hexdigest()))
|
||
9 years ago
|
|
||
|
if __name__ == '__main__':
|
||
|
main()
|