[utils] Add remove_quotes

This commit is contained in:
Sergey M․ 2015-12-14 21:30:58 +06:00
parent eb0bdc2c3e
commit 31b2051e21
2 changed files with 19 additions and 0 deletions

View file

@ -1406,6 +1406,15 @@ def remove_end(s, end):
return s
def remove_quotes(s):
if s is None or len(s) < 2:
return s
for quote in ('"', "'", ):
if s[0] == quote and s[-1] == quote:
return s[1:-1]
return s
def url_basename(url):
path = compat_urlparse.urlparse(url).path
return path.strip('/').split('/')[-1]