diff --git a/ChangeLog b/ChangeLog index 40016267b..c1b2f695c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2004-10-15 Don Allingham + * src/GrampsBSDDB.py: increase cachesize + * src/ReadGedcom.py: increment source count + * src/gedcomimport.glade: increment source count + * src/DateDisplay.py: handle BC + * src/DateParser.py: handle BC + * src/GrampsInMemDB.py: handle missing handles in find functions + * src/ReadGedcom.py: handle BC + * src/WriteGedcom.py: handle BC + * src/ReadXML.py: handle BC + 2004-10-13 Don Allingham * src/docgen/OpenOfficeDoc.py: incorporated Julio Sanchez's language patch diff --git a/example/gedcom/sample.ged b/example/gedcom/sample.ged index 22a9e27ff..62db2ae71 100755 --- a/example/gedcom/sample.ged +++ b/example/gedcom/sample.ged @@ -495,6 +495,12 @@ 2 DATE 10 JUL 1996 2 PLAC Community Presbyterian Church, Danville, CA 1 FAMC @F01@ +0 @I43@ INDI +1 NAME Really Old /Guy/ +1 SEX M +1 BIRT +2 DATE 26 JUN 34 B.C. +2 PLAC Hayward, Alameda Co., CA 0 @F01@ FAM 1 HUSB @I01@ 1 WIFE @I40@ diff --git a/src/DateDisplay.py b/src/DateDisplay.py index 885f9311b..e30762180 100644 --- a/src/DateDisplay.py +++ b/src/DateDisplay.py @@ -194,10 +194,15 @@ class DateDisplay: return "%s%s%s%s" % (qual_str,self._mod_str[mod],text,self.calendar[cal]) def _slash_year(self,val,slash): + bc = "" + if val < 0: + val = - val + bc = " B.C.E" + if slash: - return "%d/%d" % (val,(val%10)+1) + return "%d/%d%s" % (val,(val%10)+1,bc) else: - return str(val) + return "%d%s" % (val,bc) def _display_gregorian(self,date_val): year = self._slash_year(date_val[2],date_val[3]) diff --git a/src/DateParser.py b/src/DateParser.py index 2b0a057b7..106e20155 100644 --- a/src/DateParser.py +++ b/src/DateParser.py @@ -158,6 +158,7 @@ class DateParser: "Bahman" : 11, "Esfand" : 12, } + bce = ["BC", "B\.C", "B\.C\.", "BCE", "B\.C\.E", "B\.C\.E"] calendar_to_int = { 'gregorian' : Date.CAL_GREGORIAN, @@ -186,7 +187,9 @@ class DateParser: _rfc_mon_str = '(' + '|'.join(_rfc_mons_to_int.keys()) + ')' _rfc_day_str = '(' + '|'.join(_rfc_days) + ')' - + + _bce_str = '(' + '|'.join(bce) + ')' + _qual_str = '(' + '|'.join( [ key.replace('.','\.') for key in quality_to_int.keys() ] ) + ')' @@ -199,6 +202,8 @@ class DateParser: _pmon_str = '(' + '|'.join(persian_to_int.keys()) + ')' _cal_str = '(' + '|'.join(calendar_to_int.keys()) + ')' _imon_str = '(' + '|'.join(islamic_to_int.keys()) + ')' + + _bce_re = re.compile("(.+)\s+%s" % _bce_str) _cal = re.compile("(.+)\s\(%s\)" % _cal_str, re.IGNORECASE) @@ -428,12 +433,21 @@ class DateParser: (d0,m,y,s,d1,m,y,s)) return + match = self._bce_re.match(text) + bc = False + if match: + text = match.groups()[0] + bc = True + match = self._modifier.match(text) if match: grps = match.groups() start = self._parse_subdate(grps[1]) mod = self.modifier_to_int.get(grps[0].lower(),Date.MOD_NONE) - date.set(qual,mod,cal,start) + if bc: + date.set(qual,mod,cal,self.invert_year(start)) + else: + date.set(qual,mod,cal,start) return subdate = self._parse_subdate(text) @@ -456,9 +470,15 @@ class DateParser: cal = Date.CAL_PERSIAN else: cal = Date.CAL_HEBREW - - date.set(qual,Date.MOD_NONE,cal,subdate) + if bc: + date.set(qual,Date.MOD_NONE,cal,self.invert_year(subdate)) + else: + date.set(qual,Date.MOD_NONE,cal,subdate) + + def invert_year(self,subdate): + return (subdate[0],subdate[1],-subdate[2],subdate[3]) + def parse(self,text): """ Parses the text, returning a Date object. diff --git a/src/GrampsBSDDB.py b/src/GrampsBSDDB.py index d7d919c0b..0dd051707 100644 --- a/src/GrampsBSDDB.py +++ b/src/GrampsBSDDB.py @@ -58,20 +58,20 @@ class GrampsBSDDB(GrampsDbBase): self.close() self.env = db.DBEnv() - self.env.set_cachesize(0,4*1024*1024) # 2MB + self.env.set_cachesize(0,0x2000000) # 2MB flags = db.DB_CREATE|db.DB_INIT_MPOOL|db.DB_PRIVATE self.undolog = "%s.log" % name self.env.open(os.path.dirname(name), flags) name = os.path.basename(name) - self.person_map = dbshelve.open(name, dbname="person", dbenv=self.env) self.family_map = dbshelve.open(name, dbname="family", dbenv=self.env) self.place_map = dbshelve.open(name, dbname="places", dbenv=self.env) self.source_map = dbshelve.open(name, dbname="sources",dbenv=self.env) self.media_map = dbshelve.open(name, dbname="media", dbenv=self.env) self.event_map = dbshelve.open(name, dbname="events", dbenv=self.env) self.metadata = dbshelve.open(name, dbname="meta", dbenv=self.env) + self.person_map = dbshelve.open(name, dbname="person", dbenv=self.env) self.surnames = db.DB(self.env) self.surnames.set_flags(db.DB_DUP) diff --git a/src/GrampsInMemDB.py b/src/GrampsInMemDB.py index 0b0b8d5f9..b263b27dc 100644 --- a/src/GrampsInMemDB.py +++ b/src/GrampsInMemDB.py @@ -148,16 +148,28 @@ class GrampsInMemDB(GrampsDbBase): def get_family_from_gramps_id(self,val): handle = self.fid_trans.get(str(val)) - return self.family_map[handle] + if handle: + return self.family_map[handle] + else: + return None def get_place_from_gramps_id(self,val): handle = self.pid_trans.get(str(val)) - return self.place_map[handle] + if handle: + return self.place_map[handle] + else: + return None def get_source_from_gramps_id(self,val): handle = self.sid_trans.get(str(val)) - return self.source_map[handle] + if handle: + return self.source_map[handle] + else: + return None def get_object_from_gramps_id(self,val): handle = self.oid_trans.get(str(val)) - return self.media_map[handle] + if handle: + return self.media_map[handle] + else: + return None diff --git a/src/ReadGedcom.py b/src/ReadGedcom.py index 01b56cdd4..299f6b050 100644 --- a/src/ReadGedcom.py +++ b/src/ReadGedcom.py @@ -124,7 +124,7 @@ spanRegexp = re.compile(r"\s*FROM\s+@#D([^@]+)@\s*(.*)\s+TO\s+@#D([^@]+)@\s*(.*) def importData(database, filename, cb=None, use_trans=True): global callback - + f = open(filename,"r") ansel = False @@ -285,6 +285,7 @@ class GedcomParser: self.version_obj = window.get_widget("version") self.families_obj = window.get_widget("families") self.people_obj = window.get_widget("people") + self.source_obj = window.get_widget("sources") self.errors_obj = window.get_widget("errors") self.close_done = window.get_widget('close_done') self.error_text_obj = window.get_widget("error_text") @@ -434,6 +435,7 @@ class GedcomParser: self.index = 0 self.fam_count = 0 self.indi_count = 0 + self.source_count = 0 try: self.parse_header() self.parse_submitter() @@ -575,6 +577,8 @@ class GedcomParser: elif matches[1] in ["SUBM","SUBN","OBJE","_EVENT_DEFN"]: self.ignore_sub_junk(1) elif matches[2] == "SOUR": + if self.source_count % UPDATE == 0 and self.window: + self.update(self.source_obj,str(self.source_count)) self.parse_source(matches[1],1) elif matches[2][0:4] == "NOTE": if self.nmap.has_key(matches[1]): @@ -1811,7 +1815,8 @@ class GedcomParser: dateobj.set_calendar(Date.CAL_HEBREW) return dateobj else: - return self.dp.parse(text) + dval = self.dp.parse(text) + return dval except IOError: return self.dp.set_text(text) diff --git a/src/ReadXML.py b/src/ReadXML.py index a566822d6..7a8cf7b4e 100644 --- a/src/ReadXML.py +++ b/src/ReadXML.py @@ -776,7 +776,7 @@ class GrampsParser: self.family.set_gramps_id(handle) except KeyError: self.family = self.find_family_by_gramps_id(handle) - + if attrs.has_key("type"): self.family.set_relationship(_FAMILY_TRANS.get(attrs["type"], const.FAMILY_UNKNOWN)) @@ -1017,10 +1017,15 @@ class GrampsParser: else: dv = self.event.get_date_object() - start = attrs['val'].split('-') + bc = 1 + val = attrs['val'] + if val[0] == '-': + bc = -1 + val = val[1:] + start = val.split('-') try: - y = int(start[0]) + y = int(start[0])*bc except: y = 0 diff --git a/src/WriteGedcom.py b/src/WriteGedcom.py index 9983a72a8..f5622a43f 100644 --- a/src/WriteGedcom.py +++ b/src/WriteGedcom.py @@ -221,30 +221,36 @@ def make_date(subdate,calendar,mode): (day,mon,year,sl) = subdate (mmap,prefix) = _calmap.get(calendar,(_month,"")) + + if year < 0: + year = -year + bc = " B.C." + else: + bc = "" if day == 0: try: if mon == 0: - retval = '%d' % year + retval = '%d%s' % (year,bc) elif year == 0: retval = '(%s)' % mmap[mon] else: - retval = "%s %d" % (mmap[mon],year) + retval = "%s %d%s" % (mmap[mon],year,bc) except IndexError: print "Month index error - %d" % mon - retval = '%d' % year + retval = '%d%s' % (year,bc) elif mon == 0: - retval = '%d' % year + retval = '%d%s' % (year,bc) else: try: month = mmap[mon] if year == 0: retval = "(%d %s)" % (day,month) else: - retval = "%d %s %d" % (day,month,year) + retval = "%d %s %d%s" % (day,month,year,bc) except IndexError: print "Month index error - %d" % mon - retval = str(year) + retval = "%d%s" % (year,bc) if prefix: retval = "%s %s" % (prefix, retval) diff --git a/src/gedcomimport.glade b/src/gedcomimport.glade index 78f1d8756..7ee0af729 100644 --- a/src/gedcomimport.glade +++ b/src/gedcomimport.glade @@ -50,7 +50,7 @@ 12 True - 10 + 11 5 False 6 @@ -161,7 +161,7 @@ 0 True - * + * False @@ -204,8 +204,8 @@ 1 5 - 6 - 7 + 7 + 8 fill @@ -227,8 +227,8 @@ 0 5 - 5 - 6 + 6 + 7 fill @@ -251,8 +251,8 @@ 0 5 - 8 - 9 + 9 + 10 fill @@ -290,8 +290,8 @@ 1 5 - 9 - 10 + 10 + 11 fill @@ -305,7 +305,7 @@ 0 True - * + * False @@ -350,7 +350,7 @@ 10 True - * + * False @@ -371,7 +371,7 @@ 0 True - * + * False @@ -392,7 +392,7 @@ 10 True - * + * False @@ -437,7 +437,7 @@ 0 True - * + * False @@ -472,6 +472,51 @@ + + + + True + Sources: + False + False + GTK_JUSTIFY_CENTER + False + False + 0 + 0.5 + 0 + 0 + + + 1 + 2 + 4 + 5 + fill + + + + + + + True + True + False + True + 0 + + True + * + False + + + 2 + 3 + 4 + 5 + + + 0