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): |