|
|
|
@ -14,23 +14,13 @@ from random import shuffle
|
|
|
|
|
# * the --category provides the year. I.e. 2017
|
|
|
|
|
# * year does not need to be indicated in arguments
|
|
|
|
|
#
|
|
|
|
|
# * work page generation uses: work-YYYY-template.html
|
|
|
|
|
# * work pages generation uses: work-YYYY-template.html
|
|
|
|
|
# * graduation year index pages generation uses: index-template-YYYY.html
|
|
|
|
|
#
|
|
|
|
|
#
|
|
|
|
|
################
|
|
|
|
|
|
|
|
|
|
### TO DO ######
|
|
|
|
|
#
|
|
|
|
|
# Issues @current commit
|
|
|
|
|
# * index pages templates
|
|
|
|
|
# *
|
|
|
|
|
#
|
|
|
|
|
# create_page(memberpages, 'preview') : use work_yyyy_templates rather than args.category ['year']
|
|
|
|
|
# * change index templates
|
|
|
|
|
#
|
|
|
|
|
#########
|
|
|
|
|
|
|
|
|
|
#####
|
|
|
|
|
######
|
|
|
|
|
# Args
|
|
|
|
|
####
|
|
|
|
|
p = ArgumentParser()
|
|
|
|
@ -42,22 +32,12 @@ p.add_argument("--preview", help='Preview page. Will override category querying.
|
|
|
|
|
args = p.parse_args()
|
|
|
|
|
print 'args', args
|
|
|
|
|
|
|
|
|
|
# for i in args.category:
|
|
|
|
|
# if '20' in i:
|
|
|
|
|
# global year
|
|
|
|
|
# year = i
|
|
|
|
|
# print year
|
|
|
|
|
|
|
|
|
|
######
|
|
|
|
|
# DEFS: create_pages create_index
|
|
|
|
|
######
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def create_pages(memberpages, mode):
|
|
|
|
|
indexdict = {} #parent dict: contains articledict instances
|
|
|
|
|
for member in memberpages:
|
|
|
|
|
print member
|
|
|
|
|
page = mw_page(site, member)
|
|
|
|
|
page_text = mw_page_text(site, page)
|
|
|
|
|
articledict = parse_work(site, member, page_text) # create dictionary
|
|
|
|
@ -104,10 +84,8 @@ def create_pages(memberpages, mode):
|
|
|
|
|
#print
|
|
|
|
|
figures = page_tree.findall('.//figure')
|
|
|
|
|
images = page_tree.findall('.//img')
|
|
|
|
|
#print 'Number of imgs:', len(images)
|
|
|
|
|
|
|
|
|
|
if len(figures) > 0:
|
|
|
|
|
#print 'figures', figures
|
|
|
|
|
for figure in figures:
|
|
|
|
|
img = figure.find('.//img')
|
|
|
|
|
figcaption = figure.find('.//figcaption')
|
|
|
|
@ -125,9 +103,9 @@ def create_pages(memberpages, mode):
|
|
|
|
|
else:
|
|
|
|
|
for img in images:
|
|
|
|
|
img_src = img.get('src')
|
|
|
|
|
print img_src
|
|
|
|
|
#print img_src
|
|
|
|
|
src = (('File:'+img_src).capitalize()).decode('utf-8')
|
|
|
|
|
pprint.pprint(articledict)
|
|
|
|
|
#pprint.pprint(articledict)
|
|
|
|
|
if src in articledict['Imgs'].keys(): #full-url
|
|
|
|
|
url = (articledict['Imgs'][src])
|
|
|
|
|
#print url
|
|
|
|
@ -150,13 +128,10 @@ def create_index(indexdict, year):
|
|
|
|
|
index_container = index_tree.find(".//div[@class='isotope']") #maybe id is imp
|
|
|
|
|
works = indexdict.keys()
|
|
|
|
|
|
|
|
|
|
print '\n\n******* indexdict keys: works ***********\n\n'
|
|
|
|
|
print(works)
|
|
|
|
|
#print '\n\n******* indexdict keys: works ***********\n\n'
|
|
|
|
|
#print(works)
|
|
|
|
|
|
|
|
|
|
for work in works:
|
|
|
|
|
print '---TITLE:', indexdict[work]['Title']
|
|
|
|
|
print '---PATH:', indexdict[work]['Path']
|
|
|
|
|
|
|
|
|
|
index_addwork( parent=index_container,
|
|
|
|
|
workid=work,
|
|
|
|
|
href=indexdict[work]['Path'],
|
|
|
|
@ -184,33 +159,22 @@ def create_index(indexdict, year):
|
|
|
|
|
# ACTION
|
|
|
|
|
#####
|
|
|
|
|
site = mwsite(args.host, args.path)
|
|
|
|
|
# print "** New Index Mode **"
|
|
|
|
|
|
|
|
|
|
memberpages=mw_cats(site, args)
|
|
|
|
|
# print '\n\nmemberpages:\n\n', memberpages, '\n\n********\n\n' # memberpages include years, from current to 2015
|
|
|
|
|
indexdict = create_pages(memberpages, 'index')
|
|
|
|
|
# indexdict[u'A Unique Line']['Date']
|
|
|
|
|
|
|
|
|
|
# rather than interveening in the create_index or create_pages
|
|
|
|
|
# I will place create_index in a loop
|
|
|
|
|
# with sublist of idexdict for each year
|
|
|
|
|
|
|
|
|
|
indexdict_byyear={year:{} for year in years }
|
|
|
|
|
indexdict_byyear={year:{} for year in years } # index of all page organized according to year
|
|
|
|
|
# indexdict_byyear structure:
|
|
|
|
|
# {year1:{ work1: {work1 prop:vals}, work2: {...} }, year2:..., year3: }
|
|
|
|
|
# {2015: {u'A Unique Line': {'Bio': u'<p>Jun
|
|
|
|
|
# {2015: {u'A Unique Line': {'Bio': ...}}}
|
|
|
|
|
|
|
|
|
|
for key in indexdict.keys(): # populate indexdict_byyear with works
|
|
|
|
|
indexdict_byyear[ int(indexdict[key]['Date'])][key] = indexdict[key]
|
|
|
|
|
|
|
|
|
|
print '\n\n******* indexdict_byyear ***********\n\n'
|
|
|
|
|
pprint.pprint( indexdict_byyear )
|
|
|
|
|
#print '\n\n******* indexdict_byyear ***********\n\n'
|
|
|
|
|
#pprint.pprint( indexdict_byyear )
|
|
|
|
|
|
|
|
|
|
for year in indexdict_byyear.keys(): # create index page for each year ie 2016.html
|
|
|
|
|
print '\n***** ', year, ' *****\n'
|
|
|
|
|
create_index(indexdict_byyear[year], year)
|
|
|
|
|
|
|
|
|
|
# print '\n\n******* indexdict ***********\n\n'
|
|
|
|
|
# pprint.pprint(indexdict)
|
|
|
|
|
|
|
|
|
|
# print '\n\n******* loop indexdict ***********\n\n'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|