##// END OF EJS Templates
load bundled profiles without having to use 'profile create' or '--init'...
MinRK -
Show More
@@ -27,6 +27,7 b' Authors:'
27 # Imports
27 # Imports
28 #-----------------------------------------------------------------------------
28 #-----------------------------------------------------------------------------
29
29
30 import glob
30 import logging
31 import logging
31 import os
32 import os
32 import shutil
33 import shutil
@@ -254,8 +255,8 b' class BaseIPythonApplication(Application):'
254 def init_config_files(self):
255 def init_config_files(self):
255 """[optionally] copy default config files into profile dir."""
256 """[optionally] copy default config files into profile dir."""
256 # copy config files
257 # copy config files
258 path = self.builtin_profile_dir
257 if self.copy_config_files:
259 if self.copy_config_files:
258 path = self.builtin_profile_dir
259 src = self.profile
260 src = self.profile
260
261
261 cfg = self.config_file_name
262 cfg = self.config_file_name
@@ -266,6 +267,19 b' class BaseIPythonApplication(Application):'
266 self.profile_dir.copy_config_file(cfg, path=path, overwrite=self.overwrite)
267 self.profile_dir.copy_config_file(cfg, path=path, overwrite=self.overwrite)
267 else:
268 else:
268 self.stage_default_config_file()
269 self.stage_default_config_file()
270 else:
271 # Still stage *bundled* config files, but not generated ones
272 # This is necessary for `ipython profile=sympy` to load the profile
273 # on the first go
274 files = glob.glob(os.path.join(path, '*.py'))
275 for fullpath in files:
276 cfg = os.path.basename(fullpath)
277 if self.profile_dir.copy_config_file(cfg, path=path, overwrite=False):
278 # file was copied
279 self.log.warn("Staging bundled %s from %s into %r"%(
280 cfg, self.profile, self.profile_dir.location)
281 )
282
269
283
270 def stage_default_config_file(self):
284 def stage_default_config_file(self):
271 """auto generate default config file, and stage it into the profile."""
285 """auto generate default config file, and stage it into the profile."""
@@ -123,11 +123,12 b' class ProfileDir(Configurable):'
123 """
123 """
124 dst = os.path.join(self.location, config_file)
124 dst = os.path.join(self.location, config_file)
125 if os.path.isfile(dst) and not overwrite:
125 if os.path.isfile(dst) and not overwrite:
126 return
126 return False
127 if path is None:
127 if path is None:
128 path = os.path.join(get_ipython_package_dir(), u'config', u'profile', u'default')
128 path = os.path.join(get_ipython_package_dir(), u'config', u'profile', u'default')
129 src = os.path.join(path, config_file)
129 src = os.path.join(path, config_file)
130 shutil.copy(src, dst)
130 shutil.copy(src, dst)
131 return True
131
132
132 @classmethod
133 @classmethod
133 def create_profile_dir(cls, profile_dir, config=None):
134 def create_profile_dir(cls, profile_dir, config=None):
General Comments 0
You need to be logged in to leave comments. Login now