Show More
@@ -42,7 +42,6 b' sys.path.append(os.path.join(os.path.dirname(__file__), "extensions"))' | |||
|
42 | 42 | # Setup the top level names |
|
43 | 43 | #----------------------------------------------------------------------------- |
|
44 | 44 | |
|
45 | from .config.loader import Config | |
|
46 | 45 | from .core.getipython import get_ipython |
|
47 | 46 | from .core import release |
|
48 | 47 | from .core.application import Application |
@@ -88,7 +87,7 b' def embed_kernel(module=None, local_ns=None, **kwargs):' | |||
|
88 | 87 | local_ns = caller_locals |
|
89 | 88 | |
|
90 | 89 | # Only import .zmq when we really need it |
|
91 |
from |
|
|
90 | from ipython_kernel.embed import embed_kernel as real_embed_kernel | |
|
92 | 91 | real_embed_kernel(module=module, local_ns=local_ns, **kwargs) |
|
93 | 92 | |
|
94 | 93 | def start_ipython(argv=None, **kwargs): |
@@ -24,11 +24,11 b' import os' | |||
|
24 | 24 | import re |
|
25 | 25 | import sys |
|
26 | 26 | |
|
27 |
from |
|
|
27 | from traitlets.config.configurable import Configurable | |
|
28 | 28 | from IPython.core.error import UsageError |
|
29 | 29 | |
|
30 | 30 | from IPython.utils.py3compat import string_types |
|
31 |
from |
|
|
31 | from traitlets import List, Instance | |
|
32 | 32 | from IPython.utils.warn import error |
|
33 | 33 | |
|
34 | 34 | #----------------------------------------------------------------------------- |
@@ -19,13 +19,14 b' import os' | |||
|
19 | 19 | import shutil |
|
20 | 20 | import sys |
|
21 | 21 | |
|
22 |
from |
|
|
23 |
from |
|
|
22 | from traitlets.config.application import Application, catch_config_error | |
|
23 | from traitlets.config.loader import ConfigFileNotFound, PyFileConfigLoader | |
|
24 | 24 | from IPython.core import release, crashhandler |
|
25 | 25 | from IPython.core.profiledir import ProfileDir, ProfileDirError |
|
26 |
from IPython. |
|
|
26 | from IPython.paths import get_ipython_dir, get_ipython_package_dir | |
|
27 | from IPython.utils.path import ensure_dir_exists | |
|
27 | 28 | from IPython.utils import py3compat |
|
28 |
from |
|
|
29 | from traitlets import List, Unicode, Type, Bool, Dict, Set, Instance, Undefined | |
|
29 | 30 | |
|
30 | 31 | if os.name == 'nt': |
|
31 | 32 | programdata = os.environ.get('PROGRAMDATA', None) |
@@ -18,10 +18,10 b' Authors:' | |||
|
18 | 18 | # Imports |
|
19 | 19 | #----------------------------------------------------------------------------- |
|
20 | 20 | |
|
21 |
from |
|
|
21 | from traitlets.config.configurable import Configurable | |
|
22 | 22 | |
|
23 | 23 | from IPython.utils.py3compat import builtin_mod, iteritems |
|
24 |
from |
|
|
24 | from traitlets import Instance | |
|
25 | 25 | |
|
26 | 26 | #----------------------------------------------------------------------------- |
|
27 | 27 | # Classes and functions |
@@ -64,7 +64,7 b' import sys' | |||
|
64 | 64 | import unicodedata |
|
65 | 65 | import string |
|
66 | 66 | |
|
67 |
from |
|
|
67 | from traitlets.config.configurable import Configurable | |
|
68 | 68 | from IPython.core.error import TryNext |
|
69 | 69 | from IPython.core.inputsplitter import ESC_MAGIC |
|
70 | 70 | from IPython.core.latex_symbols import latex_symbols, reverse_latex_symbol |
@@ -74,7 +74,7 b' from IPython.utils.decorators import undoc' | |||
|
74 | 74 | from IPython.utils.dir2 import dir2 |
|
75 | 75 | from IPython.utils.process import arg_split |
|
76 | 76 | from IPython.utils.py3compat import builtin_mod, string_types, PY3 |
|
77 |
from |
|
|
77 | from traitlets import CBool, Enum | |
|
78 | 78 | |
|
79 | 79 | #----------------------------------------------------------------------------- |
|
80 | 80 | # Globals |
@@ -930,9 +930,9 b' def set_matplotlib_formats(*formats, **kwargs):' | |||
|
930 | 930 | """ |
|
931 | 931 | from IPython.core.interactiveshell import InteractiveShell |
|
932 | 932 | from IPython.core.pylabtools import select_figure_formats |
|
933 | from IPython.kernel.zmq.pylab.config import InlineBackend | |
|
934 | 933 | # build kwargs, starting with InlineBackend config |
|
935 | 934 | kw = {} |
|
935 | from ipython_kernel.pylab.config import InlineBackend | |
|
936 | 936 | cfg = InlineBackend.instance() |
|
937 | 937 | kw.update(cfg.print_figure_kwargs) |
|
938 | 938 | kw.update(**kwargs) |
@@ -961,7 +961,7 b' def set_matplotlib_close(close=True):' | |||
|
961 | 961 | Should all matplotlib figures be automatically closed after each cell is |
|
962 | 962 | run? |
|
963 | 963 | """ |
|
964 |
from |
|
|
964 | from ipython_kernel.pylab.config import InlineBackend | |
|
965 | 965 | cfg = InlineBackend.instance() |
|
966 | 966 | cfg.close_figures = close |
|
967 | 967 |
@@ -21,8 +21,8 b' Authors:' | |||
|
21 | 21 | |
|
22 | 22 | import sys |
|
23 | 23 | |
|
24 |
from |
|
|
25 |
from |
|
|
24 | from traitlets.config.configurable import Configurable | |
|
25 | from traitlets import Any | |
|
26 | 26 | |
|
27 | 27 | #----------------------------------------------------------------------------- |
|
28 | 28 | # Classes and functions |
@@ -12,10 +12,10 b' from __future__ import print_function' | |||
|
12 | 12 | import sys |
|
13 | 13 | |
|
14 | 14 | from IPython.core.formatters import _safe_get_formatter_method |
|
15 |
from |
|
|
15 | from traitlets.config.configurable import Configurable | |
|
16 | 16 | from IPython.utils import io |
|
17 | 17 | from IPython.utils.py3compat import builtin_mod |
|
18 |
from |
|
|
18 | from traitlets import Instance, Float | |
|
19 | 19 | from IPython.utils.warn import warn |
|
20 | 20 | |
|
21 | 21 | # TODO: Move the various attributes (cache_size, [others now moved]). Some |
@@ -17,9 +17,9 b' spec.' | |||
|
17 | 17 | |
|
18 | 18 | from __future__ import print_function |
|
19 | 19 | |
|
20 |
from |
|
|
20 | from traitlets.config.configurable import Configurable | |
|
21 | 21 | from IPython.utils import io |
|
22 |
from |
|
|
22 | from traitlets import List | |
|
23 | 23 | |
|
24 | 24 | # This used to be defined here - it is imported for backwards compatibility |
|
25 | 25 | from .display import publish_display_data |
@@ -8,9 +8,9 b' import os' | |||
|
8 | 8 | from shutil import copyfile |
|
9 | 9 | import sys |
|
10 | 10 | |
|
11 |
from |
|
|
11 | from traitlets.config.configurable import Configurable | |
|
12 | 12 | from IPython.utils.path import ensure_dir_exists |
|
13 |
from |
|
|
13 | from traitlets import Instance | |
|
14 | 14 | from IPython.utils.py3compat import PY3 |
|
15 | 15 | if PY3: |
|
16 | 16 | from imp import reload |
@@ -19,11 +19,11 b' import warnings' | |||
|
19 | 19 | |
|
20 | 20 | from decorator import decorator |
|
21 | 21 | |
|
22 |
from |
|
|
22 | from traitlets.config.configurable import Configurable | |
|
23 | 23 | from IPython.core.getipython import get_ipython |
|
24 | 24 | from IPython.utils.sentinel import Sentinel |
|
25 | 25 | from IPython.lib import pretty |
|
26 |
from |
|
|
26 | from traitlets import ( | |
|
27 | 27 | Bool, Dict, Integer, Unicode, CUnicode, ObjectName, List, |
|
28 | 28 | ForwardDeclaredInstance, |
|
29 | 29 | ) |
@@ -27,12 +27,12 b' except ImportError:' | |||
|
27 | 27 | import threading |
|
28 | 28 | |
|
29 | 29 | # Our own packages |
|
30 |
from |
|
|
30 | from traitlets.config.configurable import Configurable | |
|
31 | 31 | from decorator import decorator |
|
32 | 32 | from IPython.utils.decorators import undoc |
|
33 | 33 | from IPython.utils.path import locate_profile |
|
34 | 34 | from IPython.utils import py3compat |
|
35 |
from |
|
|
35 | from traitlets import ( | |
|
36 | 36 | Any, Bool, Dict, Instance, Integer, List, Unicode, TraitError, |
|
37 | 37 | ) |
|
38 | 38 | from IPython.utils.warn import warn |
@@ -177,7 +177,7 b' class HistoryAccessor(HistoryAccessorBase):' | |||
|
177 | 177 | hist_file : str |
|
178 | 178 | Path to an SQLite history database stored by IPython. If specified, |
|
179 | 179 | hist_file overrides profile. |
|
180 |
config : :class:`~ |
|
|
180 | config : :class:`~traitlets.config.loader.Config` | |
|
181 | 181 | Config object. hist_file can also be set through this. |
|
182 | 182 | """ |
|
183 | 183 | # We need a pointer back to the shell for various tasks. |
@@ -9,9 +9,9 b' from __future__ import print_function' | |||
|
9 | 9 | import os |
|
10 | 10 | import sqlite3 |
|
11 | 11 | |
|
12 |
from |
|
|
12 | from traitlets.config.application import Application | |
|
13 | 13 | from IPython.core.application import BaseIPythonApplication |
|
14 |
from |
|
|
14 | from traitlets import Bool, Int, Dict | |
|
15 | 15 | from IPython.utils.io import ask_yes_no |
|
16 | 16 | |
|
17 | 17 | trim_hist_help = """Trim the IPython history database to the last 1000 entries. |
@@ -29,7 +29,7 b' from io import open as io_open' | |||
|
29 | 29 | |
|
30 | 30 | from pickleshare import PickleShareDB |
|
31 | 31 | |
|
32 |
from |
|
|
32 | from traitlets.config.configurable import SingletonConfigurable | |
|
33 | 33 | from IPython.core import debugger, oinspect |
|
34 | 34 | from IPython.core import magic |
|
35 | 35 | from IPython.core import page |
@@ -64,7 +64,8 b' from IPython.utils import openpy' | |||
|
64 | 64 | from IPython.utils.decorators import undoc |
|
65 | 65 | from IPython.utils.io import ask_yes_no |
|
66 | 66 | from IPython.utils.ipstruct import Struct |
|
67 | from IPython.utils.path import get_home_dir, get_ipython_dir, get_py_filename, unquote_filename, ensure_dir_exists | |
|
67 | from IPython.paths import get_ipython_dir | |
|
68 | from IPython.utils.path import get_home_dir, get_py_filename, unquote_filename, ensure_dir_exists | |
|
68 | 69 | from IPython.utils.process import system, getoutput |
|
69 | 70 | from IPython.utils.py3compat import (builtin_mod, unicode_type, string_types, |
|
70 | 71 | with_metaclass, iteritems) |
@@ -72,7 +73,7 b' from IPython.utils.strdispatch import StrDispatch' | |||
|
72 | 73 | from IPython.utils.syspathcontext import prepended_to_syspath |
|
73 | 74 | from IPython.utils.text import (format_screen, LSString, SList, |
|
74 | 75 | DollarFormatter) |
|
75 |
from |
|
|
76 | from traitlets import (Integer, Bool, CBool, CaselessStrEnum, Enum, | |
|
76 | 77 | List, Dict, Unicode, Instance, Type) |
|
77 | 78 | from IPython.utils.warn import warn, error |
|
78 | 79 | import IPython.core.hooks |
@@ -2688,7 +2689,7 b' class InteractiveShell(SingletonConfigurable):' | |||
|
2688 | 2689 | def get_cells(): |
|
2689 | 2690 | """generator for sequence of code blocks to run""" |
|
2690 | 2691 | if fname.endswith('.ipynb'): |
|
2691 |
from |
|
|
2692 | from jupyter_nbformat import read | |
|
2692 | 2693 | with io_open(fname) as f: |
|
2693 | 2694 | nb = read(f, as_version=4) |
|
2694 | 2695 | if not nb.cells: |
@@ -23,7 +23,7 b' import types' | |||
|
23 | 23 | from getopt import getopt, GetoptError |
|
24 | 24 | |
|
25 | 25 | # Our own |
|
26 |
from |
|
|
26 | from traitlets.config.configurable import Configurable | |
|
27 | 27 | from IPython.core import oinspect |
|
28 | 28 | from IPython.core.error import UsageError |
|
29 | 29 | from IPython.core.inputsplitter import ESC_MAGIC, ESC_MAGIC2 |
@@ -32,7 +32,7 b' from IPython.utils.ipstruct import Struct' | |||
|
32 | 32 | from IPython.utils.process import arg_split |
|
33 | 33 | from IPython.utils.py3compat import string_types, iteritems |
|
34 | 34 | from IPython.utils.text import dedent |
|
35 |
from |
|
|
35 | from traitlets import Bool, Dict, Instance, MetaHasTraits | |
|
36 | 36 | from IPython.utils.warn import error |
|
37 | 37 | |
|
38 | 38 | #----------------------------------------------------------------------------- |
@@ -596,7 +596,7 b' Defaulting color scheme to \'NoColor\'"""' | |||
|
596 | 596 | """ |
|
597 | 597 | args = magic_arguments.parse_argstring(self.notebook, s) |
|
598 | 598 | |
|
599 |
from |
|
|
599 | from jupyter_nbformat import write, v4 | |
|
600 | 600 | args.filename = unquote_filename(args.filename) |
|
601 | 601 | if args.export: |
|
602 | 602 | cells = [] |
@@ -106,7 +106,7 b' class ConfigMagics(Magics):' | |||
|
106 | 106 | In [5]: %config IPCompleter.greedy = feeling_greedy |
|
107 | 107 | |
|
108 | 108 | """ |
|
109 |
from |
|
|
109 | from traitlets.config.loader import Config | |
|
110 | 110 | # some IPython objects are Configurable, but do not yet have |
|
111 | 111 | # any configurable traits. Exclude them from the effects of |
|
112 | 112 | # this magic, as their presence is just noise: |
@@ -14,7 +14,7 b' from __future__ import print_function' | |||
|
14 | 14 | #----------------------------------------------------------------------------- |
|
15 | 15 | |
|
16 | 16 | # Our own packages |
|
17 |
from |
|
|
17 | from traitlets.config.application import Application | |
|
18 | 18 | from IPython.core import magic_arguments |
|
19 | 19 | from IPython.core.magic import Magics, magics_class, line_magic |
|
20 | 20 | from IPython.testing.skipdoctest import skip_doctest |
@@ -22,7 +22,7 b' from subprocess import Popen, PIPE' | |||
|
22 | 22 | import atexit |
|
23 | 23 | |
|
24 | 24 | # Our own packages |
|
25 |
from |
|
|
25 | from traitlets.config.configurable import Configurable | |
|
26 | 26 | from IPython.core import magic_arguments |
|
27 | 27 | from IPython.core.magic import ( |
|
28 | 28 | Magics, magics_class, line_magic, cell_magic |
@@ -30,7 +30,7 b' from IPython.core.magic import (' | |||
|
30 | 30 | from IPython.lib.backgroundjobs import BackgroundJobManager |
|
31 | 31 | from IPython.utils import py3compat |
|
32 | 32 | from IPython.utils.process import arg_split |
|
33 |
from |
|
|
33 | from traitlets import List, Dict | |
|
34 | 34 | |
|
35 | 35 | #----------------------------------------------------------------------------- |
|
36 | 36 | # Magic implementation classes |
@@ -18,8 +18,8 b' Authors:' | |||
|
18 | 18 | # Imports |
|
19 | 19 | #----------------------------------------------------------------------------- |
|
20 | 20 | |
|
21 |
from |
|
|
22 |
from |
|
|
21 | from traitlets.config.configurable import Configurable | |
|
22 | from traitlets import List | |
|
23 | 23 | |
|
24 | 24 | #----------------------------------------------------------------------------- |
|
25 | 25 | # Main payload class |
@@ -28,7 +28,7 b' from keyword import iskeyword' | |||
|
28 | 28 | import re |
|
29 | 29 | |
|
30 | 30 | from IPython.core.autocall import IPyAutocall |
|
31 |
from |
|
|
31 | from traitlets.config.configurable import Configurable | |
|
32 | 32 | from IPython.core.inputsplitter import ( |
|
33 | 33 | ESC_MAGIC, |
|
34 | 34 | ESC_QUOTE, |
@@ -38,7 +38,7 b' from IPython.core.inputsplitter import (' | |||
|
38 | 38 | from IPython.core.macro import Macro |
|
39 | 39 | from IPython.core.splitinput import LineInfo |
|
40 | 40 | |
|
41 |
from |
|
|
41 | from traitlets import ( | |
|
42 | 42 | List, Integer, Unicode, CBool, Bool, Instance, CRegExp |
|
43 | 43 | ) |
|
44 | 44 |
@@ -24,15 +24,15 b' from __future__ import print_function' | |||
|
24 | 24 | |
|
25 | 25 | import os |
|
26 | 26 | |
|
27 |
from |
|
|
27 | from traitlets.config.application import Application | |
|
28 | 28 | from IPython.core.application import ( |
|
29 | 29 | BaseIPythonApplication, base_flags |
|
30 | 30 | ) |
|
31 | 31 | from IPython.core.profiledir import ProfileDir |
|
32 | 32 | from IPython.utils.importstring import import_item |
|
33 |
from IPython. |
|
|
33 | from IPython.paths import get_ipython_dir, get_ipython_package_dir | |
|
34 | 34 | from IPython.utils import py3compat |
|
35 |
from |
|
|
35 | from traitlets import Unicode, Bool, Dict | |
|
36 | 36 | |
|
37 | 37 | #----------------------------------------------------------------------------- |
|
38 | 38 | # Constants |
@@ -261,25 +261,19 b' class ProfileCreate(BaseIPythonApplication):' | |||
|
261 | 261 | from IPython.terminal.ipapp import TerminalIPythonApp |
|
262 | 262 | apps = [TerminalIPythonApp] |
|
263 | 263 | for app_path in ( |
|
264 |
' |
|
|
265 | 'IPython.terminal.console.app.ZMQTerminalIPythonApp', | |
|
266 | 'IPython.qt.console.qtconsoleapp.IPythonQtConsoleApp', | |
|
267 | 'IPython.html.notebookapp.NotebookApp', | |
|
268 | 'IPython.nbconvert.nbconvertapp.NbConvertApp', | |
|
264 | 'ipython_kernel.kernelapp.IPKernelApp', | |
|
269 | 265 | ): |
|
270 | 266 | app = self._import_app(app_path) |
|
271 | 267 | if app is not None: |
|
272 | 268 | apps.append(app) |
|
273 | 269 | if self.parallel: |
|
274 |
from |
|
|
275 |
from |
|
|
276 |
from |
|
|
277 | from IPython.parallel.apps.iploggerapp import IPLoggerApp | |
|
270 | from ipython_parallel.apps.ipcontrollerapp import IPControllerApp | |
|
271 | from ipython_parallel.apps.ipengineapp import IPEngineApp | |
|
272 | from ipython_parallel.apps.ipclusterapp import IPClusterStart | |
|
278 | 273 | apps.extend([ |
|
279 | 274 | IPControllerApp, |
|
280 | 275 | IPEngineApp, |
|
281 | 276 | IPClusterStart, |
|
282 | IPLoggerApp, | |
|
283 | 277 | ]) |
|
284 | 278 | for App in apps: |
|
285 | 279 | app = App() |
@@ -8,10 +8,11 b' import os' | |||
|
8 | 8 | import shutil |
|
9 | 9 | import errno |
|
10 | 10 | |
|
11 |
from |
|
|
12 |
from IPython. |
|
|
11 | from traitlets.config.configurable import LoggingConfigurable | |
|
12 | from IPython.paths import get_ipython_package_dir | |
|
13 | from IPython.utils.path import expand_path, ensure_dir_exists | |
|
13 | 14 | from IPython.utils import py3compat |
|
14 |
from |
|
|
15 | from traitlets import Unicode, Bool | |
|
15 | 16 | |
|
16 | 17 | #----------------------------------------------------------------------------- |
|
17 | 18 | # Module errors |
@@ -137,34 +138,16 b' class ProfileDir(LoggingConfigurable):' | |||
|
137 | 138 | def _static_dir_changed(self, name, old, new): |
|
138 | 139 | self.check_startup_dir() |
|
139 | 140 | |
|
140 | def check_static_dir(self): | |
|
141 | self._mkdir(self.static_dir) | |
|
142 | custom = os.path.join(self.static_dir, 'custom') | |
|
143 | self._mkdir(custom) | |
|
144 | try: | |
|
145 | from jupyter_notebook import DEFAULT_STATIC_FILES_PATH | |
|
146 | except ImportError: | |
|
147 | return | |
|
148 | for fname in ('custom.js', 'custom.css'): | |
|
149 | src = os.path.join(DEFAULT_STATIC_FILES_PATH, 'custom', fname) | |
|
150 | dest = os.path.join(custom, fname) | |
|
151 | if not os.path.exists(src): | |
|
152 | self.log.warn("Could not copy default file to static dir. Source file %s does not exist.", src) | |
|
153 | continue | |
|
154 | if not os.path.exists(dest): | |
|
155 | shutil.copy(src, dest) | |
|
156 | ||
|
157 | 141 | def check_dirs(self): |
|
158 | 142 | self.check_security_dir() |
|
159 | 143 | self.check_log_dir() |
|
160 | 144 | self.check_pid_dir() |
|
161 | 145 | self.check_startup_dir() |
|
162 | self.check_static_dir() | |
|
163 | 146 | |
|
164 | 147 | def copy_config_file(self, config_file, path=None, overwrite=False): |
|
165 | 148 | """Copy a default config file into the active profile directory. |
|
166 | 149 | |
|
167 |
Default configuration files are kept in :mod:`IPython.co |
|
|
150 | Default configuration files are kept in :mod:`IPython.core.profile`. | |
|
168 | 151 | This function moves these from that location to the working profile |
|
169 | 152 | directory. |
|
170 | 153 | """ |
@@ -28,10 +28,10 b' import time' | |||
|
28 | 28 | |
|
29 | 29 | from string import Formatter |
|
30 | 30 | |
|
31 |
from |
|
|
31 | from traitlets.config.configurable import Configurable | |
|
32 | 32 | from IPython.core import release |
|
33 | 33 | from IPython.utils import coloransi, py3compat |
|
34 |
from |
|
|
34 | from traitlets import (Unicode, Instance, Dict, Bool, Int) | |
|
35 | 35 | |
|
36 | 36 | #----------------------------------------------------------------------------- |
|
37 | 37 | # Color schemes for prompts |
@@ -23,7 +23,7 b" backends = {'tk': 'TkAgg'," | |||
|
23 | 23 | 'osx': 'MacOSX', |
|
24 | 24 | 'nbagg': 'nbAgg', |
|
25 | 25 | 'notebook': 'nbAgg', |
|
26 |
'inline' : 'module:// |
|
|
26 | 'inline' : 'module://ipython_kernel.pylab.backend_inline'} | |
|
27 | 27 | |
|
28 | 28 | # We also need a reverse backends2guis mapping that will properly choose which |
|
29 | 29 | # GUI support to activate based on the desired matplotlib backend. For the |
@@ -182,7 +182,7 b' def select_figure_formats(shell, formats, **kwargs):' | |||
|
182 | 182 | Extra keyword arguments to be passed to fig.canvas.print_figure. |
|
183 | 183 | """ |
|
184 | 184 | from matplotlib.figure import Figure |
|
185 |
from |
|
|
185 | from ipython_kernel.pylab import backend_inline | |
|
186 | 186 | |
|
187 | 187 | svg_formatter = shell.display_formatter.formatters['image/svg+xml'] |
|
188 | 188 | png_formatter = shell.display_formatter.formatters['image/png'] |
@@ -233,7 +233,7 b' def find_gui_and_backend(gui=None, gui_select=None):' | |||
|
233 | 233 | Returns |
|
234 | 234 | ------- |
|
235 | 235 | A tuple of (gui, backend) where backend is one of ('TkAgg','GTKAgg', |
|
236 |
'WXAgg','Qt4Agg','module:// |
|
|
236 | 'WXAgg','Qt4Agg','module://ipython_kernel.pylab.backend_inline'). | |
|
237 | 237 | """ |
|
238 | 238 | |
|
239 | 239 | import matplotlib |
@@ -334,7 +334,7 b' def configure_inline_support(shell, backend):' | |||
|
334 | 334 | # continuing (such as in terminal-only shells in environments without |
|
335 | 335 | # zeromq available). |
|
336 | 336 | try: |
|
337 |
from |
|
|
337 | from ipython_kernel.pylab.backend_inline import InlineBackend | |
|
338 | 338 | except ImportError: |
|
339 | 339 | return |
|
340 | 340 | from matplotlib import pyplot |
@@ -345,7 +345,7 b' def configure_inline_support(shell, backend):' | |||
|
345 | 345 | shell.configurables.append(cfg) |
|
346 | 346 | |
|
347 | 347 | if backend == backends['inline']: |
|
348 |
from |
|
|
348 | from ipython_kernel.pylab.backend_inline import flush_figures | |
|
349 | 349 | shell.events.register('post_execute', flush_figures) |
|
350 | 350 | |
|
351 | 351 | # Save rcParams that will be overwrittern |
@@ -355,7 +355,7 b' def configure_inline_support(shell, backend):' | |||
|
355 | 355 | # load inline_rc |
|
356 | 356 | pyplot.rcParams.update(cfg.rc) |
|
357 | 357 | else: |
|
358 |
from |
|
|
358 | from ipython_kernel.pylab.backend_inline import flush_figures | |
|
359 | 359 | try: |
|
360 | 360 | shell.events.unregister('post_execute', flush_figures) |
|
361 | 361 | except ValueError: |
@@ -14,14 +14,14 b' import glob' | |||
|
14 | 14 | import os |
|
15 | 15 | import sys |
|
16 | 16 | |
|
17 |
from |
|
|
18 |
from |
|
|
19 |
from |
|
|
17 | from traitlets.config.application import boolean_flag | |
|
18 | from traitlets.config.configurable import Configurable | |
|
19 | from traitlets.config.loader import Config | |
|
20 | 20 | from IPython.core import pylabtools |
|
21 | 21 | from IPython.utils import py3compat |
|
22 | 22 | from IPython.utils.contexts import preserve_keys |
|
23 | 23 | from IPython.utils.path import filefind |
|
24 |
from |
|
|
24 | from traitlets import ( | |
|
25 | 25 | Unicode, Instance, List, Bool, CaselessStrEnum |
|
26 | 26 | ) |
|
27 | 27 | from IPython.lib.inputhook import guis |
@@ -12,7 +12,7 b' from contextlib import contextmanager' | |||
|
12 | 12 | |
|
13 | 13 | import nose.tools as nt |
|
14 | 14 | |
|
15 |
from |
|
|
15 | from traitlets.config.loader import Config | |
|
16 | 16 | from IPython.core import completer |
|
17 | 17 | from IPython.external.decorators import knownfailureif |
|
18 | 18 | from IPython.utils.tempdir import TemporaryDirectory, TemporaryWorkingDirectory |
@@ -9,7 +9,7 b' import nose.tools as nt' | |||
|
9 | 9 | |
|
10 | 10 | from IPython.core import display |
|
11 | 11 | from IPython.core.getipython import get_ipython |
|
12 |
from IPython |
|
|
12 | from IPython import paths as ipath | |
|
13 | 13 | |
|
14 | 14 | import IPython.testing.decorators as dec |
|
15 | 15 | |
@@ -60,7 +60,7 b' def test_image_filename_defaults():' | |||
|
60 | 60 | nt.assert_is_none(img._repr_jpeg_()) |
|
61 | 61 | |
|
62 | 62 | def _get_inline_config(): |
|
63 |
from |
|
|
63 | from ipython_kernel.pylab.config import InlineBackend | |
|
64 | 64 | return InlineBackend.instance() |
|
65 | 65 | |
|
66 | 66 | @dec.skip_without('matplotlib') |
@@ -10,7 +10,7 b' except:' | |||
|
10 | 10 | import nose.tools as nt |
|
11 | 11 | |
|
12 | 12 | from IPython import get_ipython |
|
13 |
from |
|
|
13 | from traitlets.config import Config | |
|
14 | 14 | from IPython.core.formatters import ( |
|
15 | 15 | PlainTextFormatter, HTMLFormatter, PDFFormatter, _mod_name_key, |
|
16 | 16 | DisplayFormatter, JSONFormatter, |
@@ -16,7 +16,7 b' from datetime import datetime' | |||
|
16 | 16 | import nose.tools as nt |
|
17 | 17 | |
|
18 | 18 | # our own packages |
|
19 |
from |
|
|
19 | from traitlets.config.loader import Config | |
|
20 | 20 | from IPython.utils.tempdir import TemporaryDirectory |
|
21 | 21 | from IPython.core.history import HistoryManager, extract_hist_ranges |
|
22 | 22 | from IPython.utils import py3compat |
@@ -607,8 +607,8 b' class TestModules(unittest.TestCase, tt.TempFileMixin):' | |||
|
607 | 607 | """ |
|
608 | 608 | self.mktmp("import sys\n" |
|
609 | 609 | "print('numpy' in sys.modules)\n" |
|
610 |
"print(' |
|
|
611 |
"print(' |
|
|
610 | "print('ipython_parallel' in sys.modules)\n" | |
|
611 | "print('ipython_kernel' in sys.modules)\n" | |
|
612 | 612 | ) |
|
613 | 613 | out = "False\nFalse\nFalse\n" |
|
614 | 614 | tt.ipexec_validate(self.fname, out) |
@@ -28,7 +28,7 b' import inspect, os, sys, textwrap' | |||
|
28 | 28 | # Our own |
|
29 | 29 | from IPython.core.error import UsageError |
|
30 | 30 | from IPython.core.magic import Magics, magics_class, line_magic |
|
31 |
from |
|
|
31 | from traitlets import Bool | |
|
32 | 32 | from IPython.utils.py3compat import string_types |
|
33 | 33 | |
|
34 | 34 | #----------------------------------------------------------------------------- |
@@ -1,6 +1,6 b'' | |||
|
1 | 1 | import tempfile, os |
|
2 | 2 | |
|
3 |
from |
|
|
3 | from traitlets.config.loader import Config | |
|
4 | 4 | import nose.tools as nt |
|
5 | 5 | |
|
6 | 6 | ip = get_ipython() |
@@ -60,7 +60,7 b' import sys' | |||
|
60 | 60 | import tarfile |
|
61 | 61 | import zipfile |
|
62 | 62 | |
|
63 |
from IPython. |
|
|
63 | from IPython.paths import get_ipython_dir | |
|
64 | 64 | |
|
65 | 65 | try: |
|
66 | 66 | from urllib.request import urlopen # Py 3 |
@@ -8,5 +8,5 b' warnings.warn("IPython.lib.kernel moved to IPython.kernel.connect in IPython 1.0' | |||
|
8 | 8 | DeprecationWarning |
|
9 | 9 | ) |
|
10 | 10 | |
|
11 |
from |
|
|
11 | from ipython_kernel.connect import * | |
|
12 | 12 |
@@ -12,9 +12,9 b' import shutil' | |||
|
12 | 12 | import subprocess |
|
13 | 13 | |
|
14 | 14 | from IPython.utils.process import find_cmd, FindCmdError |
|
15 |
from |
|
|
16 |
from |
|
|
17 |
from |
|
|
15 | from traitlets.config import get_config | |
|
16 | from traitlets.config.configurable import SingletonConfigurable | |
|
17 | from traitlets import List, Bool, Unicode | |
|
18 | 18 | from IPython.utils.py3compat import cast_unicode, cast_unicode_py2 as u |
|
19 | 19 | |
|
20 | 20 |
@@ -18,7 +18,7 b' from IPython.core.interactiveshell import InteractiveShell' | |||
|
18 | 18 | from IPython.terminal.interactiveshell import TerminalInteractiveShell |
|
19 | 19 | from IPython.terminal.ipapp import load_default_config |
|
20 | 20 | |
|
21 |
from |
|
|
21 | from traitlets import Bool, CBool, Unicode | |
|
22 | 22 | from IPython.utils.io import ask_yes_no |
|
23 | 23 | |
|
24 | 24 |
@@ -31,7 +31,7 b' from IPython.utils.terminal import toggle_set_term_title, set_term_title' | |||
|
31 | 31 | from IPython.utils.process import abbrev_cwd |
|
32 | 32 | from IPython.utils.warn import warn, error |
|
33 | 33 | from IPython.utils.text import num_ini_spaces, SList, strip_email_quotes |
|
34 |
from |
|
|
34 | from traitlets import Integer, CBool, Unicode | |
|
35 | 35 | |
|
36 | 36 | #----------------------------------------------------------------------------- |
|
37 | 37 | # Utilities |
@@ -15,8 +15,8 b' import logging' | |||
|
15 | 15 | import os |
|
16 | 16 | import sys |
|
17 | 17 | |
|
18 |
from |
|
|
19 |
from |
|
|
18 | from traitlets.config.loader import Config | |
|
19 | from traitlets.config.application import boolean_flag, catch_config_error, Application | |
|
20 | 20 | from IPython.core import release |
|
21 | 21 | from IPython.core import usage |
|
22 | 22 | from IPython.core.completer import IPCompleter |
@@ -34,8 +34,8 b' from IPython.core.shellapp import (' | |||
|
34 | 34 | from IPython.extensions.storemagic import StoreMagics |
|
35 | 35 | from IPython.terminal.interactiveshell import TerminalInteractiveShell |
|
36 | 36 | from IPython.utils import warn |
|
37 |
from IPython. |
|
|
38 |
from |
|
|
37 | from IPython.paths import get_ipython_dir | |
|
38 | from traitlets import ( | |
|
39 | 39 | Bool, List, Dict, |
|
40 | 40 | ) |
|
41 | 41 | |
@@ -207,20 +207,20 b' class TerminalIPythonApp(BaseIPythonApplication, InteractiveShellApp):' | |||
|
207 | 207 | ] |
|
208 | 208 | |
|
209 | 209 | subcommands = dict( |
|
210 |
qtconsole=(' |
|
|
211 |
"""Launch the |
|
|
210 | qtconsole=('jupyter_qtconsole.console.qtconsoleapp.IPythonQtConsoleApp', | |
|
211 | """DEPRECATD: Launch the Jupyter Qt Console.""" | |
|
212 | 212 | ), |
|
213 |
notebook=(' |
|
|
214 | """Launch the IPython HTML Notebook Server.""" | |
|
213 | notebook=('jupyter_notebook.notebookapp.NotebookApp', | |
|
214 | """DEPRECATED: Launch the IPython HTML Notebook Server.""" | |
|
215 | 215 | ), |
|
216 | 216 | profile = ("IPython.core.profileapp.ProfileApp", |
|
217 | 217 | "Create and manage IPython profiles." |
|
218 | 218 | ), |
|
219 |
kernel = (" |
|
|
219 | kernel = ("ipython_kernel.kernelapp.IPKernelApp", | |
|
220 | 220 | "Start a kernel without an attached frontend." |
|
221 | 221 | ), |
|
222 |
console=(' |
|
|
223 |
"""Launch the |
|
|
222 | console=('jupyter_console.app.ZMQTerminalIPythonApp', | |
|
223 | """DEPRECATED: Launch the Jupyter terminal-based Console.""" | |
|
224 | 224 | ), |
|
225 | 225 | locate=('IPython.terminal.ipapp.LocateIPythonApp', |
|
226 | 226 | LocateIPythonApp.description |
@@ -228,19 +228,19 b' class TerminalIPythonApp(BaseIPythonApplication, InteractiveShellApp):' | |||
|
228 | 228 | history=('IPython.core.historyapp.HistoryApp', |
|
229 | 229 | "Manage the IPython history database." |
|
230 | 230 | ), |
|
231 |
nbconvert=(' |
|
|
232 | "Convert notebooks to/from other formats." | |
|
231 | nbconvert=('jupyter_nbconvert.nbconvertapp.NbConvertApp', | |
|
232 | "DEPRECATED: Convert notebooks to/from other formats." | |
|
233 | 233 | ), |
|
234 |
trust=(' |
|
|
235 | "Sign notebooks to trust their potentially unsafe contents at load." | |
|
234 | trust=('jupyter_nbformat.sign.TrustNotebookApp', | |
|
235 | "DEPRECATED: Sign notebooks to trust their potentially unsafe contents at load." | |
|
236 | 236 | ), |
|
237 |
kernelspec=(' |
|
|
238 |
"Manage |
|
|
237 | kernelspec=('jupyter_client.kernelspecapp.KernelSpecApp', | |
|
238 | "DEPRECATED: Manage Jupyter kernel specifications." | |
|
239 | 239 | ), |
|
240 | 240 | ) |
|
241 | 241 | subcommands['install-nbextension'] = ( |
|
242 |
" |
|
|
243 |
"Install |
|
|
242 | "jupyter_notebook.nbextensions.NBExtensionApp", | |
|
243 | "DEPRECATED: Install Jupyter notebook extension files" | |
|
244 | 244 | ) |
|
245 | 245 | |
|
246 | 246 | # *do* autocreate requested profile, but don't create the config file. |
@@ -209,7 +209,7 b" test_group_names.append('autoreload')" | |||
|
209 | 209 | #----------------------------------------------------------------------------- |
|
210 | 210 | |
|
211 | 211 | def check_exclusions_exist(): |
|
212 |
from IPython. |
|
|
212 | from IPython.paths import get_ipython_package_dir | |
|
213 | 213 | from IPython.utils.warn import warn |
|
214 | 214 | parent = os.path.dirname(get_ipython_package_dir()) |
|
215 | 215 | for sec in test_sections: |
@@ -165,16 +165,6 b' class PyTestController(TestController):' | |||
|
165 | 165 | ipydir = TemporaryDirectory() |
|
166 | 166 | self.dirs.append(ipydir) |
|
167 | 167 | self.env['IPYTHONDIR'] = ipydir.name |
|
168 | # FIXME: install IPython kernel in temporary IPython dir | |
|
169 | # remove after big split | |
|
170 | try: | |
|
171 | from jupyter_client.kernelspec import KernelSpecManager | |
|
172 | except ImportError: | |
|
173 | pass | |
|
174 | else: | |
|
175 | ksm = KernelSpecManager(ipython_dir=ipydir.name) | |
|
176 | ksm.install_native_kernel_spec(user=True) | |
|
177 | ||
|
178 | 168 | self.workingdir = workingdir = TemporaryDirectory() |
|
179 | 169 | self.dirs.append(workingdir) |
|
180 | 170 | self.env['IPTEST_WORKING_DIR'] = workingdir.name |
@@ -36,7 +36,7 b' try:' | |||
|
36 | 36 | except ImportError: |
|
37 | 37 | has_nose = False |
|
38 | 38 | |
|
39 |
from |
|
|
39 | from traitlets.config.loader import Config | |
|
40 | 40 | from IPython.utils.process import get_output_error_code |
|
41 | 41 | from IPython.utils.text import list_strings |
|
42 | 42 | from IPython.utils.io import temp_pyfile, Tee |
@@ -213,9 +213,9 b" def temp_pyfile(src, ext='.py'):" | |||
|
213 | 213 | return fname, f |
|
214 | 214 | |
|
215 | 215 | def atomic_writing(*args, **kwargs): |
|
216 |
"""DEPRECATED: moved to |
|
|
217 |
warn("IPython.utils.io.atomic_writing has moved to |
|
|
218 |
from |
|
|
216 | """DEPRECATED: moved to jupyter_notebook.services.contents.fileio""" | |
|
217 | warn("IPython.utils.io.atomic_writing has moved to jupyter_notebook.services.contents.fileio") | |
|
218 | from jupyter_notebook.services.contents.fileio import atomic_writing | |
|
219 | 219 | return atomic_writing(*args, **kwargs) |
|
220 | 220 | |
|
221 | 221 | def raw_print(*args, **kw): |
@@ -25,6 +25,7 b' import nose.tools as nt' | |||
|
25 | 25 | from nose import with_setup |
|
26 | 26 | |
|
27 | 27 | import IPython |
|
28 | from IPython import paths | |
|
28 | 29 | from IPython.testing import decorators as dec |
|
29 | 30 | from IPython.testing.decorators import (skip_if_not_win32, skip_win32, |
|
30 | 31 | onlyif_unicode_paths,) |
@@ -253,7 +254,7 b' def test_filefind():' | |||
|
253 | 254 | """Various tests for filefind""" |
|
254 | 255 | f = tempfile.NamedTemporaryFile() |
|
255 | 256 | # print 'fname:',f.name |
|
256 | alt_dirs = path.get_ipython_dir() | |
|
257 | alt_dirs = paths.get_ipython_dir() | |
|
257 | 258 | t = path.filefind(f.name, alt_dirs) |
|
258 | 259 | # print 'found:',t |
|
259 | 260 | |
@@ -298,7 +299,7 b' def test_not_writable_ipdir():' | |||
|
298 | 299 | # assume I'm root and skip the test |
|
299 | 300 | raise SkipTest("I can't create directories that I can't write to") |
|
300 | 301 | with AssertPrints('is not a writable location', channel='stderr'): |
|
301 | ipdir = path.get_ipython_dir() | |
|
302 | ipdir = paths.get_ipython_dir() | |
|
302 | 303 | env.pop('IPYTHON_DIR', None) |
|
303 | 304 | |
|
304 | 305 | def test_unquote_filename(): |
@@ -37,7 +37,7 b' no error.' | |||
|
37 | 37 | |
|
38 | 38 | To add to a collection which may have already been defined elsewhere, |
|
39 | 39 | you can use methods like those found on lists, dicts and sets: append, |
|
40 |
extend, :meth:`~ |
|
|
40 | extend, :meth:`~traitlets.config.loader.LazyConfigValue.prepend` (like | |
|
41 | 41 | extend, but at the front), add and update (which works both for dicts |
|
42 | 42 | and sets):: |
|
43 | 43 |
@@ -12,7 +12,7 b' The main concepts' | |||
|
12 | 12 | There are a number of abstractions that the IPython configuration system uses. |
|
13 | 13 | Each of these abstractions is represented by a Python class. |
|
14 | 14 | |
|
15 |
Configuration object: :class:`~ |
|
|
15 | Configuration object: :class:`~traitlets.config.loader.Config` | |
|
16 | 16 | A configuration object is a simple dictionary-like class that holds |
|
17 | 17 | configuration attributes and sub-configuration objects. These classes |
|
18 | 18 | support dotted attribute style access (``cfg.Foo.bar``) in addition to the |
@@ -20,7 +20,7 b' Configuration object: :class:`~IPython.config.loader.Config`' | |||
|
20 | 20 | The Config object is a wrapper around a simple dictionary with some convenience methods, |
|
21 | 21 | such as merging and automatic section creation. |
|
22 | 22 | |
|
23 |
Application: :class:`~ |
|
|
23 | Application: :class:`~traitlets.config.application.Application` | |
|
24 | 24 | An application is a process that does a specific job. The most obvious |
|
25 | 25 | application is the :command:`ipython` command line program. Each |
|
26 | 26 | application reads *one or more* configuration files and a single set of |
@@ -34,30 +34,30 b' Application: :class:`~IPython.config.application.Application`' | |||
|
34 | 34 | Applications always have a `log` attribute that is a configured Logger. |
|
35 | 35 | This allows centralized logging configuration per-application. |
|
36 | 36 | |
|
37 |
Configurable: :class:`~ |
|
|
37 | Configurable: :class:`~traitlets.config.configurable.Configurable` | |
|
38 | 38 | A configurable is a regular Python class that serves as a base class for |
|
39 | 39 | all main classes in an application. The |
|
40 |
:class:`~ |
|
|
40 | :class:`~traitlets.config.configurable.Configurable` base class is | |
|
41 | 41 | lightweight and only does one things. |
|
42 | 42 | |
|
43 |
This :class:`~ |
|
|
44 |
of :class:`~ |
|
|
43 | This :class:`~traitlets.config.configurable.Configurable` is a subclass | |
|
44 | of :class:`~traitlets.HasTraits` that knows how to configure | |
|
45 | 45 | itself. Class level traits with the metadata ``config=True`` become |
|
46 | 46 | values that can be configured from the command line and configuration |
|
47 | 47 | files. |
|
48 | 48 | |
|
49 |
Developers create :class:`~ |
|
|
49 | Developers create :class:`~traitlets.config.configurable.Configurable` | |
|
50 | 50 | subclasses that implement all of the logic in the application. Each of |
|
51 | 51 | these subclasses has its own configuration information that controls how |
|
52 | 52 | instances are created. |
|
53 | 53 | |
|
54 |
Singletons: :class:`~ |
|
|
54 | Singletons: :class:`~traitlets.config.configurable.SingletonConfigurable` | |
|
55 | 55 | Any object for which there is a single canonical instance. These are |
|
56 | 56 | just like Configurables, except they have a class method |
|
57 |
:meth:`~ |
|
|
57 | :meth:`~traitlets.config.configurable.SingletonConfigurable.instance`, | |
|
58 | 58 | that returns the current active instance (or creates one if it |
|
59 | 59 | does not exist). Examples of singletons include |
|
60 |
:class:`~ |
|
|
60 | :class:`~traitlets.config.application.Application`s and | |
|
61 | 61 | :class:`~IPython.core.interactiveshell.InteractiveShell`. This lets |
|
62 | 62 | objects easily connect to the current running Application without passing |
|
63 | 63 | objects around everywhere. For instance, to get the current running |
@@ -100,7 +100,7 b' Python configuration Files' | |||
|
100 | 100 | -------------------------- |
|
101 | 101 | |
|
102 | 102 | A Python configuration file is a pure Python file that populates a configuration object. |
|
103 |
This configuration object is a :class:`~ |
|
|
103 | This configuration object is a :class:`~traitlets.config.loader.Config` instance. | |
|
104 | 104 | While in a configuration file, to get a reference to this object, simply call the :func:`get_config` |
|
105 | 105 | function, which is available in the global namespace of the script. |
|
106 | 106 | |
@@ -116,13 +116,13 b' attributes on it. All you have to know is:' | |||
|
116 | 116 | * The type of each attribute. |
|
117 | 117 | |
|
118 | 118 | The answers to these questions are provided by the various |
|
119 |
:class:`~ |
|
|
119 | :class:`~traitlets.config.configurable.Configurable` subclasses that an | |
|
120 | 120 | application uses. Let's look at how this would work for a simple configurable |
|
121 | 121 | subclass:: |
|
122 | 122 | |
|
123 | 123 | # Sample configurable: |
|
124 |
from |
|
|
125 |
from |
|
|
124 | from traitlets.config.configurable import Configurable | |
|
125 | from traitlets import Int, Float, Unicode, Bool | |
|
126 | 126 | |
|
127 | 127 | class MyClass(Configurable): |
|
128 | 128 | name = Unicode(u'defaultname', config=True) |
@@ -145,16 +145,16 b' to configure this class in a configuration file::' | |||
|
145 | 145 | After this configuration file is loaded, the values set in it will override |
|
146 | 146 | the class defaults anytime a :class:`MyClass` is created. Furthermore, |
|
147 | 147 | these attributes will be type checked and validated anytime they are set. |
|
148 |
This type checking is handled by the :mod:` |
|
|
148 | This type checking is handled by the :mod:`traitlets` module, | |
|
149 | 149 | which provides the :class:`Unicode`, :class:`Int` and :class:`Float` types. |
|
150 |
In addition to these traitlets, the :mod:` |
|
|
150 | In addition to these traitlets, the :mod:`traitlets` provides | |
|
151 | 151 | traitlets for a number of other types. |
|
152 | 152 | |
|
153 | 153 | .. note:: |
|
154 | 154 | |
|
155 | 155 | Underneath the hood, the :class:`Configurable` base class is a subclass of |
|
156 |
:class:` |
|
|
157 |
:mod:` |
|
|
156 | :class:`traitlets.HasTraits`. The | |
|
157 | :mod:`traitlets` module is a lightweight version of | |
|
158 | 158 | :mod:`enthought.traits`. Our implementation is a pure Python subset |
|
159 | 159 | (mostly API compatible) of :mod:`enthought.traits` that does not have any |
|
160 | 160 | of the automatic GUI generation capabilities. Our plan is to achieve 100% |
@@ -172,17 +172,17 b' Here, ``ClassName`` is the name of the class whose configuration attribute you' | |||
|
172 | 172 | want to set, ``attribute_name`` is the name of the attribute you want to set |
|
173 | 173 | and ``attribute_value`` the the value you want it to have. The ``ClassName`` |
|
174 | 174 | attribute of ``c`` is not the actual class, but instead is another |
|
175 |
:class:`~ |
|
|
175 | :class:`~traitlets.config.loader.Config` instance. | |
|
176 | 176 | |
|
177 | 177 | .. note:: |
|
178 | 178 | |
|
179 | 179 | The careful reader may wonder how the ``ClassName`` (``MyClass`` in |
|
180 | 180 | the above example) attribute of the configuration object ``c`` gets |
|
181 | 181 | created. These attributes are created on the fly by the |
|
182 |
:class:`~ |
|
|
183 |
convention. Any attribute of a :class:`~ |
|
|
182 | :class:`~traitlets.config.loader.Config` instance, using a simple naming | |
|
183 | convention. Any attribute of a :class:`~traitlets.config.loader.Config` | |
|
184 | 184 | instance whose name begins with an uppercase character is assumed to be a |
|
185 |
sub-configuration and a new empty :class:`~ |
|
|
185 | sub-configuration and a new empty :class:`~traitlets.config.loader.Config` | |
|
186 | 186 | instance is dynamically created for that attribute. This allows deeply |
|
187 | 187 | hierarchical information created easily (``c.Foo.Bar.value``) on the fly. |
|
188 | 188 | |
@@ -190,7 +190,7 b' JSON configuration Files' | |||
|
190 | 190 | ------------------------ |
|
191 | 191 | |
|
192 | 192 | A JSON configuration file is simply a file that contains a |
|
193 |
:class:`~ |
|
|
193 | :class:`~traitlets.config.loader.Config` dictionary serialized to JSON. | |
|
194 | 194 | A JSON configuration file has the same base name as a Python configuration file, |
|
195 | 195 | but with a .json extension. |
|
196 | 196 | |
@@ -261,8 +261,8 b' There is another aspect of configuration where inheritance comes into play.' | |||
|
261 | 261 | Sometimes, your classes will have an inheritance hierarchy that you want |
|
262 | 262 | to be reflected in the configuration system. Here is a simple example:: |
|
263 | 263 | |
|
264 |
from |
|
|
265 |
from |
|
|
264 | from traitlets.config.configurable import Configurable | |
|
265 | from traitlets import Int, Float, Unicode, Bool | |
|
266 | 266 | |
|
267 | 267 | class Foo(Configurable): |
|
268 | 268 | name = Unicode(u'fooname', config=True) |
@@ -438,7 +438,7 b' with a given Application. Configuring IPython from the command-line may look' | |||
|
438 | 438 | very similar to an IPython config file |
|
439 | 439 | |
|
440 | 440 | IPython applications use a parser called |
|
441 |
:class:`~ |
|
|
441 | :class:`~traitlets.config.loader.KeyValueLoader` to load values into a Config | |
|
442 | 442 | object. Values are assigned in much the same way as in a config file: |
|
443 | 443 | |
|
444 | 444 | .. code-block:: bash |
@@ -184,7 +184,7 b' not work with this. Instead, we do this::' | |||
|
184 | 184 | ... |
|
185 | 185 | |
|
186 | 186 | This gives the new class a metaclass of :class:`~IPython.qt.util.MetaQObjectHasTraits`, |
|
187 |
and the parent classes :class:`~ |
|
|
187 | and the parent classes :class:`~traitlets.HasTraits` and | |
|
188 | 188 | :class:`~IPython.qt.util.SuperQObject`. |
|
189 | 189 | |
|
190 | 190 |
@@ -268,11 +268,11 b' As of this release, a signifiant portion of IPython has been refactored. This' | |||
|
268 | 268 | refactoring is founded on a number of new abstractions. The main new classes |
|
269 | 269 | that implement these abstractions are: |
|
270 | 270 | |
|
271 |
* :class:` |
|
|
272 |
* :class:` |
|
|
273 |
* :class:` |
|
|
274 |
* :class:` |
|
|
275 |
* :class:` |
|
|
271 | * :class:`traitlets.HasTraits`. | |
|
272 | * :class:`traitlets.config.configurable.Configurable`. | |
|
273 | * :class:`traitlets.config.application.Application`. | |
|
274 | * :class:`traitlets.config.loader.ConfigLoader`. | |
|
275 | * :class:`traitlets.config.loader.Config` | |
|
276 | 276 | |
|
277 | 277 | We are still in the process of writing developer focused documentation about |
|
278 | 278 | these classes, but for now our :ref:`configuration documentation |
@@ -383,7 +383,7 b' Additional new features' | |||
|
383 | 383 | |
|
384 | 384 | .. sourcecode:: python |
|
385 | 385 | |
|
386 |
from |
|
|
386 | from traitlets.config.application import Application | |
|
387 | 387 | logger = Application.instance().log |
|
388 | 388 | |
|
389 | 389 | * You can now get help on an object halfway through typing a command. For |
@@ -403,7 +403,7 b' Additional new features' | |||
|
403 | 403 | configuration system :ref:`documentation <config_index>` for more details. |
|
404 | 404 | |
|
405 | 405 | * The :class:`~IPython.core.interactiveshell.InteractiveShell` class is now a |
|
406 |
:class:`~ |
|
|
406 | :class:`~traitlets.config.configurable.Configurable` subclass and has traitlets | |
|
407 | 407 | that determine the defaults and runtime environment. The ``__init__`` method |
|
408 | 408 | has also been refactored so this class can be instantiated and run without |
|
409 | 409 | the old :mod:`ipmaker` module. |
@@ -426,7 +426,7 b' Additional new features' | |||
|
426 | 426 | strings like ``foo.bar.Bar`` to the actual class. |
|
427 | 427 | |
|
428 | 428 | * Completely refactored the :mod:`IPython.core.prefilter` module into |
|
429 |
:class:`~ |
|
|
429 | :class:`~traitlets.config.configurable.Configurable` subclasses. Added a new | |
|
430 | 430 | layer into the prefilter system, called "transformations" that all new |
|
431 | 431 | prefilter logic should use (rather than the older "checker/handler" |
|
432 | 432 | approach). |
@@ -439,22 +439,22 b' Additional new features' | |||
|
439 | 439 | instance and call it. In later calls, it just calls the previously created |
|
440 | 440 | :class:`~IPython.frontend.terminal.embed.InteractiveShellEmbed`. |
|
441 | 441 | |
|
442 |
* Created a configuration system (:mod:` |
|
|
443 |
based on :mod:` |
|
|
442 | * Created a configuration system (:mod:`traitlets.config.configurable`) that is | |
|
443 | based on :mod:`traitlets`. Configurables are arranged into a | |
|
444 | 444 | runtime containment tree (not inheritance) that i) automatically propagates |
|
445 | 445 | configuration information and ii) allows singletons to discover each other in |
|
446 | 446 | a loosely coupled manner. In the future all parts of IPython will be |
|
447 |
subclasses of :class:`~ |
|
|
447 | subclasses of :class:`~traitlets.config.configurable.Configurable`. All IPython | |
|
448 | 448 | developers should become familiar with the config system. |
|
449 | 449 | |
|
450 |
* Created a new :class:`~ |
|
|
450 | * Created a new :class:`~traitlets.config.loader.Config` for holding | |
|
451 | 451 | configuration information. This is a dict like class with a few extras: i) |
|
452 | 452 | it supports attribute style access, ii) it has a merge function that merges |
|
453 |
two :class:`~ |
|
|
454 |
will automatically create sub-:class:`~ |
|
|
453 | two :class:`~traitlets.config.loader.Config` instances recursively and iii) it | |
|
454 | will automatically create sub-:class:`~traitlets.config.loader.Config` | |
|
455 | 455 | instances for attributes that start with an uppercase character. |
|
456 | 456 | |
|
457 |
* Created new configuration loaders in :mod:` |
|
|
457 | * Created new configuration loaders in :mod:`traitlets.config.loader`. These | |
|
458 | 458 | loaders provide a unified loading interface for all configuration |
|
459 | 459 | information including command line arguments and configuration files. We |
|
460 | 460 | have two default implementations based on :mod:`argparse` and plain python |
@@ -474,12 +474,12 b' Additional new features' | |||
|
474 | 474 | as strings, like ``foo.bar.Bar``. This is needed for forward declarations. |
|
475 | 475 | But, this was implemented in a careful way so that string to class |
|
476 | 476 | resolution is done at a single point, when the parent |
|
477 |
:class:`~ |
|
|
477 | :class:`~traitlets.HasTraitlets` is instantiated. | |
|
478 | 478 | |
|
479 | 479 | * :mod:`IPython.utils.ipstruct` has been refactored to be a subclass of |
|
480 | 480 | dict. It also now has full docstrings and doctests. |
|
481 | 481 | |
|
482 |
* Created a Traits like implementation in :mod:` |
|
|
482 | * Created a Traits like implementation in :mod:`traitlets`. This | |
|
483 | 483 | is a pure Python, lightweight version of a library that is similar to |
|
484 | 484 | Enthought's Traits project, but has no dependencies on Enthought's code. We |
|
485 | 485 | are using this for validation, defaults and notification in our new component |
@@ -511,7 +511,7 b' Backwards incompatible changes' | |||
|
511 | 511 | ``ipython profile create <name>``. |
|
512 | 512 | |
|
513 | 513 | * All IPython applications have been rewritten to use |
|
514 |
:class:`~ |
|
|
514 | :class:`~traitlets.config.loader.KeyValueConfigLoader`. This means that | |
|
515 | 515 | command-line options have changed. Now, all configurable values are accessible |
|
516 | 516 | from the command-line with the same syntax as in a configuration file. |
|
517 | 517 |
@@ -517,7 +517,7 b' Official Public API' | |||
|
517 | 517 | We have begun organizing our API for easier public use, with an eye towards an |
|
518 | 518 | official IPython 1.0 release which will firmly maintain this API compatible for |
|
519 | 519 | its entire lifecycle. There is now an :mod:`IPython.display` module that |
|
520 |
aggregates all display routines, and the :mod:` |
|
|
520 | aggregates all display routines, and the :mod:`traitlets.config` namespace has | |
|
521 | 521 | all public configuration tools. We will continue improving our public API |
|
522 | 522 | layout so that users only need to import names one level deeper than the main |
|
523 | 523 | ``IPython`` package to access all public namespaces. |
@@ -78,7 +78,7 b' New features' | |||
|
78 | 78 | |
|
79 | 79 | * All of the parallel computing capabilities from `ipython1-dev` have been |
|
80 | 80 | merged into IPython proper. This resulted in the following new subpackages: |
|
81 |
:mod:`IPython.kernel`, :mod:`IPython.kernel.core`, :mod:` |
|
|
81 | :mod:`IPython.kernel`, :mod:`IPython.kernel.core`, :mod:`traitlets.config`, | |
|
82 | 82 | :mod:`IPython.tools` and :mod:`IPython.testing`. |
|
83 | 83 | |
|
84 | 84 | * As part of merging in the `ipython1-dev` stuff, the `setup.py` script and |
@@ -17,7 +17,7 b' from __future__ import print_function' | |||
|
17 | 17 | |
|
18 | 18 | # Try running this code both at the command line and from inside IPython (with |
|
19 | 19 | # %run example-embed.py) |
|
20 |
from |
|
|
20 | from traitlets.config.loader import Config | |
|
21 | 21 | try: |
|
22 | 22 | get_ipython |
|
23 | 23 | except NameError: |
@@ -110,7 +110,7 b'' | |||
|
110 | 110 | "outputs": [], |
|
111 | 111 | "source": [ |
|
112 | 112 | "from IPython.html import widgets\n", |
|
113 |
"from |
|
|
113 | "from traitlets import Unicode\n", | |
|
114 | 114 | "\n", |
|
115 | 115 | "class HelloWidget(widgets.DOMWidget):\n", |
|
116 | 116 | " _view_name = Unicode('HelloView', sync=True)" |
@@ -570,7 +570,7 b'' | |||
|
570 | 570 | }, |
|
571 | 571 | "outputs": [], |
|
572 | 572 | "source": [ |
|
573 |
"from |
|
|
573 | "from traitlets import CInt\n", | |
|
574 | 574 | "class SpinnerWidget(widgets.DOMWidget):\n", |
|
575 | 575 | " _view_name = Unicode('SpinnerView', sync=True)\n", |
|
576 | 576 | " value = CInt(0, sync=True)" |
@@ -757,7 +757,7 b'' | |||
|
757 | 757 | "w2 = widgets.IntSlider()\n", |
|
758 | 758 | "display(w1,w2)\n", |
|
759 | 759 | "\n", |
|
760 |
"from |
|
|
760 | "from traitlets import link\n", | |
|
761 | 761 | "mylink = link((w1, 'value'), (w2, 'value'))" |
|
762 | 762 | ] |
|
763 | 763 | }, |
@@ -24,7 +24,7 b'' | |||
|
24 | 24 | "\n", |
|
25 | 25 | "from IPython.html import widgets # Widget definitions\n", |
|
26 | 26 | "from IPython.display import display # Used to display widgets in the notebook\n", |
|
27 |
"from |
|
|
27 | "from traitlets import Unicode # Used to declare attributes of our widget" | |
|
28 | 28 | ] |
|
29 | 29 | }, |
|
30 | 30 | { |
@@ -11567,7 +11567,7 b' div#notebook {' | |||
|
11567 | 11567 | <div class=" highlight hl-ipython3"><pre><span class="c"># Widget related imports</span> |
|
11568 | 11568 | <span class="kn">from</span> <span class="nn">IPython.html</span> <span class="k">import</span> <span class="n">widgets</span> |
|
11569 | 11569 | <span class="kn">from</span> <span class="nn">IPython.display</span> <span class="k">import</span> <span class="n">display</span><span class="p">,</span> <span class="n">clear_output</span><span class="p">,</span> <span class="n">Javascript</span> |
|
11570 |
<span class="kn">from</span> <span class="nn"> |
|
|
11570 | <span class="kn">from</span> <span class="nn">traitlets</span> <span class="k">import</span> <span class="n">Unicode</span> | |
|
11571 | 11571 | |
|
11572 | 11572 | <span class="c"># nbconvert related imports</span> |
|
11573 | 11573 | <span class="kn">from</span> <span class="nn">IPython.nbconvert</span> <span class="k">import</span> <span class="n">get_export_names</span><span class="p">,</span> <span class="n">export_by_name</span> |
@@ -11,7 +11,7 b'' | |||
|
11 | 11 | "# Widget related imports\n", |
|
12 | 12 | "from IPython.html import widgets\n", |
|
13 | 13 | "from IPython.display import display, clear_output, Javascript\n", |
|
14 |
"from |
|
|
14 | "from traitlets import Unicode\n", | |
|
15 | 15 | "\n", |
|
16 | 16 | "# nbconvert related imports\n", |
|
17 | 17 | "from IPython.nbconvert import get_export_names, export_by_name\n", |
@@ -11,7 +11,7 b'' | |||
|
11 | 11 | "import base64\n", |
|
12 | 12 | "from __future__ import print_function # py 2.7 compat.\n", |
|
13 | 13 | "from IPython.html import widgets # Widget definitions.\n", |
|
14 |
"from |
|
|
14 | "from traitlets import Unicode # Traitlet needed to add synced attributes to the widget." | |
|
15 | 15 | ] |
|
16 | 16 | }, |
|
17 | 17 | { |
@@ -374,7 +374,7 b'' | |||
|
374 | 374 | }, |
|
375 | 375 | "outputs": [], |
|
376 | 376 | "source": [ |
|
377 |
"from |
|
|
377 | "from traitlets import link\n", | |
|
378 | 378 | "a = FloatText()\n", |
|
379 | 379 | "b = FloatSlider()\n", |
|
380 | 380 | "c = FloatProgress()\n", |
@@ -297,8 +297,8 b'' | |||
|
297 | 297 | "I like my cython to be nicely highlighted\n", |
|
298 | 298 | "\n", |
|
299 | 299 | "```javascript\n", |
|
300 |
" |
|
|
301 |
" |
|
|
300 | "traitlets.config.cell_magic_highlight['magic_text/x-cython'] = {}\n", | |
|
301 | "traitlets.config.cell_magic_highlight['magic_text/x-cython'].reg = [/^%%cython/]\n", | |
|
302 | 302 | "```\n", |
|
303 | 303 | "\n", |
|
304 | 304 | "`text/x-cython` is the name of CodeMirror mode name, `magic_` prefix will just patch the mode so that the first line that contains a magic does not screw up the highlighting. `reg`is a list or regular expression that will trigger the change of mode." |
@@ -114,7 +114,7 b'' | |||
|
114 | 114 | }, |
|
115 | 115 | "outputs": [], |
|
116 | 116 | "source": [ |
|
117 |
"from |
|
|
117 | "from traitlets.config import Config\n", | |
|
118 | 118 | "from IPython.nbconvert import HTMLExporter\n", |
|
119 | 119 | "\n", |
|
120 | 120 | "# The `basic` template is used here.\n", |
@@ -359,7 +359,7 b'' | |||
|
359 | 359 | }, |
|
360 | 360 | "outputs": [], |
|
361 | 361 | "source": [ |
|
362 |
"from |
|
|
362 | "from traitlets.config import Config\n", | |
|
363 | 363 | "\n", |
|
364 | 364 | "c = Config({\n", |
|
365 | 365 | " 'ExtractOutputPreprocessor':{'enabled':True}\n", |
@@ -409,7 +409,7 b'' | |||
|
409 | 409 | "outputs": [], |
|
410 | 410 | "source": [ |
|
411 | 411 | "from IPython.nbconvert.preprocessors import Preprocessor\n", |
|
412 |
"import |
|
|
412 | "import traitlets.config\n", | |
|
413 | 413 | "print(\"Four relevant docstring\")\n", |
|
414 | 414 | "print('=============================')\n", |
|
415 | 415 | "print(Preprocessor.__doc__)\n", |
@@ -444,7 +444,7 b'' | |||
|
444 | 444 | }, |
|
445 | 445 | "outputs": [], |
|
446 | 446 | "source": [ |
|
447 |
"from |
|
|
447 | "from traitlets import Integer" | |
|
448 | 448 | ] |
|
449 | 449 | }, |
|
450 | 450 | { |
General Comments 0
You need to be logged in to leave comments.
Login now