cleanupSource.py

branch
6_1_x
changeset 5043
a4044e648b75
parent 4632
ca310db386ed
equal deleted inserted replaced
5026:2ef5c7ec95c2 5043:a4044e648b75
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 and all *.pyc files 38 # step 2: delete the __pycache__ directory and all remaining *.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")]: 41 for name in [f for f in os.listdir(dirName)
42 if fnmatch.fnmatch(f, "*.pyc")]:
42 os.remove(os.path.join(dirName, name)) 43 os.remove(os.path.join(dirName, name))
43 44
44 # step 3: descent into subdirectories and delete them if empty 45 # step 3: descent into subdirectories and delete them if empty
45 for name in os.listdir(dirName): 46 for name in os.listdir(dirName):
46 name = os.path.join(dirName, name) 47 name = os.path.join(dirName, name)

eric ide

mercurial