Trees | Index | Help |
|
---|
Package logilab :: Package common :: Module textutils |
|
Some text manipulation utility functions.
Version:
$Revision: 1.2 $
Author:
Logilab
Contact:
http://www.logilab.fr/ -- mailto:python-projects@logilab.org
Copyright:
2003-2005 LOGILAB S.A. (Paris, FRANCE)
Function Summary | |
---|---|
str |
return ansi escape code corresponding to color and style |
text formatting | |
str or unicode |
normalize a text to display it with a maximum line size and optionaly arbitrary indentation. |
str or unicode |
normalize a text to display it with a maximum line size and optionaly arbitrary indentation. |
str or unicode |
return a string with the match location underlined: |
str or unicode |
remove optional quotes (simple or double) from the string |
str or unicode |
colorize message by wrapping it with ansi escape codes |
text manipulation | |
apply a regexp using "search" until no more match is found | |
str or unicode |
return a list of string in from a csv formatted line |
Variable Summary | |
---|---|
str |
__revision__ = '$Id: textutils.py,v 1.23 2005/02/08 17:2...
|
dict(str) |
ANSI_COLORS : dictionary mapping color identifier to ANSI terminal code |
str |
ANSI_END : ANSI terminal code notifing the end of an ANSI escape sequence |
str |
ANSI_PREFIX : ANSI terminal code notifing the start of an ANSI escape sequence |
str |
ANSI_RESET : ANSI terminal code reseting format defined by a previous ANSI escape sequence |
dict(str) |
ANSI_STYLES : dictionary mapping style identifier to ANSI terminal code |
SRE_Pattern |
_BLANKLINES_RGX = \r?\n\r?\n
|
SRE_Pattern |
_LINE_RGX = \r\n|\r+|\n
|
SRE_Pattern |
_NORM_SPACES_RGX = \s+
|
Function Details |
---|
normalize_text(text, line_len=80, indent='')normalize a text to display it with a maximum line size and optionaly arbitrary indentation. Line jumps are normalized but blank lines are kept. The indentation string may be used top insert a comment mark for instance.
|
normalize_paragraph(text, line_len=80, indent='')normalize a text to display it with a maximum line size and optionaly arbitrary indentation. Line jumps are normalized. The indentation string may be used top insert a comment mark for instance.
|
pretty_match(match, string, underline_char='^')return a string with the match location underlined: >>> import re >>> print pretty_match(re.search('mange', 'il mange du bacon'), 'il mange du bacon') il mange du bacon ^^^^^ >>>
|
unquote(string)remove optional quotes (simple or double) from the string
|
colorize_ansi(msg, color=None, style=None)colorize message by wrapping it with ansi escape codes
|
searchall(rgx, data)apply a regexp using "search" until no more match is found This function is deprecated, use re.finditer() instead. |
get_csv(string, sep=',')return a list of string in from a csv formatted line >>> get_csv('a, b, c , 4') ['a', 'b', 'c', '4'] >>> get_csv('a') ['a'] >>>
|
_get_ansi_code(color=None, style=None)return ansi escape code corresponding to color and style
|
Variable Details |
---|
__revision__
|
ANSI_ENDANSI terminal code notifing the end of an ANSI escape sequence
|
ANSI_PREFIXANSI terminal code notifing the start of an ANSI escape sequence
|
ANSI_RESETANSI terminal code reseting format defined by a previous ANSI escape sequence
|
ANSI_STYLESdictionary mapping style identifier to ANSI terminal code
|
_BLANKLINES_RGX
|
_LINE_RGX
|
_NORM_SPACES_RGX
|
Trees | Index | Help |
|
---|
Generated by Epydoc 2.1 on Thu Apr 14 11:37:31 2005 | http://epydoc.sf.net |