2007-02-13 Don Allingham <don@gramps-project.org>
* src/GrampsDb/_GrampsGEDDB.py: gedcom refactoring * src/GrampsDbUtils/_GedcomParse.py: gedcom refactoring * src/GrampsDbUtils/_ReadGedcom.py: gedcom refactoring * src/GrampsDbUtils/_GedcomLex.py: gedcom refactoring * src/GrampsDbUtils/_GrampsDbWRFactories.py: gedcom refactoring * src/GrampsDbUtils/_GedcomUtils.py: added * src/GrampsDbUtils/Makefile.am: added _GedcomUtils.py svn: r8110
This commit is contained in:
@@ -1,3 +1,12 @@
|
|||||||
|
2007-02-13 Don Allingham <don@gramps-project.org>
|
||||||
|
* src/GrampsDb/_GrampsGEDDB.py: gedcom refactoring
|
||||||
|
* src/GrampsDbUtils/_GedcomParse.py: gedcom refactoring
|
||||||
|
* src/GrampsDbUtils/_ReadGedcom.py: gedcom refactoring
|
||||||
|
* src/GrampsDbUtils/_GedcomLex.py: gedcom refactoring
|
||||||
|
* src/GrampsDbUtils/_GrampsDbWRFactories.py: gedcom refactoring
|
||||||
|
* src/GrampsDbUtils/_GedcomUtils.py: added
|
||||||
|
* src/GrampsDbUtils/Makefile.am: added _GedcomUtils.py
|
||||||
|
|
||||||
2007-02-13 Zsolt Foldvari <zfoldvar@users.sourceforge.net>
|
2007-02-13 Zsolt Foldvari <zfoldvar@users.sourceforge.net>
|
||||||
* src/GrampsWidgets.py: Merge trunk changes r7950:8105
|
* src/GrampsWidgets.py: Merge trunk changes r7950:8105
|
||||||
* src/MarkupText.py: cleanup
|
* src/MarkupText.py: cleanup
|
||||||
|
@@ -50,7 +50,7 @@ class GrampsGEDDB(GrampsInMemDB):
|
|||||||
GrampsInMemDB.load(self,name,callback,mode)
|
GrampsInMemDB.load(self,name,callback,mode)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from GrampsDbUtils._GedcomParse import importData
|
from GrampsDbUtils._ReadGedcom import importData
|
||||||
except:
|
except:
|
||||||
log.warning("Failed to load Gedcom reader", exc_info=True)
|
log.warning("Failed to load Gedcom reader", exc_info=True)
|
||||||
raise GrampsDbException("Failed to load Gedcom reader")
|
raise GrampsDbException("Failed to load Gedcom reader")
|
||||||
|
@@ -9,6 +9,7 @@ pkgdata_PYTHON = \
|
|||||||
_GedcomInfo.py\
|
_GedcomInfo.py\
|
||||||
_GedcomTokens.py\
|
_GedcomTokens.py\
|
||||||
_GedcomParser.py\
|
_GedcomParser.py\
|
||||||
|
_GedcomUtils.py\
|
||||||
_GedcomLexer.py\
|
_GedcomLexer.py\
|
||||||
__init__.py\
|
__init__.py\
|
||||||
_ReadGedcom.py\
|
_ReadGedcom.py\
|
||||||
|
@@ -49,11 +49,17 @@ from DateHandler._DateParser import DateParser
|
|||||||
#
|
#
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
|
|
||||||
def _empty_func(a,b):
|
def utf8_to_latin(msg):
|
||||||
return
|
"""
|
||||||
|
Converts a string from unicode to iso-8859-1. If any illegal characters
|
||||||
|
are found, they are converted to ?
|
||||||
|
|
||||||
def utf8_to_latin(s):
|
@param msg: unicode string to convert
|
||||||
return s.encode('iso-8859-1','replace')
|
@type level: unicode
|
||||||
|
@return: Returns the string, converted to a ISO-8859-1 object
|
||||||
|
@rtype: str
|
||||||
|
"""
|
||||||
|
return msg.encode('iso-8859-1', 'replace')
|
||||||
|
|
||||||
def latin_to_utf8(s):
|
def latin_to_utf8(s):
|
||||||
if type(s) == unicode:
|
if type(s) == unicode:
|
||||||
|
File diff suppressed because it is too large
Load Diff
95
src/GrampsDbUtils/_GedcomUtils.py
Normal file
95
src/GrampsDbUtils/_GedcomUtils.py
Normal file
@@ -0,0 +1,95 @@
|
|||||||
|
#
|
||||||
|
# Gramps - a GTK+/GNOME based genealogy program
|
||||||
|
#
|
||||||
|
# Copyright (C) 2000-2006 Donald N. Allingham
|
||||||
|
#
|
||||||
|
# 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
|
||||||
|
# the Free Software Foundation; either version 2 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program; if not, write to the Free Software
|
||||||
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
#
|
||||||
|
|
||||||
|
import RelLib
|
||||||
|
|
||||||
|
class PlaceParser:
|
||||||
|
|
||||||
|
field_map = {
|
||||||
|
'addr' : RelLib.Location.set_street,
|
||||||
|
'subdivision' : RelLib.Location.set_street,
|
||||||
|
'addr1' : RelLib.Location.set_street,
|
||||||
|
'adr1' : RelLib.Location.set_street,
|
||||||
|
'city' : RelLib.Location.set_city,
|
||||||
|
'town' : RelLib.Location.set_city,
|
||||||
|
'village' : RelLib.Location.set_city,
|
||||||
|
'county' : RelLib.Location.set_county,
|
||||||
|
'country' : RelLib.Location.set_country,
|
||||||
|
'state' : RelLib.Location.set_state,
|
||||||
|
'state/province': RelLib.Location.set_state,
|
||||||
|
'region' : RelLib.Location.set_state,
|
||||||
|
'province' : RelLib.Location.set_state,
|
||||||
|
'area code' : RelLib.Location.set_postal_code,
|
||||||
|
}
|
||||||
|
|
||||||
|
def __init__(self, line=None):
|
||||||
|
self.pf = []
|
||||||
|
|
||||||
|
if line:
|
||||||
|
self.parse_form(line)
|
||||||
|
|
||||||
|
def parse_form(self, line):
|
||||||
|
for item in line.data.split(','):
|
||||||
|
item = item.lower().strip()
|
||||||
|
fcn = self.field_map.get(item, lambda x, y: None)
|
||||||
|
self.pf.append(fcn)
|
||||||
|
|
||||||
|
def load_place(self, place, text):
|
||||||
|
items = [item.strip() for item in text.split(',')]
|
||||||
|
if len(items) != len(self.pf):
|
||||||
|
return
|
||||||
|
loc = place.get_main_location()
|
||||||
|
index = 0
|
||||||
|
for item in items:
|
||||||
|
self.pf[index](loc, item)
|
||||||
|
index += 1
|
||||||
|
|
||||||
|
|
||||||
|
class IdFinder:
|
||||||
|
"""
|
||||||
|
Provides method of finding the next available ID.
|
||||||
|
"""
|
||||||
|
def __init__(self, keys, prefix):
|
||||||
|
"""
|
||||||
|
Initializes the object.
|
||||||
|
"""
|
||||||
|
self.ids = set(keys)
|
||||||
|
self.index = 0
|
||||||
|
self.prefix = prefix
|
||||||
|
|
||||||
|
def find_next(self):
|
||||||
|
"""
|
||||||
|
Returns the next available GRAMPS' ID for a Event object based
|
||||||
|
off the person ID prefix.
|
||||||
|
|
||||||
|
@return: Returns the next available index
|
||||||
|
@rtype: str
|
||||||
|
"""
|
||||||
|
index = self.prefix % self.index
|
||||||
|
while str(index) in self.ids:
|
||||||
|
self.index += 1
|
||||||
|
index = self.prefix % self.index
|
||||||
|
self.ids.add(index)
|
||||||
|
self.index += 1
|
||||||
|
return index
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@@ -86,8 +86,8 @@ def gramps_db_reader_factory(db_type):
|
|||||||
import _ReadXML as ReadXML
|
import _ReadXML as ReadXML
|
||||||
md = ReadXML.importData
|
md = ReadXML.importData
|
||||||
elif db_type == const.app_gedcom:
|
elif db_type == const.app_gedcom:
|
||||||
import _GedcomParse as GedcomParse
|
import _ReadGedcom as ReadGedcom
|
||||||
md = GedcomParse.importData
|
md = ReadGedcom.importData
|
||||||
else:
|
else:
|
||||||
raise GrampsDbException("Attempt to create a database "
|
raise GrampsDbException("Attempt to create a database "
|
||||||
"reader for unknown format: "
|
"reader for unknown format: "
|
||||||
|
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user