Events and States will now only use JSON serializable attributes

This commit is contained in:
Paulus Schoutsen committed 2013-10-27 17:39:54 -07:00
1 parent 1da1713d2f
commit 83d878810e
7 files changed
+122 -84

No files matched your search

-10
View File
@@ -1,18 +1,8 @@
""" Helper methods for various modules. """
from datetime import datetime
import re
DATE_STR_FORMAT = "%H:%M:%S %d-%m-%Y"
def sanitize_filename(filename):
""" Sanitizes a filename by removing .. / and \\. """
return re.sub(r"(~|(\.\.)|/|\+)", "", filename)
def datetime_to_str(dattim):
""" Converts datetime to a string format. """
return dattim.strftime(DATE_STR_FORMAT)
def str_to_datetime(dt_str):
""" Converts a string to a datetime object. """
return datetime.strptime(dt_str, DATE_STR_FORMAT)