##// END OF EJS Templates
Specify unicode type properly in rmagic
Thomas Kluyver -
Show More
@@ -72,7 +72,8 b' from IPython.core.magic_arguments import ('
72 argument, magic_arguments, parse_argstring
72 argument, magic_arguments, parse_argstring
73 )
73 )
74 from IPython.external.simplegeneric import generic
74 from IPython.external.simplegeneric import generic
75 from IPython.utils.py3compat import str_to_unicode, unicode_to_str, PY3
75 from IPython.utils.py3compat import (str_to_unicode, unicode_to_str, PY3,
76 unicode_type)
76
77
77 class RInterpreterError(ri.RRuntimeError):
78 class RInterpreterError(ri.RRuntimeError):
78 """An error when running R code in a %%R magic cell."""
79 """An error when running R code in a %%R magic cell."""
@@ -390,7 +391,7 b' class RMagics(Magics):'
390 help='Convert these objects to data.frames and return as structured arrays.'
391 help='Convert these objects to data.frames and return as structured arrays.'
391 )
392 )
392 @argument(
393 @argument(
393 '-u', '--units', type=unicode, choices=["px", "in", "cm", "mm"],
394 '-u', '--units', type=unicode_type, choices=["px", "in", "cm", "mm"],
394 help='Units of png plotting device sent as an argument to *png* in R. One of ["px", "in", "cm", "mm"].'
395 help='Units of png plotting device sent as an argument to *png* in R. One of ["px", "in", "cm", "mm"].'
395 )
396 )
396 @argument(
397 @argument(
@@ -84,6 +84,7 b' if sys.version_info[0] >= 3:'
84 cast_bytes_py2 = no_code
84 cast_bytes_py2 = no_code
85
85
86 string_types = (str,)
86 string_types = (str,)
87 unicode_type = str
87
88
88 def isidentifier(s, dotted=False):
89 def isidentifier(s, dotted=False):
89 if dotted:
90 if dotted:
@@ -134,6 +135,7 b' else:'
134 cast_bytes_py2 = cast_bytes
135 cast_bytes_py2 = cast_bytes
135
136
136 string_types = (str, unicode)
137 string_types = (str, unicode)
138 unicode_type = unicode
137
139
138 import re
140 import re
139 _name_re = re.compile(r"[a-zA-Z_][a-zA-Z0-9_]*$")
141 _name_re = re.compile(r"[a-zA-Z_][a-zA-Z0-9_]*$")
General Comments 0
You need to be logged in to leave comments. Login now