dosage/scripts/scriptutil.py

29 lines
561 B
Python
Raw Normal View History

2012-11-29 05:46:58 +00:00
# Copyright (C) 2012 Bastian Kleineidam
2012-12-12 16:41:29 +00:00
import re
2012-11-29 05:46:58 +00:00
def contains_case_insensitive(adict, akey):
for key in adict:
if key.lower() == akey.lower():
return True
return False
2012-12-12 16:41:29 +00:00
_tagre = re.compile(r"<.+?>")
def remove_html_tags(text):
return _tagre.sub("", text)
def capfirst(text):
"""Uppercase the first character of text."""
if not text:
return text
return text[0].upper() + text[1:]
_ws = re.compile(r"\s+")
def compact_whitespace(text):
if not text:
return text
return _ws.sub(" ", text)