MCPcopy Create free account
hub / github.com/ipython/ipython / marquee

Function marquee

IPython/utils/text.py:312–334  ·  view source on GitHub ↗

Return the input string centered in a 'marquee'. Examples -------- :: In [16]: marquee('A test',40) Out[16]: '**************** A test ****************' In [17]: marquee('A test',40,'-') Out[17]: '---------------- A test ----------------' In [18

(txt='',width=78,mark='*')

Source from the content-addressed store, hash-verified

310
311
312def marquee(txt='',width=78,mark='*'):
313 """Return the input string centered in a 'marquee'.
314
315 Examples
316 --------
317 ::
318
319 In [16]: marquee('A test',40)
320 Out[16]: '**************** A test ****************'
321
322 In [17]: marquee('A test',40,'-')
323 Out[17]: '---------------- A test ----------------'
324
325 In [18]: marquee('A test',40,' ')
326 Out[18]: ' A test '
327
328 """
329 if not txt:
330 return (mark*width)[:width]
331 nmark = (width-len(txt)-2)//len(mark)//2
332 if nmark < 0: nmark =0
333 marks = mark*nmark
334 return '%s %s %s' % (marks,txt,marks)
335
336
337ini_spaces_re = re.compile(r'^(\s+)')

Callers 3

show_allMethod · 0.90
__call__Method · 0.90
marqueeMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected