| OLD | NEW | 
|    1 # Copyright 2014 The Chromium Authors. All rights reserved. |    1 # Copyright 2014 The Chromium Authors. All rights reserved. | 
|    2 # Use of this source code is governed by a BSD-style license that can be |    2 # Use of this source code is governed by a BSD-style license that can be | 
|    3 # found in the LICENSE file. |    3 # found in the LICENSE file. | 
|    4  |    4  | 
|    5 """Utility functions (file reading, simple IDL parsing by regexes) for IDL build
     . |    5 """Utility functions (file reading, simple IDL parsing by regexes) for IDL build
     . | 
|    6  |    6  | 
|    7 Design doc: http://www.chromium.org/developers/design-documents/idl-build |    7 Design doc: http://www.chromium.org/developers/design-documents/idl-build | 
|    8 """ |    8 """ | 
|    9  |    9  | 
|   10 import os |   10 import os | 
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  109     with open(destination_filename, 'w') as destination_file: |  109     with open(destination_filename, 'w') as destination_file: | 
|  110         destination_file.write(new_text) |  110         destination_file.write(new_text) | 
|  111  |  111  | 
|  112  |  112  | 
|  113 def write_pickle_file(pickle_filename, data, only_if_changed): |  113 def write_pickle_file(pickle_filename, data, only_if_changed): | 
|  114     if only_if_changed and os.path.isfile(pickle_filename): |  114     if only_if_changed and os.path.isfile(pickle_filename): | 
|  115         with open(pickle_filename) as pickle_file: |  115         with open(pickle_filename) as pickle_file: | 
|  116             try: |  116             try: | 
|  117                 if pickle.load(pickle_file) == data: |  117                 if pickle.load(pickle_file) == data: | 
|  118                     return |  118                     return | 
|  119             except (EOFError, pickle.UnpicklingError): |  119             except Exception: | 
|  120                 # If trouble unpickling, overwrite |  120                 # If trouble unpickling, overwrite | 
|  121                 pass |  121                 pass | 
|  122     with open(pickle_filename, 'w') as pickle_file: |  122     with open(pickle_filename, 'w') as pickle_file: | 
|  123         pickle.dump(data, pickle_file) |  123         pickle.dump(data, pickle_file) | 
|  124  |  124  | 
|  125  |  125  | 
|  126 ################################################################################ |  126 ################################################################################ | 
|  127 # IDL parsing |  127 # IDL parsing | 
|  128 # |  128 # | 
|  129 # We use regular expressions for parsing; this is incorrect (Web IDL is not a |  129 # We use regular expressions for parsing; this is incorrect (Web IDL is not a | 
| (...skipping 29 matching lines...) Expand all  Loading... | 
|  159     # FIXME: this splitting is WRONG: it fails on extended attributes where list
     s of |  159     # FIXME: this splitting is WRONG: it fails on extended attributes where list
     s of | 
|  160     # multiple values are used, which are seperated by a comma and a space. |  160     # multiple values are used, which are seperated by a comma and a space. | 
|  161     parts = [extended_attribute.strip() |  161     parts = [extended_attribute.strip() | 
|  162              for extended_attribute in re.split(',\s+', extended_attributes_stri
     ng) |  162              for extended_attribute in re.split(',\s+', extended_attributes_stri
     ng) | 
|  163              # Discard empty parts, which may exist due to trailing comma |  163              # Discard empty parts, which may exist due to trailing comma | 
|  164              if extended_attribute.strip()] |  164              if extended_attribute.strip()] | 
|  165     for part in parts: |  165     for part in parts: | 
|  166         name, _, value = map(string.strip, part.partition('=')) |  166         name, _, value = map(string.strip, part.partition('=')) | 
|  167         extended_attributes[name] = value |  167         extended_attributes[name] = value | 
|  168     return extended_attributes |  168     return extended_attributes | 
| OLD | NEW |