##// END OF EJS Templates
Add dictionary for magic escape sequences.
Bradley M. Froehle -
Show More
@@ -25,7 +25,7 b' from getopt import getopt, GetoptError'
25 from IPython.config.configurable import Configurable
25 from IPython.config.configurable import Configurable
26 from IPython.core import oinspect
26 from IPython.core import oinspect
27 from IPython.core.error import UsageError
27 from IPython.core.error import UsageError
28 from IPython.core.inputsplitter import ESC_MAGIC
28 from IPython.core.inputsplitter import ESC_MAGIC, ESC_MAGIC2
29 from IPython.external.decorator import decorator
29 from IPython.external.decorator import decorator
30 from IPython.utils.ipstruct import Struct
30 from IPython.utils.ipstruct import Struct
31 from IPython.utils.process import arg_split
31 from IPython.utils.process import arg_split
@@ -47,6 +47,7 b' magics = dict(line={}, cell={})'
47
47
48 magic_kinds = ('line', 'cell')
48 magic_kinds = ('line', 'cell')
49 magic_spec = ('line', 'cell', 'line_cell')
49 magic_spec = ('line', 'cell', 'line_cell')
50 magic_escapes = dict(line=ESC_MAGIC, cell=ESC_MAGIC2)
50
51
51 #-----------------------------------------------------------------------------
52 #-----------------------------------------------------------------------------
52 # Utility classes and functions
53 # Utility classes and functions
@@ -20,8 +20,7 b' from pprint import pformat'
20
20
21 # Our own packages
21 # Our own packages
22 from IPython.core.error import UsageError
22 from IPython.core.error import UsageError
23 from IPython.core.inputsplitter import ESC_MAGIC
23 from IPython.core.magic import Magics, magics_class, line_magic, magic_escapes
24 from IPython.core.magic import Magics, magics_class, line_magic
25 from IPython.utils.text import format_screen
24 from IPython.utils.text import format_screen
26 from IPython.core import magic_arguments, page
25 from IPython.core import magic_arguments, page
27 from IPython.testing.skipdoctest import skip_doctest
26 from IPython.testing.skipdoctest import skip_doctest
@@ -41,8 +40,8 b' class BasicMagics(Magics):'
41 are all part of the base 'IPython experience'."""
40 are all part of the base 'IPython experience'."""
42
41
43 def _lsmagic(self):
42 def _lsmagic(self):
44 mesc = ESC_MAGIC
43 mesc = magic_escapes['line']
45 cesc = mesc*2
44 cesc = magic_escapes['cell']
46 mman = self.shell.magics_manager
45 mman = self.shell.magics_manager
47 magics = mman.lsmagic()
46 magics = mman.lsmagic()
48 out = ['Available line magics:',
47 out = ['Available line magics:',
@@ -70,10 +69,10 b' class BasicMagics(Magics):'
70 format_string = '%s%s:\n\t%s\n'
69 format_string = '%s%s:\n\t%s\n'
71
70
72 return ''.join(
71 return ''.join(
73 [format_string % (ESC_MAGIC, fname, fndoc)
72 [format_string % (magic_escapes['line'], fname, fndoc)
74 for fname, fndoc in sorted(docs['line'].items())]
73 for fname, fndoc in sorted(docs['line'].items())]
75 +
74 +
76 [format_string % (ESC_MAGIC*2, fname, fndoc)
75 [format_string % (magic_escapes['cell'], fname, fndoc)
77 for fname, fndoc in sorted(docs['cell'].items())]
76 for fname, fndoc in sorted(docs['cell'].items())]
78 )
77 )
79
78
General Comments 0
You need to be logged in to leave comments. Login now