Make a new demo object. To run the demo, simply call the object. See the module docstring for full details and an example (you can use IPython.Demo? in IPython to see it). Inputs: - src is either a file, or file-like object, or a string that can be
(self,src,title='',arg_str='',auto_all=None, format_rst=False,
formatter='terminal', style='default')
| 204 | re_auto_all = re_mark('auto_all') |
| 205 | |
| 206 | def __init__(self,src,title='',arg_str='',auto_all=None, format_rst=False, |
| 207 | formatter='terminal', style='default'): |
| 208 | """Make a new demo object. To run the demo, simply call the object. |
| 209 | |
| 210 | See the module docstring for full details and an example (you can use |
| 211 | IPython.Demo? in IPython to see it). |
| 212 | |
| 213 | Inputs: |
| 214 | |
| 215 | - src is either a file, or file-like object, or a |
| 216 | string that can be resolved to a filename. |
| 217 | |
| 218 | Optional inputs: |
| 219 | |
| 220 | - title: a string to use as the demo name. Of most use when the demo |
| 221 | you are making comes from an object that has no filename, or if you |
| 222 | want an alternate denotation distinct from the filename. |
| 223 | |
| 224 | - arg_str(''): a string of arguments, internally converted to a list |
| 225 | just like sys.argv, so the demo script can see a similar |
| 226 | environment. |
| 227 | |
| 228 | - auto_all(None): global flag to run all blocks automatically without |
| 229 | confirmation. This attribute overrides the block-level tags and |
| 230 | applies to the whole demo. It is an attribute of the object, and |
| 231 | can be changed at runtime simply by reassigning it to a boolean |
| 232 | value. |
| 233 | |
| 234 | - format_rst(False): a bool to enable comments and doc strings |
| 235 | formatting with pygments rst lexer |
| 236 | |
| 237 | - formatter('terminal'): a string of pygments formatter name to be |
| 238 | used. Useful values for terminals: terminal, terminal256, |
| 239 | terminal16m |
| 240 | |
| 241 | - style('default'): a string of pygments style name to be used. |
| 242 | """ |
| 243 | if hasattr(src, "read"): |
| 244 | # It seems to be a file or a file-like object |
| 245 | self.fname = "from a file-like object" |
| 246 | if title == '': |
| 247 | self.title = "from a file-like object" |
| 248 | else: |
| 249 | self.title = title |
| 250 | else: |
| 251 | # Assume it's a string or something that can be converted to one |
| 252 | self.fname = src |
| 253 | if title == '': |
| 254 | (filepath, filename) = os.path.split(src) |
| 255 | self.title = filename |
| 256 | else: |
| 257 | self.title = title |
| 258 | self.sys_argv = [src] + shlex.split(arg_str) |
| 259 | self.auto_all = auto_all |
| 260 | self.src = src |
| 261 | |
| 262 | try: |
| 263 | ip = get_ipython() # this is in builtins whenever IPython is running |
nothing calls this directly
no test coverage detected