GEPS 006: Add Locality to Address and GEDCOM Import/Export

svn: r16071
This commit is contained in:
Nick Hall
2010-10-28 17:55:15 +00:00
parent 6a473c8a54
commit 9df5336fde
6 changed files with 106 additions and 34 deletions

View File

@@ -6,6 +6,7 @@
# Copyright (C) 2008-2009 Gary Burton
# Copyright (C) 2008 Robert Cheramy <robert@cheramy.net>
# Copyright (C) 2010 Jakim Friant
# Copyright (C) 2010 Nick Hall
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -361,6 +362,7 @@ class GedcomWriter(UpdateCallback):
owner = self.dbase.get_researcher()
name = owner.get_name()
addr = owner.get_address()
adr2 = owner.get_locality()
city = owner.get_city()
state = owner.get_state()
ctry = owner.get_country()
@@ -380,6 +382,8 @@ class GedcomWriter(UpdateCallback):
self.__writeln(2, "CONT", "%s, %s %s" % (city, state, post))
else:
self.__writeln(2, "CONT", u"Not Provided")
if adr2:
self.__writeln(2, "ADR2", adr2)
if city:
self.__writeln(2, "CITY", city)
if state:
@@ -679,6 +683,8 @@ class GedcomWriter(UpdateCallback):
self.__writeln(1, 'RESI')
self.__date(2, addr.get_date_object())
self.__writeln(2, "ADDR", addr.get_street())
if addr.get_locality():
self.__writeln(3, 'ADR2', addr.get_locality())
if addr.get_city():
self.__writeln(3, 'CITY', addr.get_city())
if addr.get_state():
@@ -1005,6 +1011,8 @@ class GedcomWriter(UpdateCallback):
self.__writeln(1, 'NAME', repo.get_name())
for addr in repo.get_address_list():
self.__writeln(1, "ADDR", addr.get_street())
if addr.get_locality():
self.__writeln(2, 'ADR2', addr.get_locality())
if addr.get_city():
self.__writeln(2, 'CITY', addr.get_city())
if addr.get_state():
@@ -1359,6 +1367,8 @@ class GedcomWriter(UpdateCallback):
location = place.get_main_location()
if location and not location.is_empty():
self.__writeln(level, "ADDR", location.get_street())
if location.get_locality():
self.__writeln(level + 1, 'ADR2', location.get_locality())
if location.get_city():
self.__writeln(level + 1, 'CITY', location.get_city())
if location.get_state():

View File

@@ -3,6 +3,7 @@
#
# Copyright (C) 2000-2007 Donald N. Allingham
# Copyright (C) 2009-2010 Gary Burton
# Copyright (C) 2010 Nick Hall
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -1513,6 +1514,11 @@ class PlaceParser(object):
'subdivision' : gen.lib.Location.set_street,
'addr1' : gen.lib.Location.set_street,
'adr1' : gen.lib.Location.set_street,
'street' : gen.lib.Location.set_street,
'addr2' : gen.lib.Location.set_locality,
'adr2' : gen.lib.Location.set_locality,
'locality' : gen.lib.Location.set_locality,
'neighborhood' : gen.lib.Location.set_locality,
'city' : gen.lib.Location.set_city,
'town' : gen.lib.Location.set_city,
'village' : gen.lib.Location.set_city,
@@ -1523,6 +1529,8 @@ class PlaceParser(object):
'region' : gen.lib.Location.set_state,
'province' : gen.lib.Location.set_state,
'area code' : gen.lib.Location.set_postal_code,
'post code' : gen.lib.Location.set_postal_code,
'zip code' : gen.lib.Location.set_postal_code,
}
def __init__(self, line=None):
@@ -2029,7 +2037,7 @@ class GedcomParser(UpdateCallback):
self.parse_loc_tbl = {
TOKEN_ADDR : self.__location_addr,
TOKEN_ADR1 : self.__location_addr,
TOKEN_ADR2 : self.__location_addr,
TOKEN_ADR2 : self.__location_adr2,
TOKEN_DATE : self.__location_date,
TOKEN_CITY : self.__location_city,
TOKEN_STAE : self.__location_stae,
@@ -2128,6 +2136,7 @@ class GedcomParser(UpdateCallback):
self.parse_addr_tbl = {
TOKEN_DATE : self.__address_date,
TOKEN_ADR2 : self.__address_adr2,
TOKEN_CITY : self.__address_city,
TOKEN_STAE : self.__address_state,
TOKEN_POST : self.__address_post,
@@ -3044,8 +3053,8 @@ class GedcomParser(UpdateCallback):
n ADDR <ADDRESS_LINE> {0:1}
+1 CONT <ADDRESS_LINE> {0:M}
+1 ADR1 <ADDRESS_LINE1> {0:1}
+1 ADR2 <ADDRESS_LINE2> {0:1}
+1 ADR1 <ADDRESS_LINE1> {0:1} (Street)
+1 ADR2 <ADDRESS_LINE2> {0:1} (Locality)
+1 CITY <ADDRESS_CITY> {0:1}
+1 STAE <ADDRESS_STATE> {0:1}
+1 POST <ADDRESS_POSTAL_CODE> {0:1}
@@ -4635,6 +4644,17 @@ class GedcomParser(UpdateCallback):
"""
state.addr.set_date_object(line.data)
def __address_adr2(self, line, state):
"""
Parses the ADR2 line of an ADDR tag
@param line: The current line in GedLine format
@type line: GedLine
@param state: The current state
@type state: CurrentState
"""
state.addr.set_locality(line.data)
def __address_city(self, line, state):
"""
Parses the CITY line of an ADDR tag
@@ -5249,8 +5269,8 @@ class GedcomParser(UpdateCallback):
"""
n ADDR <ADDRESS_LINE> {0:1}
+1 CONT <ADDRESS_LINE> {0:M}
+1 ADR1 <ADDRESS_LINE1> {0:1}
+1 ADR2 <ADDRESS_LINE2> {0:1}
+1 ADR1 <ADDRESS_LINE1> {0:1} (Street)
+1 ADR2 <ADDRESS_LINE2> {0:1} (Locality)
+1 CITY <ADDRESS_CITY> {0:1}
+1 STAE <ADDRESS_STATE> {0:1}
+1 POST <ADDRESS_POSTAL_CODE> {0:1}
@@ -5328,6 +5348,17 @@ class GedcomParser(UpdateCallback):
state.location = gen.lib.Location()
state.location.set_date_object(line.data)
def __location_adr2(self, line, state):
"""
@param line: The current line in GedLine format
@type line: GedLine
@param state: The current state
@type state: CurrentState
"""
if not state.location:
state.location = gen.lib.Location()
state.location.set_locality(line.data)
def __location_city(self, line, state):
"""
@param line: The current line in GedLine format
@@ -5796,6 +5827,7 @@ class GedcomParser(UpdateCallback):
location = sub_state.location
state.res.set_address(location.get_street())
state.res.set_locality(location.get_locality())
state.res.set_city(location.get_city())
state.res.set_state(location.get_state())
state.res.set_country(location.get_country())