void (String pyFilePath) { if (pyFilePath.endsWith(PyNames.DOT_PY)) { List<File> filesToDelete = new ArrayList<>(); File pyc = new File(pyFilePath + "c"); if (pyc.exists()) { filesToDelete.add(pyc); } File pyo = new File(pyFilePath + "o"); if (pyo.exists()) { filesToDelete.add(pyo); } final File file = new File(pyFilePath); File pycache = new File(file.getParentFile(), PyNames.PYCACHE); if (pycache.isDirectory()) { final String shortName = FileUtilRt.getNameWithoutExtension(file.getName()); Collections.addAll(filesToDelete, pycache.listFiles(pathname -> { if (!FileUtilRt.extensionEquals(pathname.getName(), "pyc")) return false; String nameWithMagic = FileUtilRt.getNameWithoutExtension(pathname.getName()); return FileUtilRt.getNameWithoutExtension(nameWithMagic).equals(shortName); })); } FileUtil.asyncDelete(filesToDelete); } }