third_party:waf: update to upstream 2.0.4 release
[amitay/samba.git] / buildtools / wafsamba / configure_file.py
index 8e2ba3bc23f1495efbfa1b18ddc9170729db9898..6ad43546249fba7b4c0a037035e8574e7a9d2753 100644 (file)
@@ -1,18 +1,17 @@
 # handle substitution of variables in .in files
 
-import Build, sys, Logs
-from samba_utils import *
+import sys
+import re
+import os
+from waflib import Build, Logs
+from samba_utils import SUBST_VARS_RECURSIVE
 
 def subst_at_vars(task):
     '''substiture @VAR@ style variables in a file'''
 
     env = task.env
-    src = task.inputs[0].srcpath(env)
-    tgt = task.outputs[0].bldpath(env)
+    s = task.inputs[0].read()
 
-    f = open(src, 'r')
-    s = f.read()
-    f.close()
     # split on the vars
     a = re.split('(@\w+@)', s)
     out = []
@@ -27,9 +26,7 @@ def subst_at_vars(task):
             v = SUBST_VARS_RECURSIVE(task.env[vname], task.env)
         out.append(v)
     contents = ''.join(out)
-    f = open(tgt, 'w')
-    s = f.write(contents)
-    f.close()
+    task.outputs[0].write(contents)
     return 0
 
 def CONFIGURE_FILE(bld, in_file, **kwargs):