Python 清除CVS和SVN下的目录和子目录,cvssvn,#!/usr/bin/e
文章由Byrx.net分享于2019-03-23 09:03:05
Python 清除CVS和SVN下的目录和子目录,cvssvn,#!/usr/bin/e
#!/usr/bin/env python # to delete all cvs directory of a root directory. import os, string def deltree(top): for root, dirs, files in os.walk(top, topdown=False): for name in files: os.remove(os.path.join(root, name)) for name in dirs: os.rmdir(os.path.join(root, name)) os.rmdir(top) def delallcvs(top): for root, dirs, files in os.walk(top, topdown=True): if 'CVS' in dirs: deltree(os.path.join(root, 'CVS')) if __name__=='__main__': dir = os.listdir('.') if 'CVS' in dir: print '--get it!--', os.curdir delallcvs(os.curdir) else: print 'can''t get it!'#该片段来自于http://byrx.net
评论关闭