MCPcopy Index your code
hub / github.com/python/cpython / getFilesToDelete

Method getFilesToDelete

Lib/logging/handlers.py:386–422  ·  view source on GitHub ↗

Determine the files to delete when rolling over. More specific than the earlier method, which just used glob.glob().

(self)

Source from the content-addressed store, hash-verified

384 return False
385
386 def getFilesToDelete(self):
387 """
388 Determine the files to delete when rolling over.
389
390 More specific than the earlier method, which just used glob.glob().
391 """
392 dirName, baseName = os.path.split(self.baseFilename)
393 fileNames = os.listdir(dirName)
394 result = []
395 if self.namer is None:
396 prefix = baseName + '.'
397 plen = len(prefix)
398 for fileName in fileNames:
399 if fileName[:plen] == prefix:
400 suffix = fileName[plen:]
401 if self.extMatch.fullmatch(suffix):
402 result.append(os.path.join(dirName, fileName))
403 else:
404 for fileName in fileNames:
405 # Our files could be just about anything after custom naming,
406 # but they should contain the datetime suffix.
407 # Try to find the datetime suffix in the file name and verify
408 # that the file name can be generated by this handler.
409 m = self.extMatch.search(fileName)
410 while m:
411 dfn = self.namer(self.baseFilename + "." + m[0])
412 if os.path.basename(dfn) == fileName:
413 result.append(os.path.join(dirName, fileName))
414 break
415 m = self.extMatch.search(fileName, m.start() + 1)
416
417 if len(result) < self.backupCount:
418 result = []
419 else:
420 result.sort()
421 result = result[:len(result) - self.backupCount]
422 return result
423
424 def doRollover(self):
425 """

Calls 9

listdirMethod · 0.80
splitMethod · 0.45
appendMethod · 0.45
joinMethod · 0.45
searchMethod · 0.45
namerMethod · 0.45
basenameMethod · 0.45
startMethod · 0.45
sortMethod · 0.45