Show More
@@ -476,3 +476,34 b' def check_for_old_config(ipython_dir=None):' | |||
|
476 | 476 | IPython and want to suppress this warning message, set |
|
477 | 477 | `c.InteractiveShellApp.ignore_old_config=True` in the new config.""") |
|
478 | 478 | |
|
479 | def get_security_file(filename, profile='default'): | |
|
480 | """Return the absolute path of a security file given by filename and profile | |
|
481 | ||
|
482 | This allows users and developers to find security files without | |
|
483 | knowledge of the IPython directory structure. The search path | |
|
484 | will be ['.', profile.security_dir] | |
|
485 | ||
|
486 | Parameters | |
|
487 | ---------- | |
|
488 | ||
|
489 | filename : str | |
|
490 | The file to be found. If it is passed as an absolute path, it will | |
|
491 | simply be returned. | |
|
492 | profile : str [default: 'default'] | |
|
493 | The name of the profile to search. Leaving this unspecified | |
|
494 | The file to be found. If it is passed as an absolute path, fname will | |
|
495 | simply be returned. | |
|
496 | ||
|
497 | Returns | |
|
498 | ------- | |
|
499 | Raises :exc:`IOError` if file not found or returns absolute path to file. | |
|
500 | """ | |
|
501 | # import here, because profiledir also imports from utils.path | |
|
502 | from IPython.core.profiledir import ProfileDir | |
|
503 | try: | |
|
504 | pd = ProfileDir.find_profile_dir_by_name(get_ipython_dir(), profile) | |
|
505 | except Exception: | |
|
506 | # will raise ProfileDirError if no such profile | |
|
507 | raise IOError("Profile %r not found") | |
|
508 | return filefind(filename, ['.', pd.security_dir]) | |
|
509 |
General Comments 0
You need to be logged in to leave comments.
Login now