| Index: Source/bindings/scripts/utilities.py
|
| diff --git a/Source/bindings/scripts/utilities.py b/Source/bindings/scripts/utilities.py
|
| index 28beb17c94e8a842c10f7f4ddafa980f47ef0224..727ee06a7b6c4aed9d6754cfad6c647604adbc38 100644
|
| --- a/Source/bindings/scripts/utilities.py
|
| +++ b/Source/bindings/scripts/utilities.py
|
| @@ -11,6 +11,7 @@ import os
|
| import cPickle as pickle
|
| import re
|
| import string
|
| +import subprocess
|
|
|
|
|
| class IdlBadFilenameError(Exception):
|
| @@ -38,6 +39,34 @@ def read_file_to_list(filename):
|
| return [line.rstrip('\n') for line in f]
|
|
|
|
|
| +def resolve_cygpath(cygdrive_names):
|
| + if not cygdrive_names:
|
| + return []
|
| + cmd = ['cygpath', '-f', '-', '-wa']
|
| + process = subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
| + idl_file_names = []
|
| + for file_name in cygdrive_names:
|
| + process.stdin.write('%s\n' % file_name)
|
| + process.stdin.flush()
|
| + idl_file_names.append(process.stdout.readline().rstrip())
|
| + process.stdin.close()
|
| + process.wait()
|
| + return idl_file_names
|
| +
|
| +
|
| +def read_idl_files_list_from_file(filename):
|
| + """Similar to read_file_to_list, but also resolves cygpath."""
|
| + with open(filename) as input_file:
|
| + file_names = sorted([os.path.realpath(line.rstrip('\n'))
|
| + for line in input_file])
|
| + idl_file_names = [file_name for file_name in file_names
|
| + if not file_name.startswith('/cygdrive')]
|
| + cygdrive_names = [file_name for file_name in file_names
|
| + if file_name.startswith('/cygdrive')]
|
| + idl_file_names.extend(resolve_cygpath(cygdrive_names))
|
| + return idl_file_names
|
| +
|
| +
|
| def read_pickle_files(pickle_filenames):
|
| for pickle_filename in pickle_filenames:
|
| with open(pickle_filename) as pickle_file:
|
| @@ -49,6 +78,9 @@ def write_file(new_text, destination_filename, only_if_changed):
|
| with open(destination_filename) as destination_file:
|
| if destination_file.read() == new_text:
|
| return
|
| + destination_dirname = os.path.dirname(destination_filename)
|
| + if not os.path.exists(destination_dirname):
|
| + os.makedirs(destination_dirname)
|
| with open(destination_filename, 'w') as destination_file:
|
| destination_file.write(new_text)
|
|
|
|
|