MCPcopy Index your code
hub / github.com/nodejs/node / FileContentsCache

Class FileContentsCache

deps/v8/tools/v8_presubmit.py:193–242  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

191 return rc
192
193class FileContentsCache(object):
194
195 def __init__(self, sums_file_name):
196 self.sums = {}
197 self.sums_file_name = sums_file_name
198
199 def Load(self):
200 try:
201 sums_file = None
202 try:
203 sums_file = open(self.sums_file_name, 'rb')
204 self.sums = pickle.load(sums_file)
205 except:
206 # Cannot parse pickle for any reason. Not much we can do about it.
207 pass
208 finally:
209 if sums_file:
210 sums_file.close()
211
212 def Save(self):
213 try:
214 sums_file = open(self.sums_file_name, 'wb')
215 pickle.dump(self.sums, sums_file)
216 except:
217 # Failed to write pickle. Try to clean-up behind us.
218 if sums_file:
219 sums_file.close()
220 try:
221 os.unlink(self.sums_file_name)
222 except:
223 pass
224 finally:
225 sums_file.close()
226
227 def FilterUnchangedFiles(self, files):
228 changed_or_new = []
229 for file in files:
230 try:
231 handle = open(file, "rb")
232 file_sum = md5er(handle.read()).digest()
233 if not file in self.sums or self.sums[file] != file_sum:
234 changed_or_new.append(file)
235 self.sums[file] = file_sum
236 finally:
237 handle.close()
238 return changed_or_new
239
240 def RemoveFile(self, file):
241 if file in self.sums:
242 self.sums.pop(file)
243
244
245class SourceFileProcessor(object):

Callers 3

setUpMethod · 0.90
testCachesFilesMethod · 0.90
ProcessFilesMethod · 0.85

Calls

no outgoing calls

Tested by 2

setUpMethod · 0.72
testCachesFilesMethod · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…