MCPcopy Create free account
hub / github.com/ipython/ipython / find_profile_dir_by_name

Method find_profile_dir_by_name

IPython/core/profiledir.py:182–207  ·  view source on GitHub ↗

Find an existing profile dir by profile name, return its ProfileDir. This searches through a sequence of paths for a profile dir. If it is not found, a :class:`ProfileDirError` exception will be raised. The search path algorithm is: 1. ``os.getcwd()`` 2. ``

(cls, ipython_dir, name=u'default', config=None)

Source from the content-addressed store, hash-verified

180
181 @classmethod
182 def find_profile_dir_by_name(cls, ipython_dir, name=u'default', config=None):
183 """Find an existing profile dir by profile name, return its ProfileDir.
184
185 This searches through a sequence of paths for a profile dir. If it
186 is not found, a :class:`ProfileDirError` exception will be raised.
187
188 The search path algorithm is:
189 1. ``os.getcwd()``
190 2. ``ipython_dir``
191
192 Parameters
193 ----------
194 ipython_dir : unicode or str
195 The IPython directory to use.
196 name : unicode or str
197 The name of the profile. The name of the profile directory
198 will be "profile_<profile>".
199 """
200 dirname = u'profile_' + name
201 paths = [os.getcwd(), ipython_dir]
202 for p in paths:
203 profile_dir = os.path.join(p, dirname)
204 if os.path.isdir(profile_dir):
205 return cls(location=profile_dir, config=config)
206 else:
207 raise ProfileDirError('Profile directory not found in paths: %s' % dirname)
208
209 @classmethod
210 def find_profile_dir(cls, profile_dir, config=None):

Callers 4

locate_profileFunction · 0.80
load_subconfigMethod · 0.80
init_profile_dirMethod · 0.80
test_list_profiles_inFunction · 0.80

Calls 1

ProfileDirErrorClass · 0.85

Tested by 1

test_list_profiles_inFunction · 0.64