From 2b91dffa4c056bc5d6257a78a2ac02487550bd3b 2013-02-05 14:45:45 From: Thomas Kluyver Date: 2013-02-05 14:45:45 Subject: [PATCH] Remove more unused functions from utils.text --- diff --git a/IPython/utils/text.py b/IPython/utils/text.py index 8d52935..44b19b9 100644 --- a/IPython/utils/text.py +++ b/IPython/utils/text.py @@ -36,18 +36,6 @@ from IPython.utils.data import flatten # Code #----------------------------------------------------------------------------- -def unquote_ends(istr): - """Remove a single pair of quotes from the endpoints of a string.""" - - if not istr: - return istr - if (istr[0]=="'" and istr[-1]=="'") or \ - (istr[0]=='"' and istr[-1]=='"'): - return istr[1:-1] - else: - return istr - - class LSString(str): """String derivative with a special access attributes. @@ -269,58 +257,6 @@ class SList(list): # print_slist = result_display.when_type(SList)(print_slist) -def esc_quotes(strng): - """Return the input string with single and double quotes escaped out""" - - return strng.replace('"','\\"').replace("'","\\'") - - -def qw(words,flat=0,sep=None,maxsplit=-1): - """Similar to Perl's qw() operator, but with some more options. - - qw(words,flat=0,sep=' ',maxsplit=-1) -> words.split(sep,maxsplit) - - words can also be a list itself, and with flat=1, the output will be - recursively flattened. - - Examples: - - >>> qw('1 2') - ['1', '2'] - - >>> qw(['a b','1 2',['m n','p q']]) - [['a', 'b'], ['1', '2'], [['m', 'n'], ['p', 'q']]] - - >>> qw(['a b','1 2',['m n','p q']],flat=1) - ['a', 'b', '1', '2', 'm', 'n', 'p', 'q'] - """ - - if isinstance(words, basestring): - return [word.strip() for word in words.split(sep,maxsplit) - if word and not word.isspace() ] - if flat: - return flatten(map(qw,words,[1]*len(words))) - return map(qw,words) - - -def qwflat(words,sep=None,maxsplit=-1): - """Calls qw(words) in flat mode. It's just a convenient shorthand.""" - return qw(words,1,sep,maxsplit) - - -def qw_lol(indata): - """qw_lol('a b') -> [['a','b']], - otherwise it's just a call to qw(). - - We need this to make sure the modules_some keys *always* end up as a - list of lists.""" - - if isinstance(indata, basestring): - return [qw(indata)] - else: - return qw(indata) - - def indent(instr,nspaces=4, ntabs=0, flatten=False): """Indent a string a given number of spaces or tabstops.