eric6/VirtualEnv/VirtualenvManager.py

changeset 7910
2eeec6bc49e6
parent 7781
607a6098cb44
child 7923
91e843545d9a
equal deleted inserted replaced
7909:ad9f1dc09b4a 7910:2eeec6bc49e6
56 56
57 def __loadSettings(self): 57 def __loadSettings(self):
58 """ 58 """
59 Private slot to load the virtual environments. 59 Private slot to load the virtual environments.
60 """ 60 """
61 self.__virtualEnvironmentsBaseDir = Preferences.Prefs.settings.value(
62 "PyVenv/VirtualEnvironmentsBaseDir", "")
63
61 venvString = Preferences.Prefs.settings.value( 64 venvString = Preferences.Prefs.settings.value(
62 "PyVenv/VirtualEnvironments", "{}") # __IGNORE_WARNING_M613__ 65 "PyVenv/VirtualEnvironments", "{}") # __IGNORE_WARNING_M613__
63 environments = json.loads(venvString) 66 environments = json.loads(venvString)
64 67
65 self.__virtualEnvironments = {} 68 self.__virtualEnvironments = {}
125 def __saveSettings(self): 128 def __saveSettings(self):
126 """ 129 """
127 Private slot to save the virtual environments. 130 Private slot to save the virtual environments.
128 """ 131 """
129 Preferences.Prefs.settings.setValue( 132 Preferences.Prefs.settings.setValue(
133 "PyVenv/VirtualEnvironmentsBaseDir",
134 self.__virtualEnvironmentsBaseDir)
135
136 Preferences.Prefs.settings.setValue(
130 "PyVenv/VirtualEnvironments", 137 "PyVenv/VirtualEnvironments",
131 json.dumps(self.__virtualEnvironments) 138 json.dumps(self.__virtualEnvironments)
132 ) 139 )
133 Preferences.syncPreferences() 140 Preferences.syncPreferences()
134 141
162 ) 169 )
163 170
164 return ("", {}) 171 return ("", {})
165 172
166 @pyqtSlot() 173 @pyqtSlot()
167 def createVirtualEnv(self): 174 def createVirtualEnv(self, baseDir=""):
168 """ 175 """
169 Public slot to create a new virtual environment. 176 Public slot to create a new virtual environment.
177
178 @param baseDir base directory for the virtual environments
179 @type str
170 """ 180 """
171 from .VirtualenvConfigurationDialog import ( 181 from .VirtualenvConfigurationDialog import (
172 VirtualenvConfigurationDialog 182 VirtualenvConfigurationDialog
173 ) 183 )
174 184
175 dlg = VirtualenvConfigurationDialog() 185 if not baseDir:
186 baseDir = self.__virtualEnvironmentsBaseDir
187
188 dlg = VirtualenvConfigurationDialog(baseDir=baseDir)
176 if dlg.exec() == QDialog.Accepted: 189 if dlg.exec() == QDialog.Accepted:
177 resultDict = dlg.getData() 190 resultDict = dlg.getData()
178 191
179 if resultDict["envType"] == "conda": 192 if resultDict["envType"] == "conda":
180 # create the conda environment 193 # create the conda environment
600 """ 613 """
601 if venvName in self.__virtualEnvironments: 614 if venvName in self.__virtualEnvironments:
602 return self.__virtualEnvironments[venvName]["exec_path"] 615 return self.__virtualEnvironments[venvName]["exec_path"]
603 else: 616 else:
604 return "" 617 return ""
618
619 def setVirtualEnvironmentsBaseDir(self, baseDir):
620 """
621 Public method to set the base directory for the virtual environments.
622
623 @param baseDir base directory for the virtual environments
624 @type str
625 """
626 self.__virtualEnvironmentsBaseDir = baseDir
627 self.__saveSettings()
628
629 def getVirtualEnvironmentsBaseDir(self):
630 """
631 Public method to set the base directory for the virtual environments.
632
633 @return base directory for the virtual environments
634 @rtype str
635 """
636 return self.__virtualEnvironmentsBaseDir

eric ide

mercurial