467 if not os.path.exists(os.path.join(dirName, formName)): |
467 if not os.path.exists(os.path.join(dirName, formName)): |
468 os.remove(os.path.join(dirName, sourceName)) |
468 os.remove(os.path.join(dirName, sourceName)) |
469 if os.path.exists(os.path.join(dirName, sourceName + "c")): |
469 if os.path.exists(os.path.join(dirName, sourceName + "c")): |
470 os.remove(os.path.join(dirName, sourceName + "c")) |
470 os.remove(os.path.join(dirName, sourceName + "c")) |
471 |
471 |
472 # step 2: delete the __pycache__ directory and all *.pyc files |
472 # step 2: delete the __pycache__ directory and all remaining *.pyc files |
473 if os.path.exists(os.path.join(dirName, "__pycache__")): |
473 if os.path.exists(os.path.join(dirName, "__pycache__")): |
474 shutil.rmtree(os.path.join(dirName, "__pycache__")) |
474 shutil.rmtree(os.path.join(dirName, "__pycache__")) |
475 for name in [f for f in dirListing if fnmatch.fnmatch(f, "*.pyc")]: |
475 for name in [f for f in os.listdir(dirName) |
|
476 if fnmatch.fnmatch(f, "*.pyc")]: |
476 os.remove(os.path.join(dirName, name)) |
477 os.remove(os.path.join(dirName, name)) |
477 |
478 |
478 # step 3: descent into subdirectories and delete them if empty |
479 # step 3: descent into subdirectories and delete them if empty |
479 for name in os.listdir(dirName): |
480 for name in os.listdir(dirName): |
480 name = os.path.join(dirName, name) |
481 name = os.path.join(dirName, name) |