Skip to content
Snippets Groups Projects
Commit 63aaa6bb authored by gijs's avatar gijs
Browse files

Modified boxes.py so it reads an argument and exports an html clip

parent 2ff37afd
No related branches found
No related tags found
Loading
import re
import urllib
import argparse
filein = open("../classification-systems/TARIC-nomenclature.txt","r")
with open("sketch-blokken/schets-manetta4.html","w+") as fileout:
parser = argparse.ArgumentParser()
parser.add_argument('input', type=str, help="The text-file to parse")
parser.add_argument('output', type=str, help="The dot-file to store produced dot in.")
args = parser.parse_args()
fileout.write('<html><head><link href="schets-manetta4.css" rel="stylesheet"></head><body><div id="main">')
is_url_match = r'^http(?:s)?:\/\/'
filein = urllib.urlopen(args.input) if re.match(is_url_match, args.input) else open(args.input, 'r')
with open(args.output, 'w') as fileout:
fileout.write('<div id="main">')
c = 1
for line in filein:
for line in filein:
line = re.sub('\s{8}', '\t', line)
m = re.search(r"^\t*", line)
if m:
tab = len(m.group(0)) + 1
strtab = str(tab)
line = line.replace("\t","")
print line
# print line
fontsize = str(10);
if line == 'For slaughter\n':
line = line+"<img src='../img/0106.jpg'>"
if line == 'Bulls of the Schwyz, Fribourg and spotted Simmental breeds\n':
line = line+"<img src='../img/https---s3.amazonaws.com-ul-hos-legacy-images-tiff-02LateAncient-Solinus-1543-Solinus-1543det-007-detail.jpg'>"
if tab == c:
if "LIVE ANIMALS\n" != line:
fileout.write('</div>\n')
fileout.write('<div class="h'+strtab+'">'+line)
print 'tab is same'
print 'c:', c, 'tab:', tab
# print 'tab is same'
# print 'c:', c, 'tab:', tab
if tab > c:
fileout.write('<div class="h'+strtab+'">'+line)
print 'tab is bigger'
print 'c:', c, 'tab:', tab
# print 'tab is bigger'
# print 'c:', c, 'tab:', tab
if tab < c:
enddiv = '</div>\n'
fileout.write((c - tab + 1) * enddiv)
print str(c - tab + 1)+ 'x enddiv printed'
# print str(c - tab + 1)+ 'x enddiv printed'
fileout.write('<div class="h'+strtab+'">'+line)
print 'tab is smaller'
print 'c:', c, 'tab:', tab
# print 'tab is smaller'
# print 'c:', c, 'tab:', tab
c = tab
print '**********************'
fileout.write("""
</div>
</body>
</html>
""")
# print '**********************'
fileout.write('</div>')
fileout.close()
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment