OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # | 2 # |
3 # Copyright (C) 2011 Google Inc. All rights reserved. | 3 # Copyright (C) 2011 Google Inc. All rights reserved. |
4 # | 4 # |
5 # Redistribution and use in source and binary forms, with or without | 5 # Redistribution and use in source and binary forms, with or without |
6 # modification, are permitted provided that the following conditions are | 6 # modification, are permitted provided that the following conditions are |
7 # met: | 7 # met: |
8 # | 8 # |
9 # * Redistributions of source code must retain the above copyright | 9 # * Redistributions of source code must retain the above copyright |
10 # notice, this list of conditions and the following disclaimer. | 10 # notice, this list of conditions and the following disclaimer. |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 'check source tree for consistency' % | 68 'check source tree for consistency' % |
69 (import_file_name, input_file_name)) | 69 (import_file_name, input_file_name)) |
70 import_file = open(full_path, 'r') | 70 import_file = open(full_path, 'r') |
71 import_script = import_file.read() | 71 import_script = import_file.read() |
72 import_file.close() | 72 import_file.close() |
73 return import_script | 73 return import_script |
74 | 74 |
75 output_script = re.sub(r'importScripts?\([\'"]([^\'"]+)[\'"]\)', replace, in
put_script) | 75 output_script = re.sub(r'importScripts?\([\'"]([^\'"]+)[\'"]\)', replace, in
put_script) |
76 if re.search("importScripts?\(\"", output_script): | 76 if re.search("importScripts?\(\"", output_script): |
77 raise Exception('Unresolved "importScript" statements found in "%s". ' | 77 raise Exception('Unresolved "importScript" statements found in "%s". ' |
78 'Make sure you call "importScript" in module initializer
s only.' % | 78 'Make sure you call "importScript" in module heads only.
' % |
79 (output_file_name)) | 79 (output_file_name)) |
80 | 80 |
81 if os.path.exists(output_file_name): | 81 if os.path.exists(output_file_name): |
82 os.remove(output_file_name) | 82 os.remove(output_file_name) |
83 output_file = open(output_file_name, 'w') | 83 output_file = open(output_file_name, 'w') |
84 if not no_minify: | 84 if not no_minify: |
85 output_script = rjsmin.jsmin(output_script) | 85 output_script = rjsmin.jsmin(output_script) |
86 output_file.write(output_script) | 86 output_file.write(output_script) |
87 output_file.close() | 87 output_file.close() |
88 | 88 |
89 # Touch output file directory to make sure that Xcode will copy | 89 # Touch output file directory to make sure that Xcode will copy |
90 # modified resource files. | 90 # modified resource files. |
91 if sys.platform == 'darwin': | 91 if sys.platform == 'darwin': |
92 output_dir_name = os.path.dirname(output_file_name) | 92 output_dir_name = os.path.dirname(output_file_name) |
93 os.utime(output_dir_name, None) | 93 os.utime(output_dir_name, None) |
94 | 94 |
95 if __name__ == '__main__': | 95 if __name__ == '__main__': |
96 sys.exit(main(sys.argv)) | 96 sys.exit(main(sys.argv)) |
OLD | NEW |