diff -r e9e7eca7efee -r bf71ee032bb4 scripts/cleanupSource.py --- a/scripts/cleanupSource.py Wed Jul 13 11:16:20 2022 +0200 +++ b/scripts/cleanupSource.py Wed Jul 13 14:55:47 2022 +0200 @@ -18,27 +18,28 @@ """ Cleanup the sources directory to get rid of leftover files and directories. - + @param dirName name of the directory to prune (string) """ # step 1: delete all Ui_*.py files without a corresponding # *.ui file dirListing = os.listdir(dirName) for formName, sourceName in [ - (f.replace('Ui_', "").replace(".py", ".ui"), f) - for f in dirListing if fnmatch.fnmatch(f, "Ui_*.py")]: + (f.replace("Ui_", "").replace(".py", ".ui"), f) + for f in dirListing + if fnmatch.fnmatch(f, "Ui_*.py") + ]: if not os.path.exists(os.path.join(dirName, formName)): os.remove(os.path.join(dirName, sourceName)) if os.path.exists(os.path.join(dirName, sourceName + "c")): os.remove(os.path.join(dirName, sourceName + "c")) - + # step 2: delete the __pycache__ directory and all remaining *.pyc files if os.path.exists(os.path.join(dirName, "__pycache__")): shutil.rmtree(os.path.join(dirName, "__pycache__")) - for name in [f for f in os.listdir(dirName) - if fnmatch.fnmatch(f, "*.pyc")]: + for name in [f for f in os.listdir(dirName) if fnmatch.fnmatch(f, "*.pyc")]: os.remove(os.path.join(dirName, name)) - + # step 3: descent into subdirectories and delete them if empty for name in os.listdir(dirName): name = os.path.join(dirName, name) @@ -57,8 +58,8 @@ print("Cleaning up source ...") sourceDir = os.path.dirname(os.path.dirname(__file__)) or "." cleanupSource(sourceDir) - - + + if __name__ == "__main__": try: main(sys.argv) @@ -68,7 +69,8 @@ print( "\nAn internal error occured. Please report all the output of the" " program, \nincluding the following traceback, to" - " eric-bugs@eric-ide.python-projects.org.\n") + " eric-bugs@eric-ide.python-projects.org.\n" + ) raise #