##// END OF EJS Templates
Merge pull request #2868 from takluyver/import-performance...
Bussonnier Matthias -
r9459:ff3032f2 merge
parent child Browse files
Show More
@@ -30,7 +30,6 b' from IPython.config.configurable import Configurable'
30 from IPython.core.splitinput import split_user_input
30 from IPython.core.splitinput import split_user_input
31
31
32 from IPython.utils.traitlets import List, Instance
32 from IPython.utils.traitlets import List, Instance
33 from IPython.utils.autoattr import auto_attr
34 from IPython.utils.warn import warn, error
33 from IPython.utils.warn import warn, error
35
34
36 #-----------------------------------------------------------------------------
35 #-----------------------------------------------------------------------------
@@ -74,7 +74,6 b' import itertools'
74 import keyword
74 import keyword
75 import os
75 import os
76 import re
76 import re
77 import shlex
78 import sys
77 import sys
79
78
80 from IPython.config.configurable import Configurable
79 from IPython.config.configurable import Configurable
@@ -30,7 +30,6 b' from zipimport import zipimporter'
30 # Our own imports
30 # Our own imports
31 from IPython.core.completer import expand_user, compress_user
31 from IPython.core.completer import expand_user, compress_user
32 from IPython.core.error import TryNext
32 from IPython.core.error import TryNext
33 from IPython.utils import py3compat
34 from IPython.utils._process_common import arg_split
33 from IPython.utils._process_common import arg_split
35
34
36 # FIXME: this should be pulled in with the right call via the component system
35 # FIXME: this should be pulled in with the right call via the component system
@@ -33,7 +33,7 b' import sys'
33
33
34 from IPython.utils import PyColorize, ulinecache
34 from IPython.utils import PyColorize, ulinecache
35 from IPython.core import ipapi
35 from IPython.core import ipapi
36 from IPython.utils import coloransi, io, openpy, py3compat
36 from IPython.utils import coloransi, io, py3compat
37 from IPython.core.excolors import exception_colors
37 from IPython.core.excolors import exception_colors
38
38
39 # See if we can use pydb.
39 # See if we can use pydb.
@@ -19,8 +19,6 b' Authors:'
19
19
20 from __future__ import print_function
20 from __future__ import print_function
21
21
22 from xml.dom import minidom
23
24 from .displaypub import (
22 from .displaypub import (
25 publish_pretty, publish_html,
23 publish_pretty, publish_html,
26 publish_latex, publish_svg,
24 publish_latex, publish_svg,
@@ -330,6 +328,7 b' class SVG(DisplayObject):'
330 self._data = None
328 self._data = None
331 return
329 return
332 # parse into dom object
330 # parse into dom object
331 from xml.dom import minidom
333 x = minidom.parseString(svg)
332 x = minidom.parseString(svg)
334 # get svg tag (should be 1)
333 # get svg tag (should be 1)
335 found_svg = x.getElementsByTagName('svg')
334 found_svg = x.getElementsByTagName('svg')
@@ -30,7 +30,7 b' import sys'
30
30
31 from IPython.config.configurable import Configurable
31 from IPython.config.configurable import Configurable
32 from IPython.utils import io
32 from IPython.utils import io
33 from IPython.utils.traitlets import Instance, List
33 from IPython.utils.traitlets import Instance
34 from IPython.utils.warn import warn
34 from IPython.utils.warn import warn
35
35
36 #-----------------------------------------------------------------------------
36 #-----------------------------------------------------------------------------
@@ -20,8 +20,6 b' Authors:'
20 import os
20 import os
21 from shutil import copyfile
21 from shutil import copyfile
22 import sys
22 import sys
23 from urllib import urlretrieve
24 from urlparse import urlparse
25
23
26 from IPython.core.error import UsageError
24 from IPython.core.error import UsageError
27 from IPython.config.configurable import Configurable
25 from IPython.config.configurable import Configurable
@@ -171,6 +169,8 b' class ExtensionManager(Configurable):'
171 src_filename = os.path.basename(url)
169 src_filename = os.path.basename(url)
172 copy = copyfile
170 copy = copyfile
173 else:
171 else:
172 from urllib import urlretrieve # Deferred imports
173 from urlparse import urlparse
174 src_filename = urlparse(url).path.split('/')[-1]
174 src_filename = urlparse(url).path.split('/')[-1]
175 copy = urlretrieve
175 copy = urlretrieve
176
176
@@ -28,7 +28,6 b' import runpy'
28 import sys
28 import sys
29 import tempfile
29 import tempfile
30 import types
30 import types
31 import urllib
32 from io import open as io_open
31 from io import open as io_open
33
32
34 from IPython.config.configurable import SingletonConfigurable
33 from IPython.config.configurable import SingletonConfigurable
@@ -2989,7 +2988,8 b' class InteractiveShell(SingletonConfigurable):'
2989 return openpy.read_py_url(utarget, skip_encoding_cookie=skip_encoding_cookie)
2988 return openpy.read_py_url(utarget, skip_encoding_cookie=skip_encoding_cookie)
2990 except UnicodeDecodeError:
2989 except UnicodeDecodeError:
2991 if not py_only :
2990 if not py_only :
2992 response = urllib.urlopen(target)
2991 from urllib import urlopen # Deferred import
2992 response = urlopen(target)
2993 return response.read().decode('latin1')
2993 return response.read().decode('latin1')
2994 raise ValueError(("'%s' seem to be unreadable.") % utarget)
2994 raise ValueError(("'%s' seem to be unreadable.") % utarget)
2995
2995
@@ -8,7 +8,6 b''
8 #*****************************************************************************
8 #*****************************************************************************
9
9
10 import re
10 import re
11 import sys
12
11
13 from IPython.utils import py3compat
12 from IPython.utils import py3compat
14 from IPython.utils.encoding import DEFAULT_ENCODING
13 from IPython.utils.encoding import DEFAULT_ENCODING
@@ -31,7 +31,7 b' from IPython.utils.ipstruct import Struct'
31 from IPython.utils.process import arg_split
31 from IPython.utils.process import arg_split
32 from IPython.utils.text import dedent
32 from IPython.utils.text import dedent
33 from IPython.utils.traitlets import Bool, Dict, Instance, MetaHasTraits
33 from IPython.utils.traitlets import Bool, Dict, Instance, MetaHasTraits
34 from IPython.utils.warn import error, warn
34 from IPython.utils.warn import error
35
35
36 #-----------------------------------------------------------------------------
36 #-----------------------------------------------------------------------------
37 # Globals
37 # Globals
@@ -15,11 +15,9 b''
15 # Stdlib
15 # Stdlib
16 import inspect
16 import inspect
17 import io
17 import io
18 import json
19 import os
18 import os
20 import re
19 import re
21 import sys
20 import sys
22 from urllib2 import urlopen
23
21
24 # Our own packages
22 # Our own packages
25 from IPython.core.error import TryNext, StdinNotImplementedError, UsageError
23 from IPython.core.error import TryNext, StdinNotImplementedError, UsageError
@@ -27,7 +25,6 b' from IPython.core.macro import Macro'
27 from IPython.core.magic import Magics, magics_class, line_magic
25 from IPython.core.magic import Magics, magics_class, line_magic
28 from IPython.core.oinspect import find_file, find_source_lines
26 from IPython.core.oinspect import find_file, find_source_lines
29 from IPython.testing.skipdoctest import skip_doctest
27 from IPython.testing.skipdoctest import skip_doctest
30 from IPython.utils import openpy
31 from IPython.utils import py3compat
28 from IPython.utils import py3compat
32 from IPython.utils.contexts import preserve_keys
29 from IPython.utils.contexts import preserve_keys
33 from IPython.utils.io import file_read
30 from IPython.utils.io import file_read
@@ -141,6 +138,8 b' class CodeMagics(Magics):'
141 print e.args[0]
138 print e.args[0]
142 return
139 return
143
140
141 from urllib2 import urlopen # Deferred import
142 import json
144 post_data = json.dumps({
143 post_data = json.dumps({
145 "description": opts.get('d', "Pasted from IPython"),
144 "description": opts.get('d', "Pasted from IPython"),
146 "public": True,
145 "public": True,
@@ -14,7 +14,7 b''
14 # Our own packages
14 # Our own packages
15 from IPython.core.display import display, Javascript, Latex, SVG
15 from IPython.core.display import display, Javascript, Latex, SVG
16 from IPython.core.magic import (
16 from IPython.core.magic import (
17 Magics, magics_class, line_magic, cell_magic
17 Magics, magics_class, cell_magic
18 )
18 )
19
19
20 #-----------------------------------------------------------------------------
20 #-----------------------------------------------------------------------------
@@ -16,7 +16,6 b' from __future__ import print_function'
16 # Stdlib
16 # Stdlib
17 import os
17 import os
18 from io import open as io_open
18 from io import open as io_open
19 from IPython.external.argparse import Action
20
19
21 # Our own packages
20 # Our own packages
22 from IPython.core.error import StdinNotImplementedError
21 from IPython.core.error import StdinNotImplementedError
@@ -26,14 +26,14 b' from pprint import pformat'
26 from IPython.core import magic_arguments
26 from IPython.core import magic_arguments
27 from IPython.core import oinspect
27 from IPython.core import oinspect
28 from IPython.core import page
28 from IPython.core import page
29 from IPython.core.error import UsageError, StdinNotImplementedError
29 from IPython.core.error import UsageError
30 from IPython.core.magic import (
30 from IPython.core.magic import (
31 Magics, compress_dhist, magics_class, line_magic, cell_magic, line_cell_magic
31 Magics, compress_dhist, magics_class, line_magic, cell_magic, line_cell_magic
32 )
32 )
33 from IPython.testing.skipdoctest import skip_doctest
33 from IPython.testing.skipdoctest import skip_doctest
34 from IPython.utils.io import file_read, nlprint
34 from IPython.utils.io import nlprint
35 from IPython.utils.openpy import source_to_unicode
35 from IPython.utils.openpy import source_to_unicode
36 from IPython.utils.path import get_py_filename, unquote_filename
36 from IPython.utils.path import unquote_filename
37 from IPython.utils.process import abbrev_cwd
37 from IPython.utils.process import abbrev_cwd
38 from IPython.utils.terminal import set_term_title
38 from IPython.utils.terminal import set_term_title
39 #-----------------------------------------------------------------------------
39 #-----------------------------------------------------------------------------
@@ -14,7 +14,6 b''
14 # Stdlib
14 # Stdlib
15 import errno
15 import errno
16 import os
16 import os
17 import re
18 import sys
17 import sys
19 import signal
18 import signal
20 import time
19 import time
@@ -24,12 +23,10 b' import atexit'
24 # Our own packages
23 # Our own packages
25 from IPython.config.configurable import Configurable
24 from IPython.config.configurable import Configurable
26 from IPython.core import magic_arguments
25 from IPython.core import magic_arguments
27 from IPython.core.error import UsageError
28 from IPython.core.magic import (
26 from IPython.core.magic import (
29 Magics, magics_class, line_magic, cell_magic
27 Magics, magics_class, line_magic, cell_magic
30 )
28 )
31 from IPython.lib.backgroundjobs import BackgroundJobManager
29 from IPython.lib.backgroundjobs import BackgroundJobManager
32 from IPython.testing.skipdoctest import skip_doctest
33 from IPython.utils import py3compat
30 from IPython.utils import py3compat
34 from IPython.utils.process import arg_split
31 from IPython.utils.process import arg_split
35 from IPython.utils.traitlets import List, Dict
32 from IPython.utils.traitlets import List, Dict
@@ -29,7 +29,6 b' from __future__ import print_function'
29
29
30 import os
30 import os
31 import re
31 import re
32 import subprocess
33 import sys
32 import sys
34 import tempfile
33 import tempfile
35
34
@@ -37,7 +36,6 b' from io import UnsupportedOperation'
37
36
38 from IPython.core import ipapi
37 from IPython.core import ipapi
39 from IPython.core.error import TryNext
38 from IPython.core.error import TryNext
40 from IPython.utils.cursesimport import use_curses
41 from IPython.utils.data import chop
39 from IPython.utils.data import chop
42 from IPython.utils import io
40 from IPython.utils import io
43 from IPython.utils.process import system
41 from IPython.utils.process import system
@@ -73,61 +71,66 b' def page_dumb(strng, start=0, screen_lines=25):'
73 last_escape = esc_list[-1]
71 last_escape = esc_list[-1]
74 print(last_escape + os.linesep.join(screens[-1]), file=io.stdout)
72 print(last_escape + os.linesep.join(screens[-1]), file=io.stdout)
75
73
76 def _detect_screen_size(use_curses, screen_lines_def):
74 def _detect_screen_size(screen_lines_def):
77 """Attempt to work out the number of lines on the screen.
75 """Attempt to work out the number of lines on the screen.
78
76
79 This is called by page(). It can raise an error (e.g. when run in the
77 This is called by page(). It can raise an error (e.g. when run in the
80 test suite), so it's separated out so it can easily be called in a try block.
78 test suite), so it's separated out so it can easily be called in a try block.
81 """
79 """
82 TERM = os.environ.get('TERM',None)
80 TERM = os.environ.get('TERM',None)
83 if (TERM=='xterm' or TERM=='xterm-color') and sys.platform != 'sunos5':
81 if not((TERM=='xterm' or TERM=='xterm-color') and sys.platform != 'sunos5'):
84 local_use_curses = use_curses
85 else:
86 # curses causes problems on many terminals other than xterm, and
82 # curses causes problems on many terminals other than xterm, and
87 # some termios calls lock up on Sun OS5.
83 # some termios calls lock up on Sun OS5.
88 local_use_curses = False
84 return screen_lines_def
89 if local_use_curses:
85
86 try:
90 import termios
87 import termios
91 import curses
88 import curses
92 # There is a bug in curses, where *sometimes* it fails to properly
89 except ImportError:
93 # initialize, and then after the endwin() call is made, the
90 return screen_lines_def
94 # terminal is left in an unusable state. Rather than trying to
91
95 # check everytime for this (by requesting and comparing termios
92 # There is a bug in curses, where *sometimes* it fails to properly
96 # flags each time), we just save the initial terminal state and
93 # initialize, and then after the endwin() call is made, the
97 # unconditionally reset it every time. It's cheaper than making
94 # terminal is left in an unusable state. Rather than trying to
98 # the checks.
95 # check everytime for this (by requesting and comparing termios
99 term_flags = termios.tcgetattr(sys.stdout)
96 # flags each time), we just save the initial terminal state and
100
97 # unconditionally reset it every time. It's cheaper than making
101 # Curses modifies the stdout buffer size by default, which messes
98 # the checks.
102 # up Python's normal stdout buffering. This would manifest itself
99 term_flags = termios.tcgetattr(sys.stdout)
103 # to IPython users as delayed printing on stdout after having used
100
104 # the pager.
101 # Curses modifies the stdout buffer size by default, which messes
105 #
102 # up Python's normal stdout buffering. This would manifest itself
106 # We can prevent this by manually setting the NCURSES_NO_SETBUF
103 # to IPython users as delayed printing on stdout after having used
107 # environment variable. For more details, see:
104 # the pager.
108 # http://bugs.python.org/issue10144
105 #
109 NCURSES_NO_SETBUF = os.environ.get('NCURSES_NO_SETBUF', None)
106 # We can prevent this by manually setting the NCURSES_NO_SETBUF
110 os.environ['NCURSES_NO_SETBUF'] = ''
107 # environment variable. For more details, see:
111
108 # http://bugs.python.org/issue10144
112 # Proceed with curses initialization
109 NCURSES_NO_SETBUF = os.environ.get('NCURSES_NO_SETBUF', None)
110 os.environ['NCURSES_NO_SETBUF'] = ''
111
112 # Proceed with curses initialization
113 try:
113 scr = curses.initscr()
114 scr = curses.initscr()
114 screen_lines_real,screen_cols = scr.getmaxyx()
115 except AttributeError:
115 curses.endwin()
116 # Curses on Solaris may not be complete, so we can't use it there
117 return screen_lines_def
118
119 screen_lines_real,screen_cols = scr.getmaxyx()
120 curses.endwin()
116
121
117 # Restore environment
122 # Restore environment
118 if NCURSES_NO_SETBUF is None:
123 if NCURSES_NO_SETBUF is None:
119 del os.environ['NCURSES_NO_SETBUF']
124 del os.environ['NCURSES_NO_SETBUF']
120 else:
121 os.environ['NCURSES_NO_SETBUF'] = NCURSES_NO_SETBUF
122
123 # Restore terminal state in case endwin() didn't.
124 termios.tcsetattr(sys.stdout,termios.TCSANOW,term_flags)
125 # Now we have what we needed: the screen size in rows/columns
126 return screen_lines_real
127 #print '***Screen size:',screen_lines_real,'lines x',\
128 #screen_cols,'columns.' # dbg
129 else:
125 else:
130 return screen_lines_def
126 os.environ['NCURSES_NO_SETBUF'] = NCURSES_NO_SETBUF
127
128 # Restore terminal state in case endwin() didn't.
129 termios.tcsetattr(sys.stdout,termios.TCSANOW,term_flags)
130 # Now we have what we needed: the screen size in rows/columns
131 return screen_lines_real
132 #print '***Screen size:',screen_lines_real,'lines x',\
133 #screen_cols,'columns.' # dbg
131
134
132 def page(strng, start=0, screen_lines=0, pager_cmd=None):
135 def page(strng, start=0, screen_lines=0, pager_cmd=None):
133 """Print a string, piping through a pager after a certain length.
136 """Print a string, piping through a pager after a certain length.
@@ -184,7 +187,7 b' def page(strng, start=0, screen_lines=0, pager_cmd=None):'
184 # auto-determine screen size
187 # auto-determine screen size
185 if screen_lines <= 0:
188 if screen_lines <= 0:
186 try:
189 try:
187 screen_lines += _detect_screen_size(use_curses, screen_lines_def)
190 screen_lines += _detect_screen_size(screen_lines_def)
188 except (TypeError, UnsupportedOperation):
191 except (TypeError, UnsupportedOperation):
189 print(str_toprint, file=io.stdout)
192 print(str_toprint, file=io.stdout)
190 return
193 return
@@ -24,11 +24,8 b' Authors:'
24 # Imports
24 # Imports
25 #-----------------------------------------------------------------------------
25 #-----------------------------------------------------------------------------
26
26
27 import __builtin__
28 import codeop
29 import re
27 import re
30
28
31 from IPython.core.alias import AliasManager
32 from IPython.core.autocall import IPyAutocall
29 from IPython.core.autocall import IPyAutocall
33 from IPython.config.configurable import Configurable
30 from IPython.config.configurable import Configurable
34 from IPython.core.inputsplitter import (
31 from IPython.core.inputsplitter import (
@@ -42,13 +39,11 b' from IPython.core.inputsplitter import ('
42 ESC_PAREN,
39 ESC_PAREN,
43 )
40 )
44 from IPython.core.macro import Macro
41 from IPython.core.macro import Macro
45 from IPython.core.splitinput import split_user_input, LineInfo
42 from IPython.core.splitinput import LineInfo
46 from IPython.core import page
47
43
48 from IPython.utils.traitlets import (
44 from IPython.utils.traitlets import (
49 List, Integer, Any, Unicode, CBool, Bool, Instance, CRegExp
45 List, Integer, Unicode, CBool, Bool, Instance, CRegExp
50 )
46 )
51 from IPython.utils.autoattr import auto_attr
52
47
53 #-----------------------------------------------------------------------------
48 #-----------------------------------------------------------------------------
54 # Global utilities, errors and constants
49 # Global utilities, errors and constants
@@ -21,12 +21,11 b' Authors:'
21 # Imports
21 # Imports
22 #-----------------------------------------------------------------------------
22 #-----------------------------------------------------------------------------
23
23
24 import logging
25 import os
24 import os
26
25
27 from IPython.config.application import Application, boolean_flag
26 from IPython.config.application import Application
28 from IPython.core.application import (
27 from IPython.core.application import (
29 BaseIPythonApplication, base_flags, base_aliases
28 BaseIPythonApplication, base_flags
30 )
29 )
31 from IPython.core.profiledir import ProfileDir
30 from IPython.core.profiledir import ProfileDir
32 from IPython.utils.path import get_ipython_dir, get_ipython_package_dir
31 from IPython.utils.path import get_ipython_dir, get_ipython_package_dir
@@ -23,12 +23,10 b' Authors:'
23
23
24 import os
24 import os
25 import shutil
25 import shutil
26 import sys
27
26
28 from IPython.config.configurable import LoggingConfigurable
27 from IPython.config.configurable import LoggingConfigurable
29 from IPython.config.loader import Config
30 from IPython.utils.path import get_ipython_package_dir, expand_path
28 from IPython.utils.path import get_ipython_package_dir, expand_path
31 from IPython.utils.traitlets import List, Unicode, Bool
29 from IPython.utils.traitlets import Unicode, Bool
32
30
33 #-----------------------------------------------------------------------------
31 #-----------------------------------------------------------------------------
34 # Classes and functions
32 # Classes and functions
@@ -109,7 +109,6 b' from IPython.utils import py3compat'
109 from IPython.utils import pyfile
109 from IPython.utils import pyfile
110 from IPython.utils import ulinecache
110 from IPython.utils import ulinecache
111 from IPython.utils.data import uniq_stable
111 from IPython.utils.data import uniq_stable
112 from IPython.utils.openpy import read_py_file
113 from IPython.utils.warn import info, error
112 from IPython.utils.warn import info, error
114
113
115 # Globals
114 # Globals
@@ -358,8 +358,13 b' class TerminalInteractiveShell(InteractiveShell):'
358 using_paste_magics = CBool(False)
358 using_paste_magics = CBool(False)
359
359
360 # In the terminal, GUI control is done via PyOS_InputHook
360 # In the terminal, GUI control is done via PyOS_InputHook
361 from IPython.lib.inputhook import enable_gui
361 @staticmethod
362 enable_gui = staticmethod(enable_gui)
362 def enable_gui(gui=None, app=None):
363 """Switch amongst GUI input hooks by name.
364 """
365 # Deferred import
366 from IPython.lib.inputhook import enable_gui as real_enable_gui
367 return real_enable_gui(gui, app)
363
368
364 def __init__(self, config=None, ipython_dir=None, profile_dir=None,
369 def __init__(self, config=None, ipython_dir=None, profile_dir=None,
365 user_ns=None, user_module=None, custom_exceptions=((),None),
370 user_ns=None, user_module=None, custom_exceptions=((),None),
@@ -48,7 +48,6 b' from IPython.core.shellapp import ('
48 InteractiveShellApp, shell_flags, shell_aliases
48 InteractiveShellApp, shell_flags, shell_aliases
49 )
49 )
50 from IPython.frontend.terminal.interactiveshell import TerminalInteractiveShell
50 from IPython.frontend.terminal.interactiveshell import TerminalInteractiveShell
51 from IPython.lib import inputhook
52 from IPython.utils import warn
51 from IPython.utils import warn
53 from IPython.utils.path import get_ipython_dir, check_for_old_config
52 from IPython.utils.path import get_ipython_dir, check_for_old_config
54 from IPython.utils.traitlets import (
53 from IPython.utils.traitlets import (
@@ -14,18 +14,6 b' Extra capabilities for IPython'
14 # Imports
14 # Imports
15 #-----------------------------------------------------------------------------
15 #-----------------------------------------------------------------------------
16
16
17 from IPython.lib.inputhook import (
18 enable_wx, disable_wx,
19 enable_gtk, disable_gtk,
20 enable_qt4, disable_qt4,
21 enable_tk, disable_tk,
22 enable_glut, disable_glut,
23 enable_pyglet, disable_pyglet,
24 enable_gtk3, disable_gtk3,
25 set_inputhook, clear_inputhook,
26 current_gui
27 )
28
29 from IPython.lib.security import passwd
17 from IPython.lib.security import passwd
30
18
31 #-----------------------------------------------------------------------------
19 #-----------------------------------------------------------------------------
@@ -34,7 +34,7 b' import sys'
34 import threading
34 import threading
35
35
36 from IPython.core.ultratb import AutoFormattedTB
36 from IPython.core.ultratb import AutoFormattedTB
37 from IPython.utils.warn import warn, error
37 from IPython.utils.warn import error
38
38
39
39
40 class BackgroundJobManager(object):
40 class BackgroundJobManager(object):
@@ -2,7 +2,6 b''
2 """
2 """
3
3
4 import subprocess
4 import subprocess
5 import sys
6
5
7 from IPython.core.error import TryNext
6 from IPython.core.error import TryNext
8 import IPython.utils.py3compat as py3compat
7 import IPython.utils.py3compat as py3compat
@@ -183,9 +183,8 b' import re'
183 import shlex
183 import shlex
184 import sys
184 import sys
185
185
186 from IPython.utils.PyColorize import Parser
187 from IPython.utils import io
186 from IPython.utils import io
188 from IPython.utils.io import file_read, file_readlines
187 from IPython.utils.io import file_read
189 from IPython.utils.text import marquee
188 from IPython.utils.text import marquee
190 from IPython.utils import openpy
189 from IPython.utils import openpy
191 __all__ = ['Demo','IPythonDemo','LineDemo','IPythonLineDemo','DemoError']
190 __all__ = ['Demo','IPythonDemo','LineDemo','IPythonLineDemo','DemoError']
@@ -2,8 +2,6 b''
2
2
3 Authors : MinRK, gregcaporaso, dannystaple
3 Authors : MinRK, gregcaporaso, dannystaple
4 """
4 """
5 import urllib
6
7 from os.path import exists, isfile, splitext, abspath, join, isdir
5 from os.path import exists, isfile, splitext, abspath, join, isdir
8 from os import walk, sep
6 from os import walk, sep
9
7
@@ -41,7 +39,8 b' class YouTubeVideo(object):'
41 def _repr_html_(self):
39 def _repr_html_(self):
42 """return YouTube embed iframe for this video id"""
40 """return YouTube embed iframe for this video id"""
43 if self.params:
41 if self.params:
44 params = "?" + urllib.urlencode(self.params)
42 from urllib import urlencode # Deferred import
43 params = "?" + urlencode(self.params)
45 else:
44 else:
46 params = ""
45 params = ""
47 return """
46 return """
@@ -17,9 +17,7 b' Authors: Robin Dunn, Brian Granger, Ondrej Certik'
17 # Imports
17 # Imports
18 #-----------------------------------------------------------------------------
18 #-----------------------------------------------------------------------------
19
19
20 import os
21 import signal
20 import signal
22 import sys
23 import time
21 import time
24 from timeit import default_timer as clock
22 from timeit import default_timer as clock
25 import wx
23 import wx
@@ -26,7 +26,7 b' import subprocess'
26
26
27 from IPython.utils.process import find_cmd, FindCmdError
27 from IPython.utils.process import find_cmd, FindCmdError
28 from IPython.config.configurable import SingletonConfigurable
28 from IPython.config.configurable import SingletonConfigurable
29 from IPython.utils.traitlets import Instance, List, CBool, CUnicode
29 from IPython.utils.traitlets import List, CBool, CUnicode
30 from IPython.utils.py3compat import bytes_to_str
30 from IPython.utils.py3compat import bytes_to_str
31
31
32 #-----------------------------------------------------------------------------
32 #-----------------------------------------------------------------------------
@@ -41,7 +41,6 b" _scheme_default = 'Linux'"
41 import StringIO
41 import StringIO
42 import keyword
42 import keyword
43 import os
43 import os
44 import optparse
45 import sys
44 import sys
46 import token
45 import token
47 import tokenize
46 import tokenize
@@ -263,6 +262,7 b' def main(argv=None):'
263 Colorize a python file or stdin using ANSI color escapes and print to stdout.
262 Colorize a python file or stdin using ANSI color escapes and print to stdout.
264 If no filename is given, or if filename is -, read standard input."""
263 If no filename is given, or if filename is -, read standard input."""
265
264
265 import optparse
266 parser = optparse.OptionParser(usage=usage_msg)
266 parser = optparse.OptionParser(usage=usage_msg)
267 newopt = parser.add_option
267 newopt = parser.add_option
268 newopt('-s','--scheme',metavar='NAME',dest='scheme_name',action='store',
268 newopt('-s','--scheme',metavar='NAME',dest='scheme_name',action='store',
@@ -24,7 +24,6 b' from IPython.external import pexpect'
24 # Our own
24 # Our own
25 from .autoattr import auto_attr
25 from .autoattr import auto_attr
26 from ._process_common import getoutput, arg_split
26 from ._process_common import getoutput, arg_split
27 from IPython.utils import text
28 from IPython.utils import py3compat
27 from IPython.utils import py3compat
29 from IPython.utils.encoding import DEFAULT_ENCODING
28 from IPython.utils.encoding import DEFAULT_ENCODING
30
29
@@ -28,7 +28,6 b' from subprocess import STDOUT'
28 # our own imports
28 # our own imports
29 from ._process_common import read_no_interrupt, process_handler, arg_split as py_arg_split
29 from ._process_common import read_no_interrupt, process_handler, arg_split as py_arg_split
30 from . import py3compat
30 from . import py3compat
31 from . import text
32 from .encoding import DEFAULT_ENCODING
31 from .encoding import DEFAULT_ENCODING
33
32
34 #-----------------------------------------------------------------------------
33 #-----------------------------------------------------------------------------
@@ -13,7 +13,6 b''
13 # stdlib
13 # stdlib
14 import math
14 import math
15 import re
15 import re
16 import sys
17 import types
16 import types
18 from datetime import datetime
17 from datetime import datetime
19
18
@@ -26,7 +25,6 b' except ImportError:'
26
25
27 from IPython.utils import py3compat
26 from IPython.utils import py3compat
28 from IPython.utils.encoding import DEFAULT_ENCODING
27 from IPython.utils.encoding import DEFAULT_ENCODING
29 from IPython.utils import text
30 next_attr_name = '__next__' if py3compat.PY3 else 'next'
28 next_attr_name = '__next__' if py3compat.PY3 else 'next'
31
29
32 #-----------------------------------------------------------------------------
30 #-----------------------------------------------------------------------------
@@ -9,7 +9,6 b' from __future__ import absolute_import'
9 import io
9 import io
10 from io import TextIOWrapper, BytesIO
10 from io import TextIOWrapper, BytesIO
11 import re
11 import re
12 import urllib
13
12
14 cookie_re = re.compile(ur"coding[:=]\s*([-\w.]+)", re.UNICODE)
13 cookie_re = re.compile(ur"coding[:=]\s*([-\w.]+)", re.UNICODE)
15 cookie_comment_re = re.compile(ur"^\s*#.*coding[:=]\s*([-\w.]+)", re.UNICODE)
14 cookie_comment_re = re.compile(ur"^\s*#.*coding[:=]\s*([-\w.]+)", re.UNICODE)
@@ -205,7 +204,8 b" def read_py_url(url, errors='replace', skip_encoding_cookie=True):"
205 -------
204 -------
206 A unicode string containing the contents of the file.
205 A unicode string containing the contents of the file.
207 """
206 """
208 response = urllib.urlopen(url)
207 from urllib import urlopen # Deferred import for faster start
208 response = urlopen(url)
209 buffer = io.BytesIO(response.read())
209 buffer = io.BytesIO(response.read())
210 return source_to_unicode(buffer, errors, skip_encoding_cookie)
210 return source_to_unicode(buffer, errors, skip_encoding_cookie)
211
211
@@ -28,7 +28,6 b' else:'
28
28
29
29
30 from ._process_common import getoutputerror
30 from ._process_common import getoutputerror
31 from IPython.utils import py3compat
32
31
33 #-----------------------------------------------------------------------------
32 #-----------------------------------------------------------------------------
34 # Code
33 # Code
@@ -9,14 +9,9 b' In addition to normal readline stuff, this module provides have_readline'
9 boolean and _outputfile variable used in IPython.utils.
9 boolean and _outputfile variable used in IPython.utils.
10 """
10 """
11
11
12 import os
13 import re
14 import sys
12 import sys
15 import time
16 import warnings
13 import warnings
17
14
18 from subprocess import Popen, PIPE
19
20 if sys.platform == 'darwin':
15 if sys.platform == 'darwin':
21 # dirty trick, to skip the system readline, because pip-installed readline
16 # dirty trick, to skip the system readline, because pip-installed readline
22 # will never be found on OSX, since lib-dynload always comes ahead of site-packages
17 # will never be found on OSX, since lib-dynload always comes ahead of site-packages
@@ -20,8 +20,6 b' import pprint'
20 import sys
20 import sys
21 import subprocess
21 import subprocess
22
22
23 from ConfigParser import ConfigParser
24
25 from IPython.core import release
23 from IPython.core import release
26 from IPython.utils import py3compat, _sysinfo, encoding
24 from IPython.utils import py3compat, _sysinfo, encoding
27
25
@@ -23,7 +23,6 b' import __main__'
23
23
24 import os
24 import os
25 import re
25 import re
26 import shutil
27 import sys
26 import sys
28 import textwrap
27 import textwrap
29 from string import Formatter
28 from string import Formatter
@@ -403,31 +402,6 b' def indent(instr,nspaces=4, ntabs=0, flatten=False):'
403 else:
402 else:
404 return outstr
403 return outstr
405
404
406 def native_line_ends(filename,backup=1):
407 """Convert (in-place) a file to line-ends native to the current OS.
408
409 If the optional backup argument is given as false, no backup of the
410 original file is left. """
411
412 backup_suffixes = {'posix':'~','dos':'.bak','nt':'.bak','mac':'.bak'}
413
414 bak_filename = filename + backup_suffixes[os.name]
415
416 original = open(filename).read()
417 shutil.copy2(filename,bak_filename)
418 try:
419 new = open(filename,'wb')
420 new.write(os.linesep.join(original.splitlines()))
421 new.write(os.linesep) # ALWAYS put an eol at the end of the file
422 new.close()
423 except:
424 os.rename(bak_filename,filename)
425 if not backup:
426 try:
427 os.remove(bak_filename)
428 except:
429 pass
430
431
405
432 def list_strings(arg):
406 def list_strings(arg):
433 """Always return a list of strings, given a string or list of strings
407 """Always return a list of strings, given a string or list of strings
@@ -32,3 +32,7 b' Backwards incompatible changes'
32 was duplicated in :mod:`IPython.core.inputsplitter`, and the latter version
32 was duplicated in :mod:`IPython.core.inputsplitter`, and the latter version
33 was already what IPython relied on. A new API to transform input will be ready
33 was already what IPython relied on. A new API to transform input will be ready
34 before release.
34 before release.
35 * Functions from :mod:`IPython.lib.inputhook` to control integration with GUI
36 event loops are no longer exposed in the top level of :mod:`IPython.lib`.
37 Code calling these should make sure to import them from
38 :mod:`IPython.lib.inputhook`.
1 NO CONTENT: file was removed
NO CONTENT: file was removed
General Comments 0
You need to be logged in to leave comments. Login now