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()`` # removed for
(cls, ipython_dir, name=u'default', config=None)
| 201 | |
| 202 | @classmethod |
| 203 | def find_profile_dir_by_name(cls, ipython_dir, name=u'default', config=None): |
| 204 | """Find an existing profile dir by profile name, return its ProfileDir. |
| 205 | |
| 206 | This searches through a sequence of paths for a profile dir. If it |
| 207 | is not found, a :class:`ProfileDirError` exception will be raised. |
| 208 | |
| 209 | The search path algorithm is: |
| 210 | 1. ``os.getcwd()`` # removed for security reason. |
| 211 | 2. ``ipython_dir`` |
| 212 | |
| 213 | Parameters |
| 214 | ---------- |
| 215 | ipython_dir : unicode or str |
| 216 | The IPython directory to use. |
| 217 | name : unicode or str |
| 218 | The name of the profile. The name of the profile directory |
| 219 | will be "profile_<profile>". |
| 220 | """ |
| 221 | dirname = u'profile_' + name |
| 222 | paths = [ipython_dir] |
| 223 | for p in paths: |
| 224 | profile_dir = os.path.join(p, dirname) |
| 225 | if os.path.isdir(profile_dir): |
| 226 | return cls(location=profile_dir, config=config) |
| 227 | else: |
| 228 | raise ProfileDirError('Profile directory not found in paths: %s' % dirname) |
| 229 | |
| 230 | @classmethod |
| 231 | def find_profile_dir(cls, profile_dir, config=None): |