352 # *.ui file |
352 # *.ui file |
353 dirListing = os.listdir(dirName) |
353 dirListing = os.listdir(dirName) |
354 for formName, sourceName in [(f.replace('Ui_',"").replace(".py",".ui"), f) |
354 for formName, sourceName in [(f.replace('Ui_',"").replace(".py",".ui"), f) |
355 for f in dirListing |
355 for f in dirListing |
356 if fnmatch.fnmatch(f, "Ui_*.py")]: |
356 if fnmatch.fnmatch(f, "Ui_*.py")]: |
357 if not os.path.exist(os.path.join(dirName, formName)): |
357 if not os.path.exists(os.path.join(dirName, formName)): |
358 os.remove(os.path.join(dirName, sourceName)) |
358 os.remove(os.path.join(dirName, sourceName)) |
359 if os.path.exist(os.path.join(dirName, sourceName + "c")): |
359 if os.path.exists(os.path.join(dirName, sourceName + "c")): |
360 os.remove(os.path.join(dirName, sourceName + "c")) |
360 os.remove(os.path.join(dirName, sourceName + "c")) |
361 |
361 |
362 # step 2: delete the __pycache__ directory |
362 # step 2: delete the __pycache__ directory |
363 if os.path.exist(os.path.join(dirName, "__pycache__")): |
363 if os.path.exists(os.path.join(dirName, "__pycache__")): |
364 shutil.rmtree(os.path.join(dirName, "__pycache__")) |
364 shutil.rmtree(os.path.join(dirName, "__pycache__")) |
365 |
365 |
366 # step 3: descent into subdirectories and delete them if empty |
366 # step 3: descent into subdirectories and delete them if empty |
367 for name in os.listdir(dirName): |
367 for name in os.listdir(dirName): |
368 name = os.path.join(dirName, name) |
368 name = os.path.join(dirName, name) |