|
|
|
@ -3,8 +3,18 @@ from mwclient import Site
|
|
|
|
|
from pprint import pprint
|
|
|
|
|
from jinja2 import Template
|
|
|
|
|
from functions import pandoc, page_props, unpack_response
|
|
|
|
|
from argparse import ArgumentParser
|
|
|
|
|
|
|
|
|
|
site = Site(host='hub.xpub.nl/sandbox', path='/itchwiki/')
|
|
|
|
|
p = ArgumentParser(description="From smw ask string generate HTML pages with resulting results.")
|
|
|
|
|
p.add_argument("--host", metavar='', default="hub.xpub.nl/sandbox")
|
|
|
|
|
p.add_argument("--path", metavar='', default="/itchwiki/", help="Wiki path. Should end with /")
|
|
|
|
|
p.add_argument("--ask", "-a", metavar='',
|
|
|
|
|
default='[[File:+]][[Title::+]][[Date::+]]|?Title|?Date|?Part|?Partof|sort=Title,Part|order=asc,asc',
|
|
|
|
|
help="Ask query to be sent to the wiki API.")
|
|
|
|
|
|
|
|
|
|
args = p.parse_args()
|
|
|
|
|
|
|
|
|
|
site = Site(host=args.host, path=args.path)
|
|
|
|
|
wd = os.path.dirname(os.path.abspath(__file__)) # working directory
|
|
|
|
|
imgdir = os.path.join(wd, 'images')
|
|
|
|
|
imgsjson_fn = os.path.join(wd, 'images.json')
|
|
|
|
@ -20,9 +30,6 @@ with open(os.path.join(wd, 'login.txt'), 'r') as login: # read login user & pwd
|
|
|
|
|
site.login(username=user, password=pwd) # login to wiki
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
query = ('[[File:+]][[Title::+]][[Date::+]]|?Title|?Date|?Part|?Partof|sort=Title,Part|order=asc,asc')
|
|
|
|
|
print('Query:', query)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
with open(os.path.join(wd, 'templates/publication.html')) as pub_html:
|
|
|
|
|
pub_template = Template(pub_html.read())
|
|
|
|
@ -35,7 +42,7 @@ pub_parts_html = '' # to append all content
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for answer in site.ask(query):
|
|
|
|
|
for answer in site.ask(args.ask):
|
|
|
|
|
publication_title = ''
|
|
|
|
|
# print(answer, answer.keys())
|
|
|
|
|
printout_dict = unpack_response(answer)
|
|
|
|
|