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

Side by Side Diff: client/dom/scripts/database.py

Issue 9421034: Do not use relative paths in dom scripts. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 10 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 | « no previous file | 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 #!/usr/bin/python 1 #!/usr/bin/python
2 # Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 2 # Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
3 # for details. All rights reserved. Use of this source code is governed by a 3 # for details. All rights reserved. Use of this source code is governed by a
4 # BSD-style license that can be found in the LICENSE file. 4 # BSD-style license that can be found in the LICENSE file.
5 5
6 """Module to manage IDL files.""" 6 """Module to manage IDL files."""
7 7
8 import copy 8 import copy
9 import pickle 9 import pickle
10 import logging 10 import logging
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 """Loads all interfaces into memory. 118 """Loads all interfaces into memory.
119 """ 119 """
120 # FIXME: Speed this up by multi-threading. 120 # FIXME: Speed this up by multi-threading.
121 for (interface_name) in self._ScanForInterfaces(): 121 for (interface_name) in self._ScanForInterfaces():
122 self._LoadInterfaceFile(interface_name) 122 self._LoadInterfaceFile(interface_name)
123 self.Cache() 123 self.Cache()
124 124
125 def Cache(self): 125 def Cache(self):
126 """Serialize the database using pickle for faster startup in the future 126 """Serialize the database using pickle for faster startup in the future
127 """ 127 """
128 output_file = open('../database/cache.pickle', 'wb') 128 output_file = open(os.path.join(self._root_dir, 'cache.pickle'), 'wb')
129 pickle.dump(self._all_interfaces, output_file) 129 pickle.dump(self._all_interfaces, output_file)
130 pickle.dump(self._interfaces_to_delete, output_file) 130 pickle.dump(self._interfaces_to_delete, output_file)
131 131
132 def LoadFromCache(self): 132 def LoadFromCache(self):
133 """Deserialize the database using pickle for fast startup 133 """Deserialize the database using pickle for fast startup
134 """ 134 """
135 input_file = open('../database/cache.pickle', 'rb') 135 input_file = open(os.path.join(self._root_dir, 'cache.pickle'), 'rb')
136 self._all_interfaces = pickle.load(input_file) 136 self._all_interfaces = pickle.load(input_file)
137 self._interfaces_to_delete = pickle.load(input_file) 137 self._interfaces_to_delete = pickle.load(input_file)
138 138
139 def Save(self): 139 def Save(self):
140 """Saves all in-memory interfaces into files.""" 140 """Saves all in-memory interfaces into files."""
141 for interface in self._all_interfaces.values(): 141 for interface in self._all_interfaces.values():
142 self._SaveInterfaceFile(interface) 142 self._SaveInterfaceFile(interface)
143 for interface_name in self._interfaces_to_delete: 143 for interface_name in self._interfaces_to_delete:
144 self._DeleteInterfaceFile(interface_name) 144 self._DeleteInterfaceFile(interface_name)
145 145
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 raise RuntimeError('Interface %s not found' % interface_name) 213 raise RuntimeError('Interface %s not found' % interface_name)
214 self._interfaces_to_delete.append(interface_name) 214 self._interfaces_to_delete.append(interface_name)
215 del self._all_interfaces[interface_name] 215 del self._all_interfaces[interface_name]
216 216
217 def _DeleteInterfaceFile(self, interface_name): 217 def _DeleteInterfaceFile(self, interface_name):
218 """Actual file deletion""" 218 """Actual file deletion"""
219 file_path = self._FilePath(interface_name) 219 file_path = self._FilePath(interface_name)
220 if os.path.exists(file_path): 220 if os.path.exists(file_path):
221 _logger.debug('deleting %s' % file_path) 221 _logger.debug('deleting %s' % file_path)
222 os.remove(file_path) 222 os.remove(file_path)
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698