##// END OF EJS Templates
Add full docstring to strip_email_quotes
Fernando Perez -
Show More
@@ -560,6 +560,35 b' def long_substr(data):'
560 560
561 561 def strip_email_quotes(text):
562 562 """Strip leading email quotation characters ('>').
563
564 Removes any combination of leading '>' interspersed with whitespace that
565 appears *identically* in all lines of the input text.
566
567 Parameters
568 ----------
569 text : str
570
571 Examples
572 --------
573
574 Simple uses::
575
576 In [2]: strip_email_quotes('> > text')
577 Out[2]: 'text'
578
579 In [3]: strip_email_quotes('> > text\n> > more')
580 Out[3]: 'text\nmore'
581
582 Note how only the common prefix that appears in all lines is stripped::
583
584 In [4]: strip_email_quotes('> > text\n> > more\n> more...')
585 Out[4]: '> text\n> more\nmore...'
586
587 So if any line has no quote marks ('>') , then none are stripped from any
588 of them ::
589
590 In [5]: strip_email_quotes('> > text\n> > more\nlast different')
591 Out[5]: '> > text\n> > more\nlast different'
563 592 """
564 593 lines = text.splitlines()
565 594 matches = set()
@@ -601,6 +630,7 b' class EvalFormatter(Formatter):'
601 630 v = eval(name, kwargs)
602 631 return v, name
603 632
633
604 634 @skip_doctest_py3
605 635 class FullEvalFormatter(Formatter):
606 636 """A String Formatter that allows evaluation of simple expressions.
@@ -658,6 +688,7 b' class FullEvalFormatter(Formatter):'
658 688
659 689 return u''.join(py3compat.cast_unicode(s) for s in result)
660 690
691
661 692 @skip_doctest_py3
662 693 class DollarFormatter(FullEvalFormatter):
663 694 """Formatter allowing Itpl style $foo replacement, for names and attribute
@@ -700,11 +731,13 b' class DollarFormatter(FullEvalFormatter):'
700 731 #-----------------------------------------------------------------------------
701 732 # Utils to columnize a list of string
702 733 #-----------------------------------------------------------------------------
734
703 735 def _chunks(l, n):
704 736 """Yield successive n-sized chunks from l."""
705 737 for i in xrange(0, len(l), n):
706 738 yield l[i:i+n]
707 739
740
708 741 def _find_optimal(rlist , separator_size=2 , displaywidth=80):
709 742 """Calculate optimal info to columnize a list of string"""
710 743 for nrow in range(1, len(rlist)+1) :
@@ -719,6 +752,7 b' def _find_optimal(rlist , separator_size=2 , displaywidth=80):'
719 752 'columns_width' : chk
720 753 }
721 754
755
722 756 def _get_or_default(mylist, i, default=None):
723 757 """return list item number, or default if don't exist"""
724 758 if i >= len(mylist):
@@ -726,6 +760,7 b' def _get_or_default(mylist, i, default=None):'
726 760 else :
727 761 return mylist[i]
728 762
763
729 764 @skip_doctest
730 765 def compute_item_matrix(items, empty=None, *args, **kwargs) :
731 766 """Returns a nested list, and info to columnize items
@@ -783,6 +818,7 b' def compute_item_matrix(items, empty=None, *args, **kwargs) :'
783 818 nrow, ncol = info['rows_numbers'], info['columns_numbers']
784 819 return ([[ _get_or_default(items, c*nrow+i, default=empty) for c in range(ncol) ] for i in range(nrow) ], info)
785 820
821
786 822 def columnize(items, separator=' ', displaywidth=80):
787 823 """ Transform a list of strings into a single string with columns.
788 824
General Comments 0
You need to be logged in to leave comments. Login now