Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

allow strips to accept lists (fixes #69)

  • Loading branch information...
commit a01f46540ba6f09e050c3eeb1898995574e98779 1 parent fa8151d
Aaron Swartz aaronsw authored
Showing with 11 additions and 0 deletions.
  1. +11 −0 web/utils.py
11 web/utils.py
View
@@ -273,6 +273,11 @@ class _hack(tuple): pass
"""
def _strips(direction, text, remove):
+ if isinstance(remove, iters):
+ for subr in remove:
+ text = _strips(direction, text, subr)
+ return text
+
if direction == 'l':
if text.startswith(remove):
return text[len(remove):]
@@ -299,6 +304,12 @@ def lstrips(text, remove):
>>> lstrips("foobar", "foo")
'bar'
+ >>> lstrips('http://foo.org/', ['http://', 'https://'])
+ 'foo.org/'
+ >>> lstrips('FOOBARBAZ', ['FOO', 'BAR'])
+ 'BAZ'
+ >>> lstrips('FOOBARBAZ', ['BAR', 'FOO'])
+ 'BARBAZ'
"""
return _strips('l', text, remove)
Please sign in to comment.
Something went wrong with that request. Please try again.