| 124 | return super(ProfileAwareConfigLoader, self).load_subconfig(fname, path=path) |
| 125 | |
| 126 | class BaseIPythonApplication(Application): |
| 127 | name = "ipython" |
| 128 | description = "IPython: an enhanced interactive Python shell." |
| 129 | version = Unicode(release.version) |
| 130 | |
| 131 | aliases = base_aliases |
| 132 | flags = base_flags |
| 133 | classes = List([ProfileDir]) |
| 134 | |
| 135 | # enable `load_subconfig('cfg.py', profile='name')` |
| 136 | python_config_loader_class = ProfileAwareConfigLoader |
| 137 | |
| 138 | # Track whether the config_file has changed, |
| 139 | # because some logic happens only if we aren't using the default. |
| 140 | config_file_specified = Set() |
| 141 | |
| 142 | config_file_name = Unicode() |
| 143 | @default('config_file_name') |
| 144 | def _config_file_name_default(self): |
| 145 | return self.name.replace('-','_') + u'_config.py' |
| 146 | @observe('config_file_name') |
| 147 | def _config_file_name_changed(self, change): |
| 148 | if change['new'] != change['old']: |
| 149 | self.config_file_specified.add(change['new']) |
| 150 | |
| 151 | # The directory that contains IPython's builtin profiles. |
| 152 | builtin_profile_dir = Unicode( |
| 153 | os.path.join(get_ipython_package_dir(), u'config', u'profile', u'default') |
| 154 | ) |
| 155 | |
| 156 | config_file_paths = List(Unicode()) |
| 157 | @default('config_file_paths') |
| 158 | def _config_file_paths_default(self): |
| 159 | return [] |
| 160 | |
| 161 | extra_config_file = Unicode( |
| 162 | help="""Path to an extra config file to load. |
| 163 | |
| 164 | If specified, load this config file in addition to any other IPython config. |
| 165 | """).tag(config=True) |
| 166 | @observe('extra_config_file') |
| 167 | def _extra_config_file_changed(self, change): |
| 168 | old = change['old'] |
| 169 | new = change['new'] |
| 170 | try: |
| 171 | self.config_files.remove(old) |
| 172 | except ValueError: |
| 173 | pass |
| 174 | self.config_file_specified.add(new) |
| 175 | self.config_files.append(new) |
| 176 | |
| 177 | profile = Unicode(u'default', |
| 178 | help="""The IPython profile to use.""" |
| 179 | ).tag(config=True) |
| 180 | |
| 181 | @observe('profile') |
| 182 | def _profile_changed(self, change): |
| 183 | self.builtin_profile_dir = os.path.join( |
searching dependent graphs…