src/eric7/Project/Project.py

branch
server
changeset 10632
1109854f15f9
parent 10631
00f5aae565a3
parent 10621
f5631f40c4d9
child 10633
dda7e43934dc
equal deleted inserted replaced
10631:00f5aae565a3 10632:1109854f15f9
5561 ) 5561 )
5562 ) 5562 )
5563 self.createSBOMAct.triggered.connect(self.__createSBOMFile) 5563 self.createSBOMAct.triggered.connect(self.__createSBOMFile)
5564 self.actions.append(self.createSBOMAct) 5564 self.actions.append(self.createSBOMAct)
5565 5565
5566 self.clearByteCodeCachesAct = EricAction(
5567 self.tr("Clear Byte Code Caches"),
5568 self.tr("Clear Byte Code &Caches"),
5569 0,
5570 0,
5571 self.othersGrp,
5572 "project_clear_bytecode_caches",
5573 )
5574 self.clearByteCodeCachesAct.setStatusTip(
5575 self.tr("Clear the byte code caches of the project.")
5576 )
5577 self.clearByteCodeCachesAct.setWhatsThis(
5578 self.tr(
5579 """<b>Clear Byte Code Caches</b>"""
5580 """<p>This deletes all directories containing byte code cache files."""
5581 """</p>"""
5582 )
5583 )
5584 self.clearByteCodeCachesAct.triggered.connect(self.__clearByteCodeCaches)
5585 self.actions.append(self.clearByteCodeCachesAct)
5586
5566 ################################################################### 5587 ###################################################################
5567 ## Project Tools - code formatting actions - Black 5588 ## Project Tools - code formatting actions - Black
5568 ################################################################### 5589 ###################################################################
5569 5590
5570 self.blackFormattingGrp = createActionGroup(self) 5591 self.blackFormattingGrp = createActionGroup(self)
7906 self.__createEmbeddedEnvironment(upgrade=True) 7927 self.__createEmbeddedEnvironment(upgrade=True)
7907 except (OSError, json.JSONDecodeError): 7928 except (OSError, json.JSONDecodeError):
7908 # the configuration file does not exist or is invalid JSON 7929 # the configuration file does not exist or is invalid JSON
7909 self.__initVenvConfiguration() 7930 self.__initVenvConfiguration()
7910 7931
7932 #########################################################################
7933 ## Below are methods implementing some tool functionality
7934 #########################################################################
7935
7936 @pyqtSlot()
7937 def __clearByteCodeCaches(self, directory=None):
7938 """
7939 Private method to recursively clear the byte code caches of a given directory.
7940
7941 Note: The byte code cache directiries are named '__pycache__'.
7942
7943 @param directory directory name to clear byte code caches from (defaults to
7944 None)
7945 @type str (optional)
7946 """
7947 if directory is None:
7948 # When directory is 'None', we were called by the QAction.
7949 if self.ppath:
7950 directory = self.ppath
7951 else:
7952 return
7953
7954 # step 1: delete the __pycache__ directory
7955 cacheDir = os.path.join(directory, "__pycache__")
7956 if os.path.exists(cacheDir):
7957 shutil.rmtree(cacheDir, ignore_errors=True)
7958
7959 # step 2: descent into subdirectories
7960 with os.scandir(directory) as dirEntriesIterator:
7961 for dirEntry in dirEntriesIterator:
7962 if dirEntry.is_dir():
7963 self.__clearByteCodeCaches(dirEntry.path)
7964
7911 ############################################################################# 7965 #############################################################################
7912 ## Below are methods implementing the support for 'eric-ide server projects 7966 ## Below are methods implementing the support for 'eric-ide server projects
7913 ############################################################################# 7967 #############################################################################
7914 7968
7915 @pyqtSlot(bool) 7969 @pyqtSlot(bool)

eric ide

mercurial