cleanupSource.py

changeset 3613
47e29cc0f29c
parent 3597
137370f7114b
child 3670
f0cb7579c0b4
child 3949
1ce546a04f0a
equal deleted inserted replaced
3612:786d97a08a14 3613:47e29cc0f29c
33 if not os.path.exists(os.path.join(dirName, formName)): 33 if not os.path.exists(os.path.join(dirName, formName)):
34 os.remove(os.path.join(dirName, sourceName)) 34 os.remove(os.path.join(dirName, sourceName))
35 if os.path.exists(os.path.join(dirName, sourceName + "c")): 35 if os.path.exists(os.path.join(dirName, sourceName + "c")):
36 os.remove(os.path.join(dirName, sourceName + "c")) 36 os.remove(os.path.join(dirName, sourceName + "c"))
37 37
38 # step 2: delete the __pycache__ directory 38 # step 2: delete the __pycache__ directory and all *.pyc files
39 if os.path.exists(os.path.join(dirName, "__pycache__")): 39 if os.path.exists(os.path.join(dirName, "__pycache__")):
40 shutil.rmtree(os.path.join(dirName, "__pycache__")) 40 shutil.rmtree(os.path.join(dirName, "__pycache__"))
41 for name in [f for f in dirListing if fnmatch.fnmatch(f, "*.pyc")]:
42 os.remove(os.path.join(dirName, name))
41 43
42 # step 3: descent into subdirectories and delete them if empty 44 # step 3: descent into subdirectories and delete them if empty
43 for name in os.listdir(dirName): 45 for name in os.listdir(dirName):
44 name = os.path.join(dirName, name) 46 name = os.path.join(dirName, name)
45 if os.path.isdir(name): 47 if os.path.isdir(name):

eric ide

mercurial