better parse location in aum
This commit is contained in:
parent
ff28c1bd51
commit
1acd27dee7
1 changed files with 3 additions and 4 deletions
|
|
@ -65,7 +65,7 @@ class FieldOld(FieldBase):
|
||||||
print str(e)
|
print str(e)
|
||||||
|
|
||||||
class FieldLocation(FieldBase):
|
class FieldLocation(FieldBase):
|
||||||
location = re.compile('(.*) \(([0-9]{5})\), (.*)')
|
location = re.compile('(?P<location>.+?)( \((?P<zipcode>[0-9]{5})\))?, (?P<country>.*)')
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
FieldBase.__init__(self, '')
|
FieldBase.__init__(self, '')
|
||||||
|
|
@ -73,9 +73,8 @@ class FieldLocation(FieldBase):
|
||||||
# TODO: determine distance, or something like
|
# TODO: determine distance, or something like
|
||||||
m = self.location.match(value)
|
m = self.location.match(value)
|
||||||
if m:
|
if m:
|
||||||
d['location'] = m.group(1)
|
for field in ('country', 'location', 'zipcode'):
|
||||||
d['zipcode'] = int(m.group(2))
|
d[field] = m.groupdict().get(field)
|
||||||
d['country'] = m.group(3)
|
|
||||||
else:
|
else:
|
||||||
warning('Unable to parse the location "%s"' % value)
|
warning('Unable to parse the location "%s"' % value)
|
||||||
d['location'] = unicode(value)
|
d['location'] = unicode(value)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue