Index: dart/site/try/add_time_stamp.py |
diff --git a/dart/site/try/add_time_stamp.py b/dart/site/try/add_time_stamp.py |
new file mode 100644 |
index 0000000000000000000000000000000000000000..b97b643187b3da78b4ecb8500b84bbcd29c9dc68 |
--- /dev/null |
+++ b/dart/site/try/add_time_stamp.py |
@@ -0,0 +1,29 @@ |
+#!/usr/bin/env python |
+# Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
+# for details. All rights reserved. Use of this source code is governed by a |
+# BSD-style license that can be found in the LICENSE file. |
+ |
+import sys |
+import re |
kustermann
2014/01/16 14:31:37
"re" is not used, is it?
ahe
2014/01/16 16:03:48
Done.
|
+import time |
+ |
+def Main(): |
+ (_, input_file_name, output_file_name) = sys.argv |
+ if not input_file_name or not output_file_name: |
+ raise Exception('Missing argument') |
+ |
+ input_file = open(input_file_name, 'r') |
+ output_file = open(output_file_name, 'w') |
+ timestamp = str(time.time()) |
kustermann
2014/01/16 14:31:37
If I understand it correctly, the only thing you w
ahe
2014/01/16 16:03:48
That's actually what I wanted, but I didn't want t
|
+ |
+ for line in input_file: |
+ if '@@TIMESTAMP@@' in line: |
+ line = line.replace('@@TIMESTAMP@@', timestamp) |
+ print >> output_file, line, |
+ |
+ input_file.close() |
+ output_file.close() |
kustermann
2014/01/16 14:31:37
You could make this a bit more readable:
with ope
ahe
2014/01/16 16:03:48
Thank you, I had forgotten about "with". "input" i
|
+ |
+ |
+if __name__ == '__main__': |
+ sys.exit(Main()) |