diff options
author | michele.simionato <devnull@localhost> | 2008-11-28 04:48:10 +0000 |
---|---|---|
committer | michele.simionato <devnull@localhost> | 2008-11-28 04:48:10 +0000 |
commit | 9f753120e3db451ce16a0500bfc36479776071de (patch) | |
tree | 1e92194600b6d22ae304c1f5769655e5b6cc5402 /scheme2rst.py | |
parent | cce215fe0e2612d35792ccac90213a8f3d4ae6a5 (diff) | |
download | micheles-9f753120e3db451ce16a0500bfc36479776071de.tar.gz |
Various improvements to Scheme stuff
Diffstat (limited to 'scheme2rst.py')
-rw-r--r-- | scheme2rst.py | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/scheme2rst.py b/scheme2rst.py index 4aa0a37..ad45337 100644 --- a/scheme2rst.py +++ b/scheme2rst.py @@ -12,6 +12,15 @@ SNIPPET = re.compile(r'\n;\s*([-A-Z\d_/!\?]+)\s*\n(.*?)\n\s*;END', re.DOTALL) SNIPPETNAME = re.compile(r'\n\$\$([-A-Z\d_/!\?]+)\n') INCLUDE = re.compile(r'@@([-\w\d_\.]+)') +PATH = os.environ['IKARUS_LIBRARY_PATH'] + +def include(fname): + try: + txt = file(fname).read() + except IOError: + txt = file(os.path.join(PATH, fname)).read() + return txt + def indent(text): return '\n'.join(' ' + ln for ln in text.splitlines()) @@ -30,7 +39,7 @@ def scheme2rst(fname, codeblock=False): name = mo.group(1) return templ % indent(snippet[name]) def include_file(mo): - return templ % indent(file(mo.group(1)).read()) + return templ % indent(include(mo.group(1))) rst = INCLUDE.sub(include_file, SNIPPETNAME.sub(repl, text)) rstfile = os.path.splitext(fname)[0] + '.rst' file(rstfile, 'w').write(rst) |