File size: 899 Bytes
b922192 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | # -*- coding: utf-8 -*-
import logging
import os.path
logger = logging.getLogger(os.path.splitext(os.path.basename(__file__))[0])
def find_files(root):
import os
import os.path
for name in os.listdir(root):
path = os.path.join(root, name)
yield path
if os.path.isdir(path):
for x in find_files(path):
yield x
def find_pyc_files(root):
for path in find_files(root):
if path.endswith('.pyc') or path.endswith('$py.class'):
yield path
def main():
import sys
import os.path
logging.basicConfig(level=logging.INFO)
for root in sys.argv[1:]:
if os.path.isdir(root):
for path in find_pyc_files(root):
if not os.path.isdir(path):
logger.info('unlink %s', path)
os.unlink(path)
if __name__ == '__main__':
main()
|