quote_matcher = re.compile(config.quote_regexp, flags=re.UNICODE)
quote_matcher_with_timestamp = re.compile(config.quote_regexp_with_timestamp, flags=re.UNICODE)
+spaces_matcher = re.compile(u"\s", flags=re.U)
def get_now():
""" Renvoie la date actuelle """
return datetime.datetime(*time.localtime()[:6])
+def sanitize_author(raw):
+ """Proprifie l'auteur : enlève les espaces insécables."""
+ return spaces_matcher.sub(u" ", raw)
+
class Quote(object):
""" Une citation """
def __init__(self, author, content, timestamp=None):
timestamp = get_now()
elif isinstance(timestamp, basestring):
timestamp = datetime.datetime(*time.strptime(timestamp, u"%Y-%m-%d_%H:%M:%S")[:6])
- self.author = author
+ self.author = sanitize_author(author)
self.content = content
self.timestamp = timestamp