A language agnostic book on programming.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

40 lines
1.1 KiB

#!/usr/bin/env python
import os
import re
from subprocess import call
header = open('./header.tex', 'r');
footer = open('./footer.tex', 'r');
book = open('./Programming In General.tex', 'w');
book.write(header.read());
header.close();
dirs = [x[0] for x in os.walk('.')][1:]
dirs.sort()
for d in filter(lambda d: not re.search('.git',d),dirs):
chapter = re.sub('\d+\s-\s', '', d[2:])
print chapter
book.write('\r\n\chapter{' + chapter + '}\r\n')
if os.path.exists(d + '/' + chapter + '.tex'):
book.write('\input{"' + d + '/' + chapter + '"}\r\n')
book.write('\\vfill\r\n\pagebreak')
files = os.listdir(d)
files.sort()
for f in filter(lambda f: re.search('^\d+.\d+\s-\s',f), files):
section = re.sub('\d+.\d+\s-\s|.tex', '', f)
print section
book.write('\r\n\section{' + section + '}\r\n')
book.write('\input{"' + d + '/' + f.replace('.tex', '') + '"}\r\n')
book.write('\\vfill\r\n\pagebreak')
book.write(footer.read());
footer.close();
book.close();
call(['latex', './Programming In General.tex'])
call(['pdflatex', './Programming In General.tex'])