bioweb
0.09.92
C++/Python(django)/JavaScript(angularJS) framework
Main Page
Classes
Files
File List
File Members
client
file_include.py
Go to the documentation of this file.
1
## @file file_include.py
2
# @brief helping python script for substitution files when generationg. Used in scons scripts.
3
4
import
re, fileinput, sys, os
5
6
7
def
file_substitution(in_file, out_file, inc_dir):
8
"""function to include html into server side. Look for <!-- #include "FileName" --> statements and include the files"""
9
10
print
'file_substitution, in_file:'
+ str(in_file) +
', out_file:'
+ str(out_file) +
', inc_dir:'
+ str(inc_dir)
11
try
:
12
f = open(in_file,
"
r")
13
w = open(out_file,
"w"
)
14
15
for
line
in
f:
16
m = re.search(
r'<!--\s*#include\s*"(.*)"\s*-->'
, line)
17
if
m:
18
inc_name = os.path.join(inc_dir, m.group(1) )
19
print
'file_include.py, include file '
+ str(inc_name) +
' into '
+ str(out_file)
20
21
with open(inc_name)
as
inc:
22
text = inc.read()
23
#print 'include text ' + text
24
w.write(text)
#include the file
25
else
:
26
w.write(line)
27
except
:
28
pass
29
30
31
32
Generated on Wed Nov 25 2015 21:50:49 for bioweb by
1.8.9.1