#!/usr/bin/python import sys t='' def init(): global t #t=open(sys.argv[1]).read() t=open('systemantics.txt').read() t=t.replace('\n\n', '\n\n

') # t=t.replace('[center]', '

') t=t.replace('[/center]', '
') # t=t.replace('[i]', '') t=t.replace('[/i]', '') # t=t.replace('[br]', '
') lst=[] foot=[] # [anchor, footnote itself] chap=[] # [CHfoo, chapter title] def chlst(): global lst, t, chap for i in range(len(t)): if t[i] == '[': if t[i:i+3] == '[CH': begin = i end = t.find(']',i) arg = t[i+1:end] if arg[:2]=='CH': chtitle=t[ end+2 : t.find('\n', end+3)] #for the chapter with a footnote in its title if chtitle.find('[') >= 0: chtitle=chtitle[:chtitle.find('[')] + chtitle[chtitle.find(']')+1:] chap.append([arg, chtitle]) def ubermklst(): global lst, t, chap, foot max=len(t) i=-1 while i[*]', anchor) if arg[:2]=='CH': chend=t.find('\n\n', i) chapname=t[end+1:chend] print "
" printf('', arg) printf('%s', chapname) end=chend if arg[:3]=='img': pic=arg[arg.find(' ')+1:] printf('', pic) i=end elif t[i]=='\n' and i[Footnote. %s]\n\n', f[0], f[1]) print "

" foot=[] else: printf('%s', t[i]) # MKLST # makes lst of all args, their start and end positions def mklst(): global lst, t max=len(t) for i in range(len(t)): if t[i]=='\n' and i') else: print('
') printf('[Footnote. %s]\n\n', f[0], f[1]) print('
') print "

" foot=[] if a[2][0] == '*': # * footnote #p=t.find(parag, a[0]) # find the next parag #foot=foot.append([p, arg[2][2:]]) anchor= '%s%d' % (a[2][2 : a[2].find(' ',2)], a[0]) foot.append([anchor, a[2][2:] ]) printf('[*]', anchor) #printf('*', anchor) if a[2][:3] == 'img': pic=a[2][a[2].find(' ')+1:] printf('',path, pic, ext) if a[2][:2] == 'CH': printf('


\n\n') chtitle=t[ a[1]+2 : t.find('\n', a[1]+3)] #chap.append([a[2], chtitle]) foot.append(['chapterbold', 'chapterbold']) printf('', a[2]) # WORKARGS # iterate over args and change them def loop(): global lst, t printf('%s', t[:lst[0][0]]) #print up to first arg workarg(lst[0]) for n in range(len(lst))[1:]: #for n in range(10)[1:]: printf('%s', t[ lst[n-1][1]+1 : lst[n][0] ]) workarg(lst[n]) print t[lst[-1][1]+1:], def noargs(): global lst, t printf('%s', t[:lst[0][0]]) #print up to first arg for n in range(len(lst))[1:]: printf('%s', t[ lst[n-1][1]+1 : lst[n][0] ]) print t[lst[-1][1]+1:], def dofoots(): global foot print "

Footnotes

" for f in foot: printf('%s

\n\n', f[0], f[1]) def dochaps(): global chap print '


\n

Table of Contents

' for c in chap: printf('%s

\n\n', c[0], c[1]) print '
' def printf(format, *args): sys.stdout.write (format % args) ####################################### print "Systemantics" print "

Systemantics

How Systems Work and Especially How They Fail

John Gall
Illustrated by R. O. Blechman. (c) 1975 John Gall
" init() chlst() dochaps() #ubermklst() mklst() loop() #dofoots() #print '\n\n\n\n\n\n' print ""