eric6/PluginManager/PluginManager.py

changeset 7785
9978016560ec
parent 7400
e5d62581d002
child 7836
2f0d208b8137
equal deleted inserted replaced
7784:3257703e10c5 7785:9978016560ec
204 if self.__develPluginFile: 204 if self.__develPluginFile:
205 path = Utilities.splitPath(self.__develPluginFile)[0] 205 path = Utilities.splitPath(self.__develPluginFile)[0]
206 fname = os.path.join(path, "__init__.py") 206 fname = os.path.join(path, "__init__.py")
207 if not os.path.exists(fname): 207 if not os.path.exists(fname):
208 try: 208 try:
209 f = open(fname, "w") 209 with open(fname, "w"):
210 f.close() 210 pass
211 except IOError: 211 except IOError:
212 return ( 212 return (
213 False, 213 False,
214 self.tr("Could not create a package for {0}.") 214 self.tr("Could not create a package for {0}.")
215 .format(self.__develPluginFile)) 215 .format(self.__develPluginFile))
217 fname = os.path.join(self.pluginDirs["user"], "__init__.py") 217 fname = os.path.join(self.pluginDirs["user"], "__init__.py")
218 if not os.path.exists(fname): 218 if not os.path.exists(fname):
219 if not os.path.exists(self.pluginDirs["user"]): 219 if not os.path.exists(self.pluginDirs["user"]):
220 os.mkdir(self.pluginDirs["user"], 0o755) 220 os.mkdir(self.pluginDirs["user"], 0o755)
221 try: 221 try:
222 f = open(fname, "w") 222 with open(fname, "w"):
223 f.close() 223 pass
224 except IOError: 224 except IOError:
225 del self.pluginDirs["user"] 225 del self.pluginDirs["user"]
226 226
227 if ( 227 if (
228 not os.path.exists(self.pluginDirs["global"]) and 228 not os.path.exists(self.pluginDirs["global"]) and
229 os.access(Utilities.getPythonModulesDirectory(), os.W_OK) 229 os.access(Utilities.getPythonModulesDirectory(), os.W_OK)
230 ): 230 ):
231 # create the global plugins directory 231 # create the global plugins directory
232 os.mkdir(self.pluginDirs["global"], 0o755) 232 os.mkdir(self.pluginDirs["global"], 0o755)
233 fname = os.path.join(self.pluginDirs["global"], "__init__.py") 233 fname = os.path.join(self.pluginDirs["global"], "__init__.py")
234 f = open(fname, "w", encoding="utf-8") 234 with open(fname, "w", encoding="utf-8") as f:
235 f.write('# -*- coding: utf-8 -*-' + "\n") 235 f.write('# -*- coding: utf-8 -*-' + "\n")
236 f.write("\n") 236 f.write("\n")
237 f.write('"""' + "\n") 237 f.write('"""' + "\n")
238 f.write('Package containing the global plugins.' + "\n") 238 f.write('Package containing the global plugins.' + "\n")
239 f.write('"""' + "\n") 239 f.write('"""' + "\n")
240 f.close()
241 if not os.path.exists(self.pluginDirs["global"]): 240 if not os.path.exists(self.pluginDirs["global"]):
242 del self.pluginDirs["global"] 241 del self.pluginDirs["global"]
243 242
244 if not os.path.exists(self.pluginDirs["eric6"]): 243 if not os.path.exists(self.pluginDirs["eric6"]):
245 return ( 244 return (

eric ide

mercurial