We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
console config not written
assigning to @minrk who said: "Oh jeez, I don't wanna fix that right now". Marking it two-point-oh.


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `IPython/core/profileapp.py`
Content:
```
1 # encoding: utf-8
2 """
3 An application for managing IPython profiles.
4 
5 To be invoked as the `ipython profile` subcommand.
6 
7 Authors:
8 
9 * Min RK
10 
11 """
12 from __future__ import print_function
13 
14 #-----------------------------------------------------------------------------
15 #  Copyright (C) 2008  The IPython Development Team
16 #
17 #  Distributed under the terms of the BSD License.  The full license is in
18 #  the file COPYING, distributed as part of this software.
19 #-----------------------------------------------------------------------------
20 
21 #-----------------------------------------------------------------------------
22 # Imports
23 #-----------------------------------------------------------------------------
24 
25 import os
26 
27 from IPython.config.application import Application
28 from IPython.core.application import (
29     BaseIPythonApplication, base_flags
30 )
31 from IPython.core.profiledir import ProfileDir
32 from IPython.utils.importstring import import_item
33 from IPython.utils.path import get_ipython_dir, get_ipython_package_dir
34 from IPython.utils import py3compat
35 from IPython.utils.traitlets import Unicode, Bool, Dict
36 
37 #-----------------------------------------------------------------------------
38 # Constants
39 #-----------------------------------------------------------------------------
40 
41 create_help = """Create an IPython profile by name
42 
43 Create an ipython profile directory by its name or
44 profile directory path. Profile directories contain
45 configuration, log and security related files and are named
46 using the convention 'profile_<name>'. By default they are
47 located in your ipython directory. Once created, you will
48 can edit the configuration files in the profile
49 directory to configure IPython. Most users will create a
50 profile directory by name,
51 `ipython profile create myprofile`, which will put the directory
52 in `<ipython_dir>/profile_myprofile`.
53 """
54 list_help = """List available IPython profiles
55 
56 List all available profiles, by profile location, that can
57 be found in the current working directly or in the ipython
58 directory. Profile directories are named using the convention
59 'profile_<profile>'.
60 """
61 profile_help = """Manage IPython profiles
62 
63 Profile directories contain
64 configuration, log and security related files and are named
65 using the convention 'profile_<name>'. By default they are
66 located in your ipython directory.  You can create profiles
67 with `ipython profile create <name>`, or see the profiles you
68 already have with `ipython profile list`
69 
70 To get started configuring IPython, simply do:
71 
72 $> ipython profile create
73 
74 and IPython will create the default profile in <ipython_dir>/profile_default,
75 where you can edit ipython_config.py to start configuring IPython.
76 
77 """
78 
79 _list_examples = "ipython profile list  # list all profiles"
80 
81 _create_examples = """
82 ipython profile create foo         # create profile foo w/ default config files
83 ipython profile create foo --reset # restage default config files over current
84 ipython profile create foo --parallel # also stage parallel config files
85 """
86 
87 _main_examples = """
88 ipython profile create -h  # show the help string for the create subcommand
89 ipython profile list -h    # show the help string for the list subcommand
90 
91 ipython locate profile foo # print the path to the directory for profile 'foo'
92 """
93 
94 #-----------------------------------------------------------------------------
95 # Profile Application Class (for `ipython profile` subcommand)
96 #-----------------------------------------------------------------------------
97 
98 
99 def list_profiles_in(path):
100     """list profiles in a given root directory"""
101     files = os.listdir(path)
102     profiles = []
103     for f in files:
104         try:
105             full_path = os.path.join(path, f)
106         except UnicodeError:
107             continue
108         if os.path.isdir(full_path) and f.startswith('profile_'):
109             profiles.append(f.split('_',1)[-1])
110     return profiles
111 
112 
113 def list_bundled_profiles():
114     """list profiles that are bundled with IPython."""
115     path = os.path.join(get_ipython_package_dir(), u'config', u'profile')
116     files = os.listdir(path)
117     profiles = []
118     for profile in files:
119         full_path = os.path.join(path, profile)
120         if os.path.isdir(full_path) and profile != "__pycache__":
121             profiles.append(profile)
122     return profiles
123 
124 
125 class ProfileLocate(BaseIPythonApplication):
126     description = """print the path to an IPython profile dir"""
127     
128     def parse_command_line(self, argv=None):
129         super(ProfileLocate, self).parse_command_line(argv)
130         if self.extra_args:
131             self.profile = self.extra_args[0]
132     
133     def start(self):
134         print(self.profile_dir.location)
135 
136 
137 class ProfileList(Application):
138     name = u'ipython-profile'
139     description = list_help
140     examples = _list_examples
141 
142     aliases = Dict({
143         'ipython-dir' : 'ProfileList.ipython_dir',
144         'log-level' : 'Application.log_level',
145     })
146     flags = Dict(dict(
147         debug = ({'Application' : {'log_level' : 0}},
148             "Set Application.log_level to 0, maximizing log output."
149         )
150     ))
151 
152     ipython_dir = Unicode(get_ipython_dir(), config=True,
153         help="""
154         The name of the IPython directory. This directory is used for logging
155         configuration (through profiles), history storage, etc. The default
156         is usually $HOME/.ipython. This options can also be specified through
157         the environment variable IPYTHONDIR.
158         """
159     )
160 
161 
162     def _print_profiles(self, profiles):
163         """print list of profiles, indented."""
164         for profile in profiles:
165             print('    %s' % profile)
166 
167     def list_profile_dirs(self):
168         profiles = list_bundled_profiles()
169         if profiles:
170             print()
171             print("Available profiles in IPython:")
172             self._print_profiles(profiles)
173             print()
174             print("    The first request for a bundled profile will copy it")
175             print("    into your IPython directory (%s)," % self.ipython_dir)
176             print("    where you can customize it.")
177         
178         profiles = list_profiles_in(self.ipython_dir)
179         if profiles:
180             print()
181             print("Available profiles in %s:" % self.ipython_dir)
182             self._print_profiles(profiles)
183         
184         profiles = list_profiles_in(py3compat.getcwd())
185         if profiles:
186             print()
187             print("Available profiles in current directory (%s):" % py3compat.getcwd())
188             self._print_profiles(profiles)
189         
190         print()
191         print("To use any of the above profiles, start IPython with:")
192         print("    ipython --profile=<name>")
193         print()
194 
195     def start(self):
196         self.list_profile_dirs()
197 
198 
199 create_flags = {}
200 create_flags.update(base_flags)
201 # don't include '--init' flag, which implies running profile create in other apps
202 create_flags.pop('init')
203 create_flags['reset'] = ({'ProfileCreate': {'overwrite' : True}},
204                         "reset config files in this profile to the defaults.")
205 create_flags['parallel'] = ({'ProfileCreate': {'parallel' : True}},
206                         "Include the config files for parallel "
207                         "computing apps (ipengine, ipcontroller, etc.)")
208 
209 
210 class ProfileCreate(BaseIPythonApplication):
211     name = u'ipython-profile'
212     description = create_help
213     examples = _create_examples
214     auto_create = Bool(True, config=False)
215     def _log_format_default(self):
216         return "[%(name)s] %(message)s"
217 
218     def _copy_config_files_default(self):
219         return True
220 
221     parallel = Bool(False, config=True,
222         help="whether to include parallel computing config files")
223     def _parallel_changed(self, name, old, new):
224         parallel_files = [   'ipcontroller_config.py',
225                             'ipengine_config.py',
226                             'ipcluster_config.py'
227                         ]
228         if new:
229             for cf in parallel_files:
230                 self.config_files.append(cf)
231         else:
232             for cf in parallel_files:
233                 if cf in self.config_files:
234                     self.config_files.remove(cf)
235 
236     def parse_command_line(self, argv):
237         super(ProfileCreate, self).parse_command_line(argv)
238         # accept positional arg as profile name
239         if self.extra_args:
240             self.profile = self.extra_args[0]
241 
242     flags = Dict(create_flags)
243 
244     classes = [ProfileDir]
245     
246     def _import_app(self, app_path):
247         """import an app class"""
248         app = None
249         name = app_path.rsplit('.', 1)[-1]
250         try:
251             app = import_item(app_path)
252         except ImportError:
253             self.log.info("Couldn't import %s, config file will be excluded", name)
254         except Exception:
255             self.log.warn('Unexpected error importing %s', name, exc_info=True)
256         return app
257 
258     def init_config_files(self):
259         super(ProfileCreate, self).init_config_files()
260         # use local imports, since these classes may import from here
261         from IPython.terminal.ipapp import TerminalIPythonApp
262         apps = [TerminalIPythonApp]
263         for app_path in (
264             'IPython.kernel.zmq.kernelapp.IPKernelApp',
265             'IPython.qt.console.qtconsoleapp.IPythonQtConsoleApp',
266             'IPython.html.notebookapp.NotebookApp',
267             'IPython.nbconvert.nbconvertapp.NbConvertApp',
268         ):
269             app = self._import_app(app_path)
270             if app is not None:
271                 apps.append(app)
272         if self.parallel:
273             from IPython.parallel.apps.ipcontrollerapp import IPControllerApp
274             from IPython.parallel.apps.ipengineapp import IPEngineApp
275             from IPython.parallel.apps.ipclusterapp import IPClusterStart
276             from IPython.parallel.apps.iploggerapp import IPLoggerApp
277             apps.extend([
278                 IPControllerApp,
279                 IPEngineApp,
280                 IPClusterStart,
281                 IPLoggerApp,
282             ])
283         for App in apps:
284             app = App()
285             app.config.update(self.config)
286             app.log = self.log
287             app.overwrite = self.overwrite
288             app.copy_config_files=True
289             app.ipython_dir=self.ipython_dir
290             app.profile_dir=self.profile_dir
291             app.init_config_files()
292 
293     def stage_default_config_file(self):
294         pass
295 
296 
297 class ProfileApp(Application):
298     name = u'ipython profile'
299     description = profile_help
300     examples = _main_examples
301 
302     subcommands = Dict(dict(
303         create = (ProfileCreate, ProfileCreate.description.splitlines()[0]),
304         list = (ProfileList, ProfileList.description.splitlines()[0]),
305         locate = (ProfileLocate, ProfileLocate.description.splitlines()[0]),
306     ))
307 
308     def start(self):
309         if self.subapp is None:
310             print("No subcommand specified. Must specify one of: %s"%(self.subcommands.keys()))
311             print()
312             self.print_description()
313             self.print_subcommands()
314             self.exit(1)
315         else:
316             return self.subapp.start()
317
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/IPython/core/profileapp.py b/IPython/core/profileapp.py
--- a/IPython/core/profileapp.py
+++ b/IPython/core/profileapp.py
@@ -262,6 +262,7 @@
         apps = [TerminalIPythonApp]
         for app_path in (
             'IPython.kernel.zmq.kernelapp.IPKernelApp',
+            'IPython.terminal.console.app.ZMQTerminalIPythonApp',
             'IPython.qt.console.qtconsoleapp.IPythonQtConsoleApp',
             'IPython.html.notebookapp.NotebookApp',
             'IPython.nbconvert.nbconvertapp.NbConvertApp',

{"golden_diff": "diff --git a/IPython/core/profileapp.py b/IPython/core/profileapp.py\n--- a/IPython/core/profileapp.py\n+++ b/IPython/core/profileapp.py\n@@ -262,6 +262,7 @@\n         apps = [TerminalIPythonApp]\n         for app_path in (\n             'IPython.kernel.zmq.kernelapp.IPKernelApp',\n+            'IPython.terminal.console.app.ZMQTerminalIPythonApp',\n             'IPython.qt.console.qtconsoleapp.IPythonQtConsoleApp',\n             'IPython.html.notebookapp.NotebookApp',\n             'IPython.nbconvert.nbconvertapp.NbConvertApp',\n", "issue": "console config not written\nassigning to @minrk who said: \"Oh jeez, I don't wanna fix that right now\". Marking it two-point-oh.\n\n", "before_files": [{"content": "# encoding: utf-8\n\"\"\"\nAn application for managing IPython profiles.\n\nTo be invoked as the `ipython profile` subcommand.\n\nAuthors:\n\n* Min RK\n\n\"\"\"\nfrom __future__ import print_function\n\n#-----------------------------------------------------------------------------\n#  Copyright (C) 2008  The IPython Development Team\n#\n#  Distributed under the terms of the BSD License.  The full license is in\n#  the file COPYING, distributed as part of this software.\n#-----------------------------------------------------------------------------\n\n#-----------------------------------------------------------------------------\n# Imports\n#-----------------------------------------------------------------------------\n\nimport os\n\nfrom IPython.config.application import Application\nfrom IPython.core.application import (\n    BaseIPythonApplication, base_flags\n)\nfrom IPython.core.profiledir import ProfileDir\nfrom IPython.utils.importstring import import_item\nfrom IPython.utils.path import get_ipython_dir, get_ipython_package_dir\nfrom IPython.utils import py3compat\nfrom IPython.utils.traitlets import Unicode, Bool, Dict\n\n#-----------------------------------------------------------------------------\n# Constants\n#-----------------------------------------------------------------------------\n\ncreate_help = \"\"\"Create an IPython profile by name\n\nCreate an ipython profile directory by its name or\nprofile directory path. Profile directories contain\nconfiguration, log and security related files and are named\nusing the convention 'profile_<name>'. By default they are\nlocated in your ipython directory. Once created, you will\ncan edit the configuration files in the profile\ndirectory to configure IPython. Most users will create a\nprofile directory by name,\n`ipython profile create myprofile`, which will put the directory\nin `<ipython_dir>/profile_myprofile`.\n\"\"\"\nlist_help = \"\"\"List available IPython profiles\n\nList all available profiles, by profile location, that can\nbe found in the current working directly or in the ipython\ndirectory. Profile directories are named using the convention\n'profile_<profile>'.\n\"\"\"\nprofile_help = \"\"\"Manage IPython profiles\n\nProfile directories contain\nconfiguration, log and security related files and are named\nusing the convention 'profile_<name>'. By default they are\nlocated in your ipython directory.  You can create profiles\nwith `ipython profile create <name>`, or see the profiles you\nalready have with `ipython profile list`\n\nTo get started configuring IPython, simply do:\n\n$> ipython profile create\n\nand IPython will create the default profile in <ipython_dir>/profile_default,\nwhere you can edit ipython_config.py to start configuring IPython.\n\n\"\"\"\n\n_list_examples = \"ipython profile list  # list all profiles\"\n\n_create_examples = \"\"\"\nipython profile create foo         # create profile foo w/ default config files\nipython profile create foo --reset # restage default config files over current\nipython profile create foo --parallel # also stage parallel config files\n\"\"\"\n\n_main_examples = \"\"\"\nipython profile create -h  # show the help string for the create subcommand\nipython profile list -h    # show the help string for the list subcommand\n\nipython locate profile foo # print the path to the directory for profile 'foo'\n\"\"\"\n\n#-----------------------------------------------------------------------------\n# Profile Application Class (for `ipython profile` subcommand)\n#-----------------------------------------------------------------------------\n\n\ndef list_profiles_in(path):\n    \"\"\"list profiles in a given root directory\"\"\"\n    files = os.listdir(path)\n    profiles = []\n    for f in files:\n        try:\n            full_path = os.path.join(path, f)\n        except UnicodeError:\n            continue\n        if os.path.isdir(full_path) and f.startswith('profile_'):\n            profiles.append(f.split('_',1)[-1])\n    return profiles\n\n\ndef list_bundled_profiles():\n    \"\"\"list profiles that are bundled with IPython.\"\"\"\n    path = os.path.join(get_ipython_package_dir(), u'config', u'profile')\n    files = os.listdir(path)\n    profiles = []\n    for profile in files:\n        full_path = os.path.join(path, profile)\n        if os.path.isdir(full_path) and profile != \"__pycache__\":\n            profiles.append(profile)\n    return profiles\n\n\nclass ProfileLocate(BaseIPythonApplication):\n    description = \"\"\"print the path to an IPython profile dir\"\"\"\n    \n    def parse_command_line(self, argv=None):\n        super(ProfileLocate, self).parse_command_line(argv)\n        if self.extra_args:\n            self.profile = self.extra_args[0]\n    \n    def start(self):\n        print(self.profile_dir.location)\n\n\nclass ProfileList(Application):\n    name = u'ipython-profile'\n    description = list_help\n    examples = _list_examples\n\n    aliases = Dict({\n        'ipython-dir' : 'ProfileList.ipython_dir',\n        'log-level' : 'Application.log_level',\n    })\n    flags = Dict(dict(\n        debug = ({'Application' : {'log_level' : 0}},\n            \"Set Application.log_level to 0, maximizing log output.\"\n        )\n    ))\n\n    ipython_dir = Unicode(get_ipython_dir(), config=True,\n        help=\"\"\"\n        The name of the IPython directory. This directory is used for logging\n        configuration (through profiles), history storage, etc. The default\n        is usually $HOME/.ipython. This options can also be specified through\n        the environment variable IPYTHONDIR.\n        \"\"\"\n    )\n\n\n    def _print_profiles(self, profiles):\n        \"\"\"print list of profiles, indented.\"\"\"\n        for profile in profiles:\n            print('    %s' % profile)\n\n    def list_profile_dirs(self):\n        profiles = list_bundled_profiles()\n        if profiles:\n            print()\n            print(\"Available profiles in IPython:\")\n            self._print_profiles(profiles)\n            print()\n            print(\"    The first request for a bundled profile will copy it\")\n            print(\"    into your IPython directory (%s),\" % self.ipython_dir)\n            print(\"    where you can customize it.\")\n        \n        profiles = list_profiles_in(self.ipython_dir)\n        if profiles:\n            print()\n            print(\"Available profiles in %s:\" % self.ipython_dir)\n            self._print_profiles(profiles)\n        \n        profiles = list_profiles_in(py3compat.getcwd())\n        if profiles:\n            print()\n            print(\"Available profiles in current directory (%s):\" % py3compat.getcwd())\n            self._print_profiles(profiles)\n        \n        print()\n        print(\"To use any of the above profiles, start IPython with:\")\n        print(\"    ipython --profile=<name>\")\n        print()\n\n    def start(self):\n        self.list_profile_dirs()\n\n\ncreate_flags = {}\ncreate_flags.update(base_flags)\n# don't include '--init' flag, which implies running profile create in other apps\ncreate_flags.pop('init')\ncreate_flags['reset'] = ({'ProfileCreate': {'overwrite' : True}},\n                        \"reset config files in this profile to the defaults.\")\ncreate_flags['parallel'] = ({'ProfileCreate': {'parallel' : True}},\n                        \"Include the config files for parallel \"\n                        \"computing apps (ipengine, ipcontroller, etc.)\")\n\n\nclass ProfileCreate(BaseIPythonApplication):\n    name = u'ipython-profile'\n    description = create_help\n    examples = _create_examples\n    auto_create = Bool(True, config=False)\n    def _log_format_default(self):\n        return \"[%(name)s] %(message)s\"\n\n    def _copy_config_files_default(self):\n        return True\n\n    parallel = Bool(False, config=True,\n        help=\"whether to include parallel computing config files\")\n    def _parallel_changed(self, name, old, new):\n        parallel_files = [   'ipcontroller_config.py',\n                            'ipengine_config.py',\n                            'ipcluster_config.py'\n                        ]\n        if new:\n            for cf in parallel_files:\n                self.config_files.append(cf)\n        else:\n            for cf in parallel_files:\n                if cf in self.config_files:\n                    self.config_files.remove(cf)\n\n    def parse_command_line(self, argv):\n        super(ProfileCreate, self).parse_command_line(argv)\n        # accept positional arg as profile name\n        if self.extra_args:\n            self.profile = self.extra_args[0]\n\n    flags = Dict(create_flags)\n\n    classes = [ProfileDir]\n    \n    def _import_app(self, app_path):\n        \"\"\"import an app class\"\"\"\n        app = None\n        name = app_path.rsplit('.', 1)[-1]\n        try:\n            app = import_item(app_path)\n        except ImportError:\n            self.log.info(\"Couldn't import %s, config file will be excluded\", name)\n        except Exception:\n            self.log.warn('Unexpected error importing %s', name, exc_info=True)\n        return app\n\n    def init_config_files(self):\n        super(ProfileCreate, self).init_config_files()\n        # use local imports, since these classes may import from here\n        from IPython.terminal.ipapp import TerminalIPythonApp\n        apps = [TerminalIPythonApp]\n        for app_path in (\n            'IPython.kernel.zmq.kernelapp.IPKernelApp',\n            'IPython.qt.console.qtconsoleapp.IPythonQtConsoleApp',\n            'IPython.html.notebookapp.NotebookApp',\n            'IPython.nbconvert.nbconvertapp.NbConvertApp',\n        ):\n            app = self._import_app(app_path)\n            if app is not None:\n                apps.append(app)\n        if self.parallel:\n            from IPython.parallel.apps.ipcontrollerapp import IPControllerApp\n            from IPython.parallel.apps.ipengineapp import IPEngineApp\n            from IPython.parallel.apps.ipclusterapp import IPClusterStart\n            from IPython.parallel.apps.iploggerapp import IPLoggerApp\n            apps.extend([\n                IPControllerApp,\n                IPEngineApp,\n                IPClusterStart,\n                IPLoggerApp,\n            ])\n        for App in apps:\n            app = App()\n            app.config.update(self.config)\n            app.log = self.log\n            app.overwrite = self.overwrite\n            app.copy_config_files=True\n            app.ipython_dir=self.ipython_dir\n            app.profile_dir=self.profile_dir\n            app.init_config_files()\n\n    def stage_default_config_file(self):\n        pass\n\n\nclass ProfileApp(Application):\n    name = u'ipython profile'\n    description = profile_help\n    examples = _main_examples\n\n    subcommands = Dict(dict(\n        create = (ProfileCreate, ProfileCreate.description.splitlines()[0]),\n        list = (ProfileList, ProfileList.description.splitlines()[0]),\n        locate = (ProfileLocate, ProfileLocate.description.splitlines()[0]),\n    ))\n\n    def start(self):\n        if self.subapp is None:\n            print(\"No subcommand specified. Must specify one of: %s\"%(self.subcommands.keys()))\n            print()\n            self.print_description()\n            self.print_subcommands()\n            self.exit(1)\n        else:\n            return self.subapp.start()\n", "path": "IPython/core/profileapp.py"}], "after_files": [{"content": "# encoding: utf-8\n\"\"\"\nAn application for managing IPython profiles.\n\nTo be invoked as the `ipython profile` subcommand.\n\nAuthors:\n\n* Min RK\n\n\"\"\"\nfrom __future__ import print_function\n\n#-----------------------------------------------------------------------------\n#  Copyright (C) 2008  The IPython Development Team\n#\n#  Distributed under the terms of the BSD License.  The full license is in\n#  the file COPYING, distributed as part of this software.\n#-----------------------------------------------------------------------------\n\n#-----------------------------------------------------------------------------\n# Imports\n#-----------------------------------------------------------------------------\n\nimport os\n\nfrom IPython.config.application import Application\nfrom IPython.core.application import (\n    BaseIPythonApplication, base_flags\n)\nfrom IPython.core.profiledir import ProfileDir\nfrom IPython.utils.importstring import import_item\nfrom IPython.utils.path import get_ipython_dir, get_ipython_package_dir\nfrom IPython.utils import py3compat\nfrom IPython.utils.traitlets import Unicode, Bool, Dict\n\n#-----------------------------------------------------------------------------\n# Constants\n#-----------------------------------------------------------------------------\n\ncreate_help = \"\"\"Create an IPython profile by name\n\nCreate an ipython profile directory by its name or\nprofile directory path. Profile directories contain\nconfiguration, log and security related files and are named\nusing the convention 'profile_<name>'. By default they are\nlocated in your ipython directory. Once created, you will\ncan edit the configuration files in the profile\ndirectory to configure IPython. Most users will create a\nprofile directory by name,\n`ipython profile create myprofile`, which will put the directory\nin `<ipython_dir>/profile_myprofile`.\n\"\"\"\nlist_help = \"\"\"List available IPython profiles\n\nList all available profiles, by profile location, that can\nbe found in the current working directly or in the ipython\ndirectory. Profile directories are named using the convention\n'profile_<profile>'.\n\"\"\"\nprofile_help = \"\"\"Manage IPython profiles\n\nProfile directories contain\nconfiguration, log and security related files and are named\nusing the convention 'profile_<name>'. By default they are\nlocated in your ipython directory.  You can create profiles\nwith `ipython profile create <name>`, or see the profiles you\nalready have with `ipython profile list`\n\nTo get started configuring IPython, simply do:\n\n$> ipython profile create\n\nand IPython will create the default profile in <ipython_dir>/profile_default,\nwhere you can edit ipython_config.py to start configuring IPython.\n\n\"\"\"\n\n_list_examples = \"ipython profile list  # list all profiles\"\n\n_create_examples = \"\"\"\nipython profile create foo         # create profile foo w/ default config files\nipython profile create foo --reset # restage default config files over current\nipython profile create foo --parallel # also stage parallel config files\n\"\"\"\n\n_main_examples = \"\"\"\nipython profile create -h  # show the help string for the create subcommand\nipython profile list -h    # show the help string for the list subcommand\n\nipython locate profile foo # print the path to the directory for profile 'foo'\n\"\"\"\n\n#-----------------------------------------------------------------------------\n# Profile Application Class (for `ipython profile` subcommand)\n#-----------------------------------------------------------------------------\n\n\ndef list_profiles_in(path):\n    \"\"\"list profiles in a given root directory\"\"\"\n    files = os.listdir(path)\n    profiles = []\n    for f in files:\n        try:\n            full_path = os.path.join(path, f)\n        except UnicodeError:\n            continue\n        if os.path.isdir(full_path) and f.startswith('profile_'):\n            profiles.append(f.split('_',1)[-1])\n    return profiles\n\n\ndef list_bundled_profiles():\n    \"\"\"list profiles that are bundled with IPython.\"\"\"\n    path = os.path.join(get_ipython_package_dir(), u'config', u'profile')\n    files = os.listdir(path)\n    profiles = []\n    for profile in files:\n        full_path = os.path.join(path, profile)\n        if os.path.isdir(full_path) and profile != \"__pycache__\":\n            profiles.append(profile)\n    return profiles\n\n\nclass ProfileLocate(BaseIPythonApplication):\n    description = \"\"\"print the path to an IPython profile dir\"\"\"\n    \n    def parse_command_line(self, argv=None):\n        super(ProfileLocate, self).parse_command_line(argv)\n        if self.extra_args:\n            self.profile = self.extra_args[0]\n    \n    def start(self):\n        print(self.profile_dir.location)\n\n\nclass ProfileList(Application):\n    name = u'ipython-profile'\n    description = list_help\n    examples = _list_examples\n\n    aliases = Dict({\n        'ipython-dir' : 'ProfileList.ipython_dir',\n        'log-level' : 'Application.log_level',\n    })\n    flags = Dict(dict(\n        debug = ({'Application' : {'log_level' : 0}},\n            \"Set Application.log_level to 0, maximizing log output.\"\n        )\n    ))\n\n    ipython_dir = Unicode(get_ipython_dir(), config=True,\n        help=\"\"\"\n        The name of the IPython directory. This directory is used for logging\n        configuration (through profiles), history storage, etc. The default\n        is usually $HOME/.ipython. This options can also be specified through\n        the environment variable IPYTHONDIR.\n        \"\"\"\n    )\n\n\n    def _print_profiles(self, profiles):\n        \"\"\"print list of profiles, indented.\"\"\"\n        for profile in profiles:\n            print('    %s' % profile)\n\n    def list_profile_dirs(self):\n        profiles = list_bundled_profiles()\n        if profiles:\n            print()\n            print(\"Available profiles in IPython:\")\n            self._print_profiles(profiles)\n            print()\n            print(\"    The first request for a bundled profile will copy it\")\n            print(\"    into your IPython directory (%s),\" % self.ipython_dir)\n            print(\"    where you can customize it.\")\n        \n        profiles = list_profiles_in(self.ipython_dir)\n        if profiles:\n            print()\n            print(\"Available profiles in %s:\" % self.ipython_dir)\n            self._print_profiles(profiles)\n        \n        profiles = list_profiles_in(py3compat.getcwd())\n        if profiles:\n            print()\n            print(\"Available profiles in current directory (%s):\" % py3compat.getcwd())\n            self._print_profiles(profiles)\n        \n        print()\n        print(\"To use any of the above profiles, start IPython with:\")\n        print(\"    ipython --profile=<name>\")\n        print()\n\n    def start(self):\n        self.list_profile_dirs()\n\n\ncreate_flags = {}\ncreate_flags.update(base_flags)\n# don't include '--init' flag, which implies running profile create in other apps\ncreate_flags.pop('init')\ncreate_flags['reset'] = ({'ProfileCreate': {'overwrite' : True}},\n                        \"reset config files in this profile to the defaults.\")\ncreate_flags['parallel'] = ({'ProfileCreate': {'parallel' : True}},\n                        \"Include the config files for parallel \"\n                        \"computing apps (ipengine, ipcontroller, etc.)\")\n\n\nclass ProfileCreate(BaseIPythonApplication):\n    name = u'ipython-profile'\n    description = create_help\n    examples = _create_examples\n    auto_create = Bool(True, config=False)\n    def _log_format_default(self):\n        return \"[%(name)s] %(message)s\"\n\n    def _copy_config_files_default(self):\n        return True\n\n    parallel = Bool(False, config=True,\n        help=\"whether to include parallel computing config files\")\n    def _parallel_changed(self, name, old, new):\n        parallel_files = [   'ipcontroller_config.py',\n                            'ipengine_config.py',\n                            'ipcluster_config.py'\n                        ]\n        if new:\n            for cf in parallel_files:\n                self.config_files.append(cf)\n        else:\n            for cf in parallel_files:\n                if cf in self.config_files:\n                    self.config_files.remove(cf)\n\n    def parse_command_line(self, argv):\n        super(ProfileCreate, self).parse_command_line(argv)\n        # accept positional arg as profile name\n        if self.extra_args:\n            self.profile = self.extra_args[0]\n\n    flags = Dict(create_flags)\n\n    classes = [ProfileDir]\n    \n    def _import_app(self, app_path):\n        \"\"\"import an app class\"\"\"\n        app = None\n        name = app_path.rsplit('.', 1)[-1]\n        try:\n            app = import_item(app_path)\n        except ImportError:\n            self.log.info(\"Couldn't import %s, config file will be excluded\", name)\n        except Exception:\n            self.log.warn('Unexpected error importing %s', name, exc_info=True)\n        return app\n\n    def init_config_files(self):\n        super(ProfileCreate, self).init_config_files()\n        # use local imports, since these classes may import from here\n        from IPython.terminal.ipapp import TerminalIPythonApp\n        apps = [TerminalIPythonApp]\n        for app_path in (\n            'IPython.kernel.zmq.kernelapp.IPKernelApp',\n            'IPython.terminal.console.app.ZMQTerminalIPythonApp',\n            'IPython.qt.console.qtconsoleapp.IPythonQtConsoleApp',\n            'IPython.html.notebookapp.NotebookApp',\n            'IPython.nbconvert.nbconvertapp.NbConvertApp',\n        ):\n            app = self._import_app(app_path)\n            if app is not None:\n                apps.append(app)\n        if self.parallel:\n            from IPython.parallel.apps.ipcontrollerapp import IPControllerApp\n            from IPython.parallel.apps.ipengineapp import IPEngineApp\n            from IPython.parallel.apps.ipclusterapp import IPClusterStart\n            from IPython.parallel.apps.iploggerapp import IPLoggerApp\n            apps.extend([\n                IPControllerApp,\n                IPEngineApp,\n                IPClusterStart,\n                IPLoggerApp,\n            ])\n        for App in apps:\n            app = App()\n            app.config.update(self.config)\n            app.log = self.log\n            app.overwrite = self.overwrite\n            app.copy_config_files=True\n            app.ipython_dir=self.ipython_dir\n            app.profile_dir=self.profile_dir\n            app.init_config_files()\n\n    def stage_default_config_file(self):\n        pass\n\n\nclass ProfileApp(Application):\n    name = u'ipython profile'\n    description = profile_help\n    examples = _main_examples\n\n    subcommands = Dict(dict(\n        create = (ProfileCreate, ProfileCreate.description.splitlines()[0]),\n        list = (ProfileList, ProfileList.description.splitlines()[0]),\n        locate = (ProfileLocate, ProfileLocate.description.splitlines()[0]),\n    ))\n\n    def start(self):\n        if self.subapp is None:\n            print(\"No subcommand specified. Must specify one of: %s\"%(self.subcommands.keys()))\n            print()\n            self.print_description()\n            self.print_subcommands()\n            self.exit(1)\n        else:\n            return self.subapp.start()\n", "path": "IPython/core/profileapp.py"}]}