aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorElena ``of Valhalla'' Grandi <elena.valhalla@gmail.com>2011-04-18 22:12:15 +0200
committerElena ``of Valhalla'' Grandi <elena.valhalla@gmail.com>2011-04-18 22:12:15 +0200
commitc554c90fac9eff37df768b9c091f6fc4e2eb94cf (patch)
tree1312e0c8b4720bc09c1ec149ac0df6523097f3bc
parent97dd8dd9a5d9149671693e7f9c7164c675b17dbb (diff)
make_guides.py: generazione di LaTeX standard (ancora da configurare)
-rwxr-xr-xmake_guides.py28
1 files changed, 24 insertions, 4 deletions
diff --git a/make_guides.py b/make_guides.py
index 42ce90b..d55d8e5 100755
--- a/make_guides.py
+++ b/make_guides.py
@@ -1,7 +1,7 @@
#!/usr/bin/env python3
import argparse, os
-#import docutils
+import docutils.core
def basename(fname):
'''Returns the name of the guide from either its name or its directory'''
@@ -42,11 +42,31 @@ def build_latex(guide):
if not rebuild:
return None
# Build the LaTeX source
- # DEBUG
- print('Building LaTeX...')
+ s_files = []
+ for dirpath, dirnames, filenames in os.walk(src_dir):
+ s_files += [os.path.join(dirpath,fn)
+ for fn in filenames
+ if fn.endswith(('.txt','.rst'))]
+ s_files.sort()
+ source = ""
+ for fname in s_files:
+ fp = open(fname,'rt')
+ try:
+ source += fp.read()
+ except IOError:
+ pass
+ finally:
+ fp.close()
if not os.path.isdir(build_dir):
os.mkdir(build_dir)
- fp = open(os.path.join(build_dir,tex_name),'w')
+ fp = open(os.path.join(build_dir,tex_name),'wt')
+ fp.write(docutils.core.publish_string(source,
+ writer_name='latex',
+ settings_overrides={'language': 'it',
+ 'documentoptions': 'a6paper,twoside',
+ 'stylesheet': 'lmodern',
+ 'hyperlink-color': '0',
+ 'output_encoding': 'unicode'}))
fp.close()
def build_pdf(guide):