Author: tziade
Date: Thu Mar 30 18:28:56 2006
New Revision: 2746
Added:
cookbook/trunk/buildbook.py (contents, props changed)
Log:
added book builder (tgv commit)
Added: cookbook/trunk/buildbook.py
==============================================================================
--- (empty file)
+++ cookbook/trunk/buildbook.py Thu Mar 30 18:28:56 2006
@@ -0,0 +1,36 @@
+import re
+import os
+
+template = """
+\documentclass{book}
+\pagestyle{headings}
+\include{macros}
+\begin{document}
+%s
+\end{document}
+"""
+
+def extractChapter(text):
+ rawstr = r"""\\chapter.*\\end{solution}"""
+ compile_obj = re.compile(rawstr, re.MULTILINE| re.DOTALL)
+ match_obj = compile_obj.search(text)
+ return match_obj.group()
+
+def getFiles(directory, lang):
+ return [file for file in os.listdir(directory)
+ if file.endswith('.%s.tex' % lang)]
+
+if __name__ == '__main__':
+ current_folder = os.path.dirname(__file__)
+ if current_folder == '':
+ current_folder = '.'
+
+ for lang in ('fr', 'en'):
+ chapters = [extractChapter(open(file).read())
+ for file in getFiles(current_folder, lang)]
+ book = template % '\n'.join(chapters)
+ bookfile = open('book.%s.tex' % lang, 'w')
+ try:
+ bookfile.write(book)
+ finally:
+ bookfile.close()
--
http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins