OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2011 Google Inc. All rights reserved. | 2 # Copyright (c) 2011 Google Inc. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 # Takes 3 arguments. Writes the 1st argument to the file in the 2nd argument, | 6 # Takes 3 arguments. Writes the 1st argument to the file in the 2nd argument, |
7 # and writes the absolute path to the file in the 2nd argument to the file in | 7 # and writes the absolute path to the file in the 2nd argument to the file in |
8 # the 3rd argument. | 8 # the 3rd argument. |
9 | 9 |
10 import os | 10 import os |
11 import shlex | 11 import shlex |
12 import sys | 12 import sys |
13 | 13 |
14 if len(sys.argv) == 3 and ' ' in sys.argv[2]: | 14 if len(sys.argv) == 3 and ' ' in sys.argv[2]: |
15 sys.argv[2], fourth = shlex.split(sys.argv[2]) | 15 sys.argv[2], fourth = shlex.split(sys.argv[2].replace('\\', '\\\\')) |
16 sys.argv.append(fourth) | 16 sys.argv.append(fourth) |
17 | 17 |
18 #print >>sys.stderr, sys.argv | 18 #print >>sys.stderr, sys.argv |
19 | 19 |
20 with open(sys.argv[2], 'w') as f: | 20 with open(sys.argv[2], 'w') as f: |
21 f.write(sys.argv[1]) | 21 f.write(sys.argv[1]) |
22 | 22 |
23 with open(sys.argv[3], 'w') as f: | 23 with open(sys.argv[3], 'w') as f: |
24 f.write(os.path.abspath(sys.argv[2])) | 24 f.write(os.path.abspath(sys.argv[2])) |
OLD | NEW |