1 # -*- coding: utf-8 -*-
2 from datetime import date
6 from person import Person
9 def str_to_unicode(value):
13 def str_to_person(value):
14 comma_count = value.count(',')
17 last_name, first_names = value, []
18 elif comma_count == 1:
19 last_name, first_names = value.split(',')
20 first_names = [name for name in first_names.split(' ') if len(name)]
22 raise ValueError("value contains more than one comma: %r" % value)
24 return Person(last_name.strip(), *first_names)
27 def str_to_date(value):
29 t = time.strptime(value, '%Y-%m-%d')
31 t = time.strptime(value, '%Y')
32 return date(t[0], t[1], t[2])