+# replace a target file with a new contents - checks for changes
+# return True if a change occurred, in which case
+# chown/chmod settings should be taken care of
+def replace_file_with_string (target, new_contents):
+ try:
+ current=file(target).read()
+ except:
+ current=""
+ # xxx if verbose, report diffs...
+ if current==new_contents:
+ return False
+ # overwrite target file
+ f=file(target,'w')
+ f.write(new_contents)
+ f.close()
+ return True
+
+# not needed yet - should that unlink the new file ?
+#def replace_file_with_file (target, new):
+# return replace_file_with_string (target, file(new).read())
+
+####################