Mercurial Hosting > traffic-intelligence
diff python/utils.py @ 971:9897a13772fb
added utils to load video sequence in metadata
author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
---|---|
date | Wed, 13 Dec 2017 14:06:20 -0500 |
parents | 5d788d2e8ffc |
children | 4f3f88a27dae |
line wrap: on
line diff
--- a/python/utils.py Thu Dec 07 23:31:54 2017 -0500 +++ b/python/utils.py Wed Dec 13 14:06:20 2017 -0500 @@ -4,6 +4,7 @@ import matplotlib.pyplot as plt from datetime import time, datetime +from argparse import ArgumentTypeError from math import sqrt, ceil, floor from scipy.stats import kruskal, shapiro, lognorm from scipy.spatial import distance @@ -24,6 +25,17 @@ lowerWords = [w[0].upper()+w[1:].lower() for w in words] return ' '.join(lowerWords) +class TimeConverter: + def __init__(self, datetimeFormat = datetimeFormat): + self.datetimeFormat = datetimeFormat + + def convert(self, s): + try: + return datetime.strptime(s, self.datetimeFormat) + except ValueError: + msg = "Not a valid date: '{0}'.".format(s) + raise ArgumentTypeError(msg) + ######################### # Enumerations #########################