/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/transport/http/__init__.py

  • Committer: Martin Pool
  • Date: 2010-10-08 07:17:16 UTC
  • mto: This revision was merged to the branch mainline in revision 5478.
  • Revision ID: mbp@sourcefrog.net-20101008071716-rv32lh1giawdvsd9
Add test for unhtml_roughly, and truncate at 1000 bytes

Show diffs side-by-side

added added

removed removed

Lines of Context:
668
668
        pass
669
669
 
670
670
 
671
 
def unhtml_roughly(maybe_html):
 
671
def unhtml_roughly(maybe_html, length_limit=1000):
672
672
    """Very approximate html->text translation, for presenting error bodies.
673
673
 
 
674
    :param length_limit: Truncate the result to this many characters.
 
675
 
674
676
    >>> unhtml_roughly("<b>bad</b> things happened\\n")
675
677
    ' bad  things happened '
676
678
    """
677
 
    return re.subn(r"(<[^>]*>|\n|&nbsp;)", " ", maybe_html)[0]
 
679
    return re.subn(r"(<[^>]*>|\n|&nbsp;)", " ", maybe_html)[0][:length_limit]