Commit 1f9d2ae9 authored by gijs's avatar gijs
Browse files

Seperate files for languages

parent 80b182ec
......@@ -43,7 +43,8 @@ def makeLemma(title, url, bigSoup):
lemmaSoup = bs(urllib.urlopen(
'{0}?action=render'.format(url)), 'html.parser')
lemma = bigSoup.new_tag("section")
lemma['class'] = 'lemma'
lemma['class'] = 'lemma {}'.format(
re.sub(r'[^\w\-]+', '', re.sub(r'\s+', '-', title.lower())).encode("ascii", "ignore"))
sectiontitle = tagContent(child)
......@@ -51,7 +52,7 @@ def makeLemma(title, url, bigSoup):
asciii['class'] = 'ascii'
asciii.append(u'''%
%
% {}'''.format(title))
% {}'''.format(title))
header = bigSoup.new_tag('section')
header['class'] = 'asciiheaderwrapper lemmaheader'
......@@ -69,16 +70,15 @@ def makeLemma(title, url, bigSoup):
return lemma
soup = bs(template, 'html.parser')
pages = (('en', 'http://www.algolit.net/index.php/Algoliterary_Encounters?action=render'),
('fr', 'http://algolit.net/index.php/Rencontres_Algolittéraires?action=render'))
for (lang, url) in pages:
print lang, url
soup = bs(template, 'html.parser')
pageSoup = bs(urllib.urlopen(url), 'html.parser')
container = soup.new_tag('section')
container['class'] = 'language {}'.format(lang)
container['class'] = u'language {}'.format(lang)
for child in pageSoup.contents:
# print child.name
......@@ -135,12 +135,9 @@ for (lang, url) in pages:
asciii1 = soup.new_tag('pre')
asciii1['class'] = 'ascii box'
asciii1.append(u'''%%% %%% %%%''')
asciii1.append(u'''%%% %%%''')
asciiiname = soup.new_tag('div')
asciiiname['class'] = 'asciiname box'
asciii2 = soup.new_tag('pre')
asciii2['class'] = 'ascii box'
asciii2.append(u'''%%% %%%''')
asciiiname.append(sectiontitle)
headerwrapper = soup.new_tag('section')
......@@ -148,7 +145,6 @@ for (lang, url) in pages:
headerwrapper.append(asciii1)
headerwrapper.append(asciiiname)
headerwrapper.append(asciii2)
container.append(headerwrapper)
else:
......@@ -156,6 +152,6 @@ for (lang, url) in pages:
soup.append(container)
with codecs.open('catalog.html', 'w', encoding='utf-8') as out:
out.write(soup.prettify())
out.close()
with codecs.open('catalog.{}.html'.format(lang), 'w', encoding='utf-8') as out:
out.write(unicode(soup))
out.close()
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment