|
|
|
@ -2,7 +2,7 @@ import os, json, sys, urllib
|
|
|
|
|
from mwclient import Site
|
|
|
|
|
from pprint import pprint
|
|
|
|
|
from jinja2 import Template
|
|
|
|
|
from functions import pandoc, page_props, unpack_response, clean_dir
|
|
|
|
|
from functions import pandoc, unpack_response, clean_dir, remove_nonwords
|
|
|
|
|
|
|
|
|
|
from functions import Colors
|
|
|
|
|
import argparse
|
|
|
|
@ -89,13 +89,7 @@ for answer in site.ask(query):
|
|
|
|
|
print(Colors.WARNING, f"{printout_dict['page']} is not is missing from the local downloaded images")
|
|
|
|
|
print(Colors.GREEN, 'run python3 download_imgs.py to fix the issue', Colors.ENDC)
|
|
|
|
|
sys.exit()
|
|
|
|
|
#
|
|
|
|
|
# # TODO: EXTRACT PROPERTIES THROUGH THE FOLLOWING ASK QUERY
|
|
|
|
|
# ask_page_props = f'[[File:{printout_dict["page"]}]]|?Title|?Date|?Part|?Partof|?Creator|?Organization|?Format|?Event|?Topic|?Language'
|
|
|
|
|
# print(ask_page_props)
|
|
|
|
|
# page_props = site.ask(ask_page_props)
|
|
|
|
|
# print(page_props)
|
|
|
|
|
# import pdb; pdb.set_trace()
|
|
|
|
|
|
|
|
|
|
page = site.pages[[printout_dict['page']]] # request that page from wiki
|
|
|
|
|
pagetext = page.text()
|
|
|
|
|
pagetext_html = pandoc(pwd=wd, content=pagetext, format_in='mediawiki', format_out='html')
|
|
|
|
@ -112,15 +106,13 @@ for answer in site.ask(query):
|
|
|
|
|
if printout_dict['Part'] == printout_dict['Partof']:
|
|
|
|
|
# RENDER DOCUMENT
|
|
|
|
|
# by passing all_document_parts html to document_template content
|
|
|
|
|
|
|
|
|
|
# TODO: EXPAND PROPERTIES IN TEMPLATE
|
|
|
|
|
|
|
|
|
|
document_html = document_template.render(
|
|
|
|
|
title=printout_dict.get('Title'),
|
|
|
|
|
date=printout_dict.get('Date'),
|
|
|
|
|
content=all_document_parts) # render document template
|
|
|
|
|
htmlpage_fn = "{}.html".format(
|
|
|
|
|
printout_dict.get('Title')[0].replace(" ", ""))
|
|
|
|
|
remove_nonwords(printout_dict.get('Title')[0])
|
|
|
|
|
)
|
|
|
|
|
with open(os.path.join(static_html, htmlpage_fn), 'w') as htmlfile:
|
|
|
|
|
htmlfile.write(document_html)
|
|
|
|
|
all_document_parts = '' # Reset all_document_parts
|
|
|
|
|