##// END OF EJS Templates
Remove utils.io.nlprint
Thomas Kluyver -
Show More
@@ -31,7 +31,6 b' from IPython.core.magic import ('
31 31 Magics, compress_dhist, magics_class, line_magic, cell_magic, line_cell_magic
32 32 )
33 33 from IPython.testing.skipdoctest import skip_doctest
34 from IPython.utils.io import nlprint
35 34 from IPython.utils.openpy import source_to_unicode
36 35 from IPython.utils.path import unquote_filename
37 36 from IPython.utils.process import abbrev_cwd
@@ -403,7 +402,7 b' class OSMagics(Magics):'
403 402
404 403 %dhist -> print full history\\
405 404 %dhist n -> print last n entries only\\
406 %dhist n1 n2 -> print entries between n1 and n2 (n1 not included)\\
405 %dhist n1 n2 -> print entries between n1 and n2 (n2 not included)\\
407 406
408 407 This history is automatically maintained by the %cd command, and
409 408 always available as the global list variable _dh. You can use %cd -<n>
@@ -425,14 +424,15 b' class OSMagics(Magics):'
425 424 ini,fin = max(len(dh)-(args[0]),0),len(dh)
426 425 elif len(args) == 2:
427 426 ini,fin = args
427 fin = min(fin, len(dh))
428 428 else:
429 429 self.arg_err(self.dhist)
430 430 return
431 431 else:
432 432 ini,fin = 0,len(dh)
433 nlprint(dh,
434 header = 'Directory history (kept in _dh)',
435 start=ini,stop=fin)
433 print 'Directory history (kept in _dh)'
434 for i in range(ini, fin):
435 print "%d: %s" % (i, dh[i])
436 436
437 437 @skip_doctest
438 438 @line_magic
@@ -242,44 +242,6 b' def ask_yes_no(prompt,default=None):'
242 242 return answers[ans]
243 243
244 244
245 class NLprinter:
246 """Print an arbitrarily nested list, indicating index numbers.
247
248 An instance of this class called nlprint is available and callable as a
249 function.
250
251 nlprint(list,indent=' ',sep=': ') -> prints indenting each level by 'indent'
252 and using 'sep' to separate the index from the value. """
253
254 def __init__(self):
255 self.depth = 0
256
257 def __call__(self,lst,pos='',**kw):
258 """Prints the nested list numbering levels."""
259 kw.setdefault('indent',' ')
260 kw.setdefault('sep',': ')
261 kw.setdefault('start',0)
262 kw.setdefault('stop',len(lst))
263 # we need to remove start and stop from kw so they don't propagate
264 # into a recursive call for a nested list.
265 start = kw['start']; del kw['start']
266 stop = kw['stop']; del kw['stop']
267 if self.depth == 0 and 'header' in kw.keys():
268 print(kw['header'])
269
270 for idx in range(start,stop):
271 elem = lst[idx]
272 newpos = pos + str(idx)
273 if type(elem)==type([]):
274 self.depth += 1
275 self.__call__(elem, newpos+",", **kw)
276 self.depth -= 1
277 else:
278 print(kw['indent']*self.depth + newpos + kw["sep"] + repr(elem))
279
280 nlprint = NLprinter()
281
282
283 245 def temp_pyfile(src, ext='.py'):
284 246 """Make a temporary python file, return filename and filehandle.
285 247
@@ -30,7 +30,6 b' from string import Formatter'
30 30 from IPython.external.path import path
31 31 from IPython.testing.skipdoctest import skip_doctest_py3, skip_doctest
32 32 from IPython.utils import py3compat
33 from IPython.utils.io import nlprint
34 33 from IPython.utils.data import flatten
35 34
36 35 #-----------------------------------------------------------------------------
@@ -265,7 +264,7 b' class SList(list):'
265 264 # arg.hideonce = False
266 265 # return
267 266 #
268 # nlprint(arg)
267 # nlprint(arg) # This was a nested list printer, now removed.
269 268 #
270 269 # print_slist = result_display.when_type(SList)(print_slist)
271 270
General Comments 0
You need to be logged in to leave comments. Login now