Login

MOVONET

Home Music Blog Group Champion Forum Club

Login | Sign Up| Help

Category:business circle/entertainment circle   Owner python    Members' Amount:11People   Group Status: Public    Create Date:2006-12-31  
  • Cleans up svn, .pyc,CVS and so on documents, the table of contents small script   python time
  • Posted by python
  • 2007-10-22 09:43:35 
     May according to need to revise content
python code
    {7whichDEL_LISTassignstoneedtocleanup} DEL_LIST= [
  1. r'^ .svn$',
  2. '^CVS$',
  3. r'.* .pyc$'
  4. ]
  5. from os.path import join
  6. import os
  7. from os import getcwd, walk, rmdir, chmod
  8. import re
  9. import stat
  10. def write_able(name:
  11. path=join(root, name
  12. chmod (path, stat. S_IWRITE
  13. return path
  14. remove=lambda name:os.remove(write_able(name
  15. def del_dir(dir:
  16. for root, dirs, files in walk(dir, topdown=False:
  17. for name in files:
  18. remove(name
  19. for name in dirs:
  20. rmdir(write_able(name
  21. rmdir(dir
  22. DEL_LIST= [re.compile(i for i in DEL_LIST]
  23. for root, dirs, files in walk(getcwd(, topdown=False:
  24. for i in DEL_LIST:
  25. j= ''
  26. def if_match(func:
  27. if i.match(j:
  28. func(join(root, j
  29. print join(root, j
  30. for j in dirs:
  31. if_match(del_dir
  32. for j in files:
  33. if_match(remove
  34. raw_input ('* ' *61+' nFinished'

MOKI-COUNT :0 | Views703 | Comments0
  Comments

Verification: 0+4=