25 """This class creates two python commands in order to remove pycache files recursively
28 object (str): Creates two python command for deleting pycache files
33 super(PycacheRemover, self).
__init__()
35 commandOne = (
"python3 -Bc " +
'"' +
"import pathlib;" +
"[p.unlink() for p in pathlib.Path('.').rglob('*.py[co]')]" +
'"')
36 commandTwo = (
"python3 -Bc" +
'"' +
"import pathlib;" +
"[p.rmdir() for p in pathlib.Path('.').rglob('__pycache__')]" +
'"')
43 """This function run two python command and it provides recursively deletes pycache files
46 BaseException: If not path exists
in OS
52 parentPath = os.getcwd()
53 if os.path.exists(parentPath):
54 logging.info(
"Inserting inside for pycache remove: %s", os.getcwd())
55 pycacheRemover.__init__()
56 logging.info(
"pycaches removed succesfully")
58 elif not os.path.exists(parentPath):
63 logging.exception(
"Something wrong with specified\
64 directory. Exception- %s", sys.exc_info(),)