summaryrefslogtreecommitdiff
path: root/textutils.py
diff options
context:
space:
mode:
authorSylvain Th?nault <sylvain.thenault@logilab.fr>2009-08-01 16:33:25 +0200
committerSylvain Th?nault <sylvain.thenault@logilab.fr>2009-08-01 16:33:25 +0200
commit8065d7f85a5a98af17496d1c4be39e65d772089d (patch)
treed85ead7be72e3e8f3808970f7bb32ff7351dc971 /textutils.py
parentc9996a3223803ed28c2484eac78cca243be362d2 (diff)
downloadlogilab-common-8065d7f85a5a98af17496d1c4be39e65d772089d.tar.gz
rename get_csv into splitstrip
Diffstat (limited to 'textutils.py')
-rw-r--r--textutils.py16
1 files changed, 10 insertions, 6 deletions
diff --git a/textutils.py b/textutils.py
index 8aabea2..c25d8c8 100644
--- a/textutils.py
+++ b/textutils.py
@@ -7,7 +7,7 @@
:group text formatting: normalize_text, normalize_paragraph, pretty_match,\
unquote, colorize_ansi
-:group text manipulation: searchall, get_csv
+:group text manipulation: searchall, splitstrip
:sort: text formatting, text manipulation
:type ANSI_STYLES: dict(str)
@@ -37,6 +37,7 @@ try:
except ImportError:
linesep = '\n' # gae
+from logilab.common.deprecation import deprecated
MANUAL_UNICODE_MAP = {
u'\xa1': u'!', # INVERTED EXCLAMATION MARK
@@ -211,12 +212,13 @@ def splittext(text, line_len):
return text[:pos], text[pos+1:].strip()
-def get_csv(string, sep=','):
- """return a list of string in from a csv formatted line
+def splitstrip(string, sep=','):
+ """return a list of stripped string by splitting the string given as
+ argument on `sep` (',' by default). Empty string are discarded.
- >>> get_csv('a, b, c , 4')
+ >>> splitstrip('a, b, c , 4,,')
['a', 'b', 'c', '4']
- >>> get_csv('a')
+ >>> splitstrip('a')
['a']
>>>
@@ -231,6 +233,8 @@ def get_csv(string, sep=','):
"""
return [word.strip() for word in string.split(sep) if word.strip()]
+get_csv = deprecated()(splitstrip)
+
_BLANK_URE = r'(\s|,)+'
_BLANK_RE = re.compile(_BLANK_URE)
__VALUE_URE = r'-?(([0-9]+\.[0-9]*)|((0x?)?[0-9]+))'
@@ -392,7 +396,7 @@ def _get_ansi_code(color=None, style=None):
"""
ansi_code = []
if style:
- style_attrs = get_csv(style)
+ style_attrs = splitstrip(style)
for effect in style_attrs:
ansi_code.append(ANSI_STYLES[effect])
if color: