diff options
| author | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2019-07-14 08:35:35 +0200 |
|---|---|---|
| committer | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2019-07-14 08:35:35 +0200 |
| commit | b4de7f5943eb16fa393df953e97eb2ba8cc35df1 (patch) | |
| tree | 20239aec5f6b0ec44acd691ad98e1a4b38957c8b /site_scons/soe_utils.py | |
| parent | 85dbcc01ae3f6b10849aa71faef6946d8e16d55f (diff) | |
| parent | 697e33ed224b539a42ff68121f7497f5bbf941b2 (diff) | |
Update upstream source from tag 'upstream/3.0.5'
Update to upstream version '3.0.5'
with Debian dir 03c2cf71b97fe65fcfd82c7f4a3862fe2b35614d
Diffstat (limited to 'site_scons/soe_utils.py')
| -rw-r--r-- | site_scons/soe_utils.py | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/site_scons/soe_utils.py b/site_scons/soe_utils.py new file mode 100644 index 0000000..451c7de --- /dev/null +++ b/site_scons/soe_utils.py @@ -0,0 +1,36 @@ +import os.path +import re + +from SCons.Script import Builder, Action, Scanner + +def soelim(target, source, env): + """ + Interpolate files included in [gnt]roff source files using the + .so directive. + + This behaves somewhat like the soelim(1) wrapper around groff, but + makes us independent of whether the actual underlying implementation + includes an soelim() command or the corresponding command-line option + to groff(1). The key behavioral difference is that this doesn't + recursively include .so files from the include file. Not yet, anyway. + """ + t = str(target[0]) + s = str(source[0]) + dir, f = os.path.split(s) + tfp = open(t, 'w') + sfp = open(s, 'r') + for line in sfp.readlines(): + if line[:4] in ['.so ', "'so "]: + sofile = os.path.join(dir, line[4:-1]) + tfp.write(open(sofile, 'r').read()) + else: + tfp.write(line) + sfp.close() + tfp.close() + +def soscan(node, env, path): + c = node.get_text_contents() + return re.compile(r"^[\.']so\s+(\S+)", re.M).findall(c) + +soelimbuilder = Builder(action = Action(soelim), + source_scanner = Scanner(soscan)) |
