Movatterモバイル変換


[0]ホーム

URL:


Google Git
Sign in
chromium /chromium /src /refs/heads/main /. /tools /remove_stale_pyc_files.py
blob: 12b59c2b8e525965da18470f1d37a15bfc6d6951 [file] [log] [blame] [edit]
#!/usr/bin/env python
# Copyright 2014 The Chromium Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import os
import sys
defRemoveAllStalePycFiles(base_dir):
"""Scan directories for old .pyc files without a .py file and delete them."""
for dirname, _, filenamesin os.walk(base_dir, topdown=False):
if'.svn'in dirnameor'.git'in dirname:
continue
for filenamein filenames:
root, ext= os.path.splitext(filename)
if ext!='.pyc':
continue
pyc_path= os.path.join(dirname, filename)
py_path= os.path.join(dirname, root+'.py')
try:
ifnot os.path.exists(py_path):
os.remove(pyc_path)
exceptOSError:
# Wrap OS calls in try/except in case another process touched this file.
pass
if __name__=='__main__':
for pathin sys.argv[1:]:
RemoveAllStalePycFiles(path)

[8]ページ先頭

©2009-2025 Movatter.jp