Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(145)

Side by Side Diff: Source/bindings/scripts/utilities.py

Issue 300273005: Bindings build: split compute_interfaces_info into 2 stages (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Remove debugging Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/bindings/scripts/compute_interfaces_info_overall.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 21 matching lines...) Expand all
32 with open(destination_filename) as destination_file: 32 with open(destination_filename) as destination_file:
33 if destination_file.read() == new_text: 33 if destination_file.read() == new_text:
34 return 34 return
35 with open(destination_filename, 'w') as destination_file: 35 with open(destination_filename, 'w') as destination_file:
36 destination_file.write(new_text) 36 destination_file.write(new_text)
37 37
38 38
39 def write_pickle_file(pickle_filename, data, only_if_changed): 39 def write_pickle_file(pickle_filename, data, only_if_changed):
40 if only_if_changed and os.path.isfile(pickle_filename): 40 if only_if_changed and os.path.isfile(pickle_filename):
41 with open(pickle_filename) as pickle_file: 41 with open(pickle_filename) as pickle_file:
42 if pickle.load(pickle_file) == data: 42 try:
43 return 43 if pickle.load(pickle_file) == data:
44 return
45 except (EOFError, pickle.UnpicklingError):
46 # If trouble unpickling, overwrite
47 pass
44 with open(pickle_filename, 'w') as pickle_file: 48 with open(pickle_filename, 'w') as pickle_file:
45 pickle.dump(data, pickle_file) 49 pickle.dump(data, pickle_file)
46 50
47 51
48 ################################################################################ 52 ################################################################################
49 # IDL parsing 53 # IDL parsing
50 # 54 #
51 # We use regular expressions for parsing; this is incorrect (Web IDL is not a 55 # We use regular expressions for parsing; this is incorrect (Web IDL is not a
52 # regular language), but simple and sufficient in practice. 56 # regular language), but simple and sufficient in practice.
53 # Leading and trailing context (e.g. following '{') used to avoid false matches. 57 # Leading and trailing context (e.g. following '{') used to avoid false matches.
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 145
142 def get_put_forward_interfaces_from_idl(file_contents): 146 def get_put_forward_interfaces_from_idl(file_contents):
143 put_forwards_pattern = (r'\[[^\]]*PutForwards=[^\]]*\]\s+' 147 put_forwards_pattern = (r'\[[^\]]*PutForwards=[^\]]*\]\s+'
144 r'readonly\s+' 148 r'readonly\s+'
145 r'attribute\s+' 149 r'attribute\s+'
146 r'(\w+)') 150 r'(\w+)')
147 return sorted(set(match.group(1) 151 return sorted(set(match.group(1)
148 for match in re.finditer(put_forwards_pattern, 152 for match in re.finditer(put_forwards_pattern,
149 file_contents, 153 file_contents,
150 flags=re.DOTALL))) 154 flags=re.DOTALL)))
OLDNEW
« no previous file with comments | « Source/bindings/scripts/compute_interfaces_info_overall.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698