Modify: clean use glob to match filename that need remove

This commit is contained in:
dongweiming 2013-11-12 13:10:41 +08:00
parent 44c0079dc9
commit be18f72a69

View file

@ -8,6 +8,7 @@ from __future__ import with_statement
import os import os
import sys import sys
import glob
from datetime import datetime from datetime import datetime
from distutils.cmd import Command from distutils.cmd import Command
from distutils.command.build import build from distutils.command.build import build
@ -117,11 +118,9 @@ class Clean(clean):
for subdir in ('salt', 'tests', 'doc'): for subdir in ('salt', 'tests', 'doc'):
root = os.path.join(os.path.dirname(__file__), subdir) root = os.path.join(os.path.dirname(__file__), subdir)
for dirname, dirnames, filenames in os.walk(root): for dirname, dirnames, filenames in os.walk(root):
for filename in filenames: for to_remove_filename in glob.glob(
for ext in remove_extensions: '{0}/*.py[oc]'.format(dirname)):
if filename.endswith(ext): os.remove(to_remove_filename)
os.remove(os.path.join(dirname, filename))
break
INSTALL_VERSION_TEMPLATE = '''\ INSTALL_VERSION_TEMPLATE = '''\