2007-07-21 Don Allingham <don@gramps-project.org>
* src/plugins/ExtractCity.py: improved extraction, fix registration * src/plugins/EventNames.py: fix registration svn: r8752
This commit is contained in:
parent
0b54846df9
commit
de7f21ebc0
@ -1,3 +1,7 @@
|
|||||||
|
2007-07-21 Don Allingham <don@gramps-project.org>
|
||||||
|
* src/plugins/ExtractCity.py: improved extraction, fix registration
|
||||||
|
* src/plugins/EventNames.py: fix registration
|
||||||
|
|
||||||
2007-07-21 Brian Matherly <brian@gramps-project.org>
|
2007-07-21 Brian Matherly <brian@gramps-project.org>
|
||||||
* src/plugins/IndivComplete.py:
|
* src/plugins/IndivComplete.py:
|
||||||
* src/plugins/DetDescendantReport.py:
|
* src/plugins/DetDescendantReport.py:
|
||||||
|
@ -70,7 +70,7 @@ class EventNames(Tool.BatchTool, ManagedWindow.ManagedWindow):
|
|||||||
|
|
||||||
Tool.BatchTool.__init__(self, dbstate, options_class, name)
|
Tool.BatchTool.__init__(self, dbstate, options_class, name)
|
||||||
|
|
||||||
if self.fail:
|
if not self.fail:
|
||||||
uistate.set_busy_cursor(True)
|
uistate.set_busy_cursor(True)
|
||||||
self.run()
|
self.run()
|
||||||
uistate.set_busy_cursor(False)
|
uistate.set_busy_cursor(False)
|
||||||
@ -157,7 +157,7 @@ class EventNamesOptions(Tool.ToolOptions):
|
|||||||
#
|
#
|
||||||
#------------------------------------------------------------------------
|
#------------------------------------------------------------------------
|
||||||
register_tool(
|
register_tool(
|
||||||
name = 'chname',
|
name = 'evname',
|
||||||
category = Tool.TOOL_DBPROC,
|
category = Tool.TOOL_DBPROC,
|
||||||
tool_class = EventNames,
|
tool_class = EventNames,
|
||||||
options_class = EventNamesOptions,
|
options_class = EventNamesOptions,
|
||||||
|
@ -47,7 +47,244 @@ import ManagedWindow
|
|||||||
|
|
||||||
from PluginUtils import Tool, register_tool
|
from PluginUtils import Tool, register_tool
|
||||||
|
|
||||||
CITY_STATE = re.compile("^(.+), \s*(\S\S)(\s+[\d-])?")
|
CITY_STATE = re.compile("^(.+),\s*([\w\s\.]+),?(\s+[\d-])?")
|
||||||
|
|
||||||
|
COUNTRY = ( "United States of America", "Canada")
|
||||||
|
|
||||||
|
STATE_MAP = {
|
||||||
|
"AL" : ("Alabama", 0),
|
||||||
|
"AL." : ("Alabama", 0),
|
||||||
|
"ALABAMA" : ("Alabama", 0),
|
||||||
|
"AK" : ("Alaska" , 0),
|
||||||
|
"AK." : ("Alaska" , 0),
|
||||||
|
"ALASKA" : ("Alaska" , 0),
|
||||||
|
"AS" : ("American Samoa", 0),
|
||||||
|
"AS." : ("American Samoa", 0),
|
||||||
|
"AMERICAN SAMOA" : ("American Samoa", 0),
|
||||||
|
"AZ" : ("Arizona", 0),
|
||||||
|
"AZ." : ("Arizona", 0),
|
||||||
|
"ARIZONA" : ("Arizona", 0),
|
||||||
|
"AR" : ("Arkansas" , 0),
|
||||||
|
"AR." : ("Arkansas" , 0),
|
||||||
|
"ARKANSAS" : ("Arkansas" , 0),
|
||||||
|
"ARK." : ("Arkansas" , 0),
|
||||||
|
"ARK" : ("Arkansas" , 0),
|
||||||
|
"CA" : ("California" , 0),
|
||||||
|
"CA." : ("California" , 0),
|
||||||
|
"CALIFORNIA" : ("California" , 0),
|
||||||
|
"CO" : ("Colorado" , 0),
|
||||||
|
"COLO" : ("Colorado" , 0),
|
||||||
|
"COLO." : ("Colorado" , 0),
|
||||||
|
"COLORADO" : ("Colorado" , 0),
|
||||||
|
"CT" : ("Connecticut" , 0),
|
||||||
|
"CT." : ("Connecticut" , 0),
|
||||||
|
"CONNECTICUT" : ("Connecticut" , 0),
|
||||||
|
"DE" : ("Delaware" , 0),
|
||||||
|
"DE." : ("Delaware" , 0),
|
||||||
|
"DELAWARE" : ("Delaware" , 0),
|
||||||
|
"DC" : ("District of Columbia" , 0),
|
||||||
|
"D.C." : ("District of Columbia" , 0),
|
||||||
|
"DC." : ("District of Columbia" , 0),
|
||||||
|
"DISTRICT OF COLUMBIA" : ("District of Columbia" , 0),
|
||||||
|
"FL" : ("Florida" , 0),
|
||||||
|
"FL." : ("Florida" , 0),
|
||||||
|
"FLA" : ("Florida" , 0),
|
||||||
|
"FLA." : ("Florida" , 0),
|
||||||
|
"FLORIDA" : ("Florida" , 0),
|
||||||
|
"GA" : ("Georgia" , 0),
|
||||||
|
"GA." : ("Georgia" , 0),
|
||||||
|
"GEORGIA" : ("Georgia" , 0),
|
||||||
|
"GU" : ("Guam" , 0),
|
||||||
|
"GU." : ("Guam" , 0),
|
||||||
|
"GUAM" : ("Guam" , 0),
|
||||||
|
"HI" : ("Hawaii" , 0),
|
||||||
|
"HI." : ("Hawaii" , 0),
|
||||||
|
"HAWAII" : ("Hawaii" , 0),
|
||||||
|
"ID" : ("Idaho" , 0),
|
||||||
|
"ID." : ("Idaho" , 0),
|
||||||
|
"IDAHO" : ("Idaho" , 0),
|
||||||
|
"IL" : ("Illinois" , 0),
|
||||||
|
"IL." : ("Illinois" , 0),
|
||||||
|
"ILLINOIS" : ("Illinois" , 0),
|
||||||
|
"ILL" : ("Illinois" , 0),
|
||||||
|
"ILL." : ("Illinois" , 0),
|
||||||
|
"ILLS" : ("Illinois" , 0),
|
||||||
|
"ILLS." : ("Illinois" , 0),
|
||||||
|
"IN" : ("Indiana" , 0),
|
||||||
|
"IN." : ("Indiana" , 0),
|
||||||
|
"INDIANA" : ("Indiana" , 0),
|
||||||
|
"IA" : ("Iowa" , 0),
|
||||||
|
"IA." : ("Iowa" , 0),
|
||||||
|
"IOWA" : ("Iowa" , 0),
|
||||||
|
"KS" : ("Kansas" , 0),
|
||||||
|
"KS." : ("Kansas" , 0),
|
||||||
|
"KANSAS" : ("Kansas" , 0),
|
||||||
|
"KY" : ("Kentucky" , 0),
|
||||||
|
"KY." : ("Kentucky" , 0),
|
||||||
|
"KENTUCKY" : ("Kentucky" , 0),
|
||||||
|
"LA" : ("Louisiana" , 0),
|
||||||
|
"LA." : ("Louisiana" , 0),
|
||||||
|
"LOUISIANA" : ("Louisiana" , 0),
|
||||||
|
"ME" : ("Maine" , 0),
|
||||||
|
"ME." : ("Maine" , 0),
|
||||||
|
"MAINE" : ("Maine" , 0),
|
||||||
|
"MD" : ("Maryland" , 0),
|
||||||
|
"MD." : ("Maryland" , 0),
|
||||||
|
"MARYLAND" : ("Maryland" , 0),
|
||||||
|
"MA" : ("Massachusetts" , 0),
|
||||||
|
"MA." : ("Massachusetts" , 0),
|
||||||
|
"MASSACHUSETTS" : ("Massachusetts" , 0),
|
||||||
|
"MI" : ("Michigan" , 0),
|
||||||
|
"MI." : ("Michigan" , 0),
|
||||||
|
"MICH." : ("Michigan" , 0),
|
||||||
|
"MICH" : ("Michigan" , 0),
|
||||||
|
"MN" : ("Minnesota" , 0),
|
||||||
|
"MN." : ("Minnesota" , 0),
|
||||||
|
"MINNESOTA" : ("Minnesota" , 0),
|
||||||
|
"MS" : ("Mississippi" , 0),
|
||||||
|
"MS." : ("Mississippi" , 0),
|
||||||
|
"MISSISSIPPI" : ("Mississippi" , 0),
|
||||||
|
"MO" : ("Missouri" , 0),
|
||||||
|
"MO." : ("Missouri" , 0),
|
||||||
|
"MISSOURI" : ("Missouri" , 0),
|
||||||
|
"MT" : ("Montana" , 0),
|
||||||
|
"MT." : ("Montana" , 0),
|
||||||
|
"MONTANA" : ("Montana" , 0),
|
||||||
|
"NE" : ("Nebraska" , 0),
|
||||||
|
"NE." : ("Nebraska" , 0),
|
||||||
|
"NEBRASKA" : ("Nebraska" , 0),
|
||||||
|
"NV" : ("Nevada" , 0),
|
||||||
|
"NV." : ("Nevada" , 0),
|
||||||
|
"NEVADA" : ("Nevada" , 0),
|
||||||
|
"NH" : ("New Hampshire" , 0),
|
||||||
|
"NH." : ("New Hampshire" , 0),
|
||||||
|
"N.H." : ("New Hampshire" , 0),
|
||||||
|
"NEW HAMPSHIRE" : ("New Hampshire" , 0),
|
||||||
|
"NJ" : ("New Jersey" , 0),
|
||||||
|
"NJ." : ("New Jersey" , 0),
|
||||||
|
"N.J." : ("New Jersey" , 0),
|
||||||
|
"NEW JERSEY" : ("New Jersey" , 0),
|
||||||
|
"NM" : ("New Mexico" , 0),
|
||||||
|
"NM." : ("New Mexico" , 0),
|
||||||
|
"NEW MEXICO" : ("New Mexico" , 0),
|
||||||
|
"NY" : ("New York" , 0),
|
||||||
|
"N.Y." : ("New York" , 0),
|
||||||
|
"NY." : ("New York" , 0),
|
||||||
|
"NEW YORK" : ("New York" , 0),
|
||||||
|
"NC" : ("North Carolina" , 0),
|
||||||
|
"NC." : ("North Carolina" , 0),
|
||||||
|
"N.C." : ("North Carolina" , 0),
|
||||||
|
"NORTH CAROLINA" : ("North Carolina" , 0),
|
||||||
|
"ND" : ("North Dakota" , 0),
|
||||||
|
"ND." : ("North Dakota" , 0),
|
||||||
|
"N.D." : ("North Dakota" , 0),
|
||||||
|
"NORTH DAKOTA" : ("North Dakota" , 0),
|
||||||
|
"OH" : ("Ohio" , 0),
|
||||||
|
"OH." : ("Ohio" , 0),
|
||||||
|
"OHIO" : ("Ohio" , 0),
|
||||||
|
"OK" : ("Oklahoma" , 0),
|
||||||
|
"OKLA" : ("Oklahoma" , 0),
|
||||||
|
"OKLA." : ("Oklahoma" , 0),
|
||||||
|
"OK." : ("Oklahoma" , 0),
|
||||||
|
"OKLAHOMA" : ("Oklahoma" , 0),
|
||||||
|
"OR" : ("Oregon" , 0),
|
||||||
|
"OR." : ("Oregon" , 0),
|
||||||
|
"OREGON" : ("Oregon" , 0),
|
||||||
|
"PA" : ("Pennsylvania" , 0),
|
||||||
|
"PA." : ("Pennsylvania" , 0),
|
||||||
|
"PENNSYLVANIA" : ("Pennsylvania" , 0),
|
||||||
|
"PR" : ("Puerto Rico" , 0),
|
||||||
|
"PUERTO RICO" : ("Puerto Rico" , 0),
|
||||||
|
"RI" : ("Rhode Island" , 0),
|
||||||
|
"RI." : ("Rhode Island" , 0),
|
||||||
|
"R.I." : ("Rhode Island" , 0),
|
||||||
|
"RHODE ISLAND" : ("Rhode Island" , 0),
|
||||||
|
"SC" : ("South Carolina" , 0),
|
||||||
|
"SC." : ("South Carolina" , 0),
|
||||||
|
"S.C." : ("South Carolina" , 0),
|
||||||
|
"SOUTH CAROLINA" : ("South Carolina" , 0),
|
||||||
|
"SD" : ("South Dakota" , 0),
|
||||||
|
"SD." : ("South Dakota" , 0),
|
||||||
|
"S.D." : ("South Dakota" , 0),
|
||||||
|
"SOUTH DAKOTA" : ("South Dakota" , 0),
|
||||||
|
"TN" : ("Tennessee" , 0),
|
||||||
|
"TN." : ("Tennessee" , 0),
|
||||||
|
"TENNESSEE" : ("Tennessee" , 0),
|
||||||
|
"TENN." : ("Tennessee" , 0),
|
||||||
|
"TENN" : ("Tennessee" , 0),
|
||||||
|
"TX" : ("Texas" , 0),
|
||||||
|
"TX." : ("Texas" , 0),
|
||||||
|
"TEXAS" : ("Texas" , 0),
|
||||||
|
"UT" : ("Utah" , 0),
|
||||||
|
"UT." : ("Utah" , 0),
|
||||||
|
"UTAH" : ("Utah" , 0),
|
||||||
|
"VT" : ("Vermont" , 0),
|
||||||
|
"VT." : ("Vermont" , 0),
|
||||||
|
"VERMONT" : ("Vermont" , 0),
|
||||||
|
"VI" : ("Virgin Islands" , 0),
|
||||||
|
"VIRGIN ISLANDS" : ("Virgin Islands" , 0),
|
||||||
|
"VA" : ("Virginia" , 0),
|
||||||
|
"VA." : ("Virginia" , 0),
|
||||||
|
"VIRGINIA" : ("Virginia" , 0),
|
||||||
|
"WA" : ("Washington" , 0),
|
||||||
|
"WA." : ("Washington" , 0),
|
||||||
|
"WASHINGTON" : ("Washington" , 0),
|
||||||
|
"WV" : ("West Virginia" , 0),
|
||||||
|
"WV." : ("West Virginia" , 0),
|
||||||
|
"W.V." : ("West Virginia" , 0),
|
||||||
|
"WEST VIRGINIA" : ("West Virginia" , 0),
|
||||||
|
"WI" : ("Wisconsin" , 0),
|
||||||
|
"WI." : ("Wisconsin" , 0),
|
||||||
|
"WISCONSIN" : ("Wisconsin" , 0),
|
||||||
|
"WY" : ("Wyoming" , 0),
|
||||||
|
"WY." : ("Wyoming" , 0),
|
||||||
|
"WYOMING" : ("Wyoming" , 0),
|
||||||
|
"AB" : ("Alberta", 1),
|
||||||
|
"AB." : ("Alberta", 1),
|
||||||
|
"ALBERTA" : ("Alberta", 1),
|
||||||
|
"BC" : ("British Columbia", 1),
|
||||||
|
"BC." : ("British Columbia", 1),
|
||||||
|
"B.C." : ("British Columbia", 1),
|
||||||
|
"MB" : ("Manitoba", 1),
|
||||||
|
"MB." : ("Manitoba", 1),
|
||||||
|
"MANITOBA" : ("Manitoba", 1),
|
||||||
|
"NB" : ("New Brunswick", 1),
|
||||||
|
"N.B." : ("New Brunswick", 1),
|
||||||
|
"NB." : ("New Brunswick", 1),
|
||||||
|
"NEW BRUNSWICK" : ("New Brunswick", 1),
|
||||||
|
"NL" : ("Newfoundland and Labrador", 1),
|
||||||
|
"NL." : ("Newfoundland and Labrador", 1),
|
||||||
|
"N.L." : ("Newfoundland and Labrador", 1),
|
||||||
|
"NEWFOUNDLAND" : ("Newfoundland and Labrador", 1),
|
||||||
|
"NEWFOUNDLAND AND LABRADOR" : ("Newfoundland and Labrador", 1),
|
||||||
|
"LABRADOR" : ("Newfoundland and Labrador", 1),
|
||||||
|
"NT" : ("Northwest Territories", 1),
|
||||||
|
"NT." : ("Northwest Territories", 1),
|
||||||
|
"N.T." : ("Northwest Territories", 1),
|
||||||
|
"NORTHWEST TERRITORIES" : ("Northwest Territories", 1),
|
||||||
|
"NS" : ("Nova Scotia", 1),
|
||||||
|
"NS." : ("Nova Scotia", 1),
|
||||||
|
"N.S." : ("Nova Scotia", 1),
|
||||||
|
"NOVA SCOTIA" : ("Nova Scotia", 1),
|
||||||
|
"NU" : ("Nunavut", 1),
|
||||||
|
"NU." : ("Nunavut", 1),
|
||||||
|
"NUNAVUT" : ("Nunavut", 1),
|
||||||
|
"ON" : ("Ontario", 1),
|
||||||
|
"ON." : ("Ontario", 1),
|
||||||
|
"ONTARIO" : ("Ontario", 1),
|
||||||
|
"PE" : ("Prince Edward Island", 1),
|
||||||
|
"PE." : ("Prince Edward Island", 1),
|
||||||
|
"PRINCE EDWARD ISLAND" : ("Prince Edward Island", 1),
|
||||||
|
"QC" : ("Quebec", 1),
|
||||||
|
"QC." : ("Quebec", 1),
|
||||||
|
"QUEBEC" : ("Quebec", 1),
|
||||||
|
"SK" : ("Saskatchewan", 1),
|
||||||
|
"SK." : ("Saskatchewan", 1),
|
||||||
|
"SASKATCHEWAN" : ("Saskatchewan", 1),
|
||||||
|
"YT" : ("Yukon", 1),
|
||||||
|
"YT." : ("Yukon", 1),
|
||||||
|
"YUKON" : ("Yukon", 1),
|
||||||
|
}
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
@ -68,43 +305,54 @@ class ExtractCity(Tool.BatchTool, ManagedWindow.ManagedWindow):
|
|||||||
def __init__(self, dbstate, uistate, options_class, name, callback=None):
|
def __init__(self, dbstate, uistate, options_class, name, callback=None):
|
||||||
self.label = _('Capitalization changes')
|
self.label = _('Capitalization changes')
|
||||||
|
|
||||||
ManagedWindow.ManagedWindow.__init__(self, uistate, [], self.__class__)
|
# ManagedWindow.ManagedWindow.__init__(self, uistate, [], self.__class__)
|
||||||
self.set_window(gtk.Window(), gtk.Label(), '')
|
# self.set_window(gtk.Window(), gtk.Label(), '')
|
||||||
|
|
||||||
Tool.BatchTool.__init__(self, dbstate, options_class, name)
|
Tool.BatchTool.__init__(self, dbstate, options_class, name)
|
||||||
if self.fail:
|
if not self.fail:
|
||||||
uistate.set_busy_cursor(True)
|
uistate.set_busy_cursor(True)
|
||||||
self.run()
|
self.run(dbstate.db)
|
||||||
uistate.set_busy_cursor(False)
|
uistate.set_busy_cursor(False)
|
||||||
|
|
||||||
def run(self):
|
def run(self, db):
|
||||||
"""
|
"""
|
||||||
Performs the actual extraction of information
|
Performs the actual extraction of information
|
||||||
"""
|
"""
|
||||||
trans = self.db.transaction_begin("", batch=True)
|
trans = db.transaction_begin("", batch=True)
|
||||||
self.db.disable_signals()
|
db.disable_signals()
|
||||||
|
|
||||||
for handle in self.db.get_place_handles():
|
for handle in db.get_place_handles():
|
||||||
place = self.db.get_place_from_handle(handle)
|
place = db.get_place_from_handle(handle)
|
||||||
descr = place.get_title()
|
descr = place.get_title()
|
||||||
loc = place.get_main_location()
|
loc = place.get_main_location()
|
||||||
|
|
||||||
if loc.get_street() == "" and loc.get_city() == "" \
|
if loc.get_street() == "" and loc.get_city() == "" \
|
||||||
and loc.get_state() == "" and \
|
and loc.get_state() == "" and \
|
||||||
loc.get_postal_code() == "":
|
loc.get_postal_code() == "":
|
||||||
match = CITY_STATE.match(descr)
|
match = CITY_STATE.match(descr.strip())
|
||||||
if match:
|
if match:
|
||||||
(city, state, postal) = match.groups()
|
(city, state, postal) = match.groups()
|
||||||
if city:
|
|
||||||
loc.set_city(city)
|
|
||||||
if state:
|
if state:
|
||||||
loc.set_state(state)
|
new_state = STATE_MAP.get(state.upper())
|
||||||
if postal:
|
if new_state:
|
||||||
loc.set_postal_code(postal)
|
loc.set_state(new_state[0])
|
||||||
self.db.commit_place(place, trans)
|
loc.set_country(COUNTRY[new_state[1]])
|
||||||
self.db.transaction_commit(trans, _("Place changes"))
|
if city:
|
||||||
self.db.enable_signals()
|
loc.set_city(" ".join(city.split()))
|
||||||
self.db.request_rebuild()
|
if postal:
|
||||||
|
loc.set_postal_code(postal)
|
||||||
|
db.commit_place(place, trans)
|
||||||
|
else:
|
||||||
|
val = " ".join(descr.strip().split()).upper()
|
||||||
|
new_state = STATE_MAP.get(val)
|
||||||
|
if new_state:
|
||||||
|
loc.set_state(new_state[0])
|
||||||
|
loc.set_country(COUNTRY[new_state[1]])
|
||||||
|
db.commit_place(place, trans)
|
||||||
|
|
||||||
|
db.transaction_commit(trans, _("Place changes"))
|
||||||
|
db.enable_signals()
|
||||||
|
db.request_rebuild()
|
||||||
|
|
||||||
#------------------------------------------------------------------------
|
#------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
@ -124,7 +372,7 @@ class ExtractCityOptions(Tool.ToolOptions):
|
|||||||
#
|
#
|
||||||
#------------------------------------------------------------------------
|
#------------------------------------------------------------------------
|
||||||
register_tool(
|
register_tool(
|
||||||
name = 'chname',
|
name = 'excity',
|
||||||
category = Tool.TOOL_DBPROC,
|
category = Tool.TOOL_DBPROC,
|
||||||
tool_class = ExtractCity,
|
tool_class = ExtractCity,
|
||||||
options_class = ExtractCityOptions,
|
options_class = ExtractCityOptions,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user