* src/ReadGedcom.py: create GedcomDateParser class to handle
English requirements for GEDCOM svn: r3838
This commit is contained in:
parent
adf91f7efb
commit
0f7d28ddfc
@ -1,4 +1,7 @@
|
||||
2004-12-26 Don Allingham <dallingham@users.sourceforge.net>
|
||||
* src/Report.py: delay importing of GenericFilter
|
||||
* src/ReadGedcom.py: create GedcomDateParser class to handle
|
||||
English requirements for GEDCOM
|
||||
* src/DateHandler.py: provide date handler registration function
|
||||
* src/RelLib.py: more documentation
|
||||
* src/dates/Date_es.py: use new registration function
|
||||
|
@ -85,6 +85,8 @@ def create_parser():
|
||||
try:
|
||||
return _lang_to_parser[_lang]()
|
||||
except:
|
||||
import traceback
|
||||
traceback.print_stack()
|
||||
print "Date parser for",_lang,"not available"
|
||||
return DateParser.DateParser()
|
||||
|
||||
@ -145,6 +147,6 @@ def register_datehandler(locales,parse_class,display_class):
|
||||
#-------------------------------------------------------------------------
|
||||
from Plugins import load_plugins
|
||||
from const import datesDir
|
||||
print "loading",datesDir
|
||||
load_plugins(datesDir)
|
||||
|
||||
print _lang_to_display[_lang].formats
|
||||
|
@ -53,7 +53,6 @@ from TransTable import TransTable
|
||||
from gettext import gettext as _
|
||||
from Utils import for_each_ancestor
|
||||
|
||||
|
||||
_date_parser = DateHandler.create_parser()
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
|
@ -219,6 +219,14 @@ class DateStruct:
|
||||
self.date = ""
|
||||
self.time = ""
|
||||
|
||||
class GedcomDateParser(DateParser.DateParser):
|
||||
|
||||
month_to_int = {
|
||||
'jan' : 1, 'feb' : 2, 'mar' : 3, 'apr' : 4,
|
||||
'may' : 5, 'jun' : 6, 'jul' : 7, 'aug' : 8,
|
||||
'sep' : 9, 'oct' : 10, 'nov' : 11, 'dec' : 12,
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
#
|
||||
@ -230,7 +238,7 @@ class GedcomParser:
|
||||
BadFile = "Not a GEDCOM file"
|
||||
|
||||
def __init__(self, dbase, filename, window, codeset):
|
||||
self.dp = DateParser.DateParser()
|
||||
self.dp = GedcomDateParser()
|
||||
self.db = dbase
|
||||
self.person = None
|
||||
self.media_map = {}
|
||||
@ -1924,6 +1932,17 @@ class GedcomParser:
|
||||
|
||||
self.db.pmap_index = new_pmax
|
||||
|
||||
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.
|
||||
"""
|
||||
new_date = Date.Date()
|
||||
self.set_date(new_date,text)
|
||||
return new_date
|
||||
|
||||
def extract_temple(matches):
|
||||
try:
|
||||
if const.lds_temple_to_abrev.has_key(matches[2]):
|
||||
|
@ -51,7 +51,6 @@ import gnome.ui
|
||||
import const
|
||||
import Utils
|
||||
import Plugins
|
||||
import GenericFilter
|
||||
import BaseDoc
|
||||
import StyleEditor
|
||||
import GrampsGconfKeys
|
||||
@ -516,6 +515,8 @@ class BareReportDialog:
|
||||
generations fields and the filter combo box are used in most
|
||||
(but not all) dialog boxes."""
|
||||
|
||||
import GenericFilter
|
||||
|
||||
(em_label, extra_map, preset, em_tip) = self.get_report_extra_menu_info()
|
||||
(et_label, string, et_tip) = self.get_report_extra_textbox_info()
|
||||
|
||||
@ -1499,6 +1500,8 @@ class CommandLineReport:
|
||||
self.options_help[key] = self.option_class.options_help[key]
|
||||
|
||||
def parse_option_str(self):
|
||||
import GenericFilter
|
||||
|
||||
for opt in self.options_str_dict.keys():
|
||||
if opt in self.options_dict.keys():
|
||||
converter = Utils.get_type_converter(self.options_dict[opt])
|
||||
|
@ -151,6 +151,6 @@ class DateDisplayES(DateDisplay):
|
||||
# Register classes
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from DateHandler import add_format
|
||||
from DateHandler import register_datehandler
|
||||
register_datehandler(('es_ES','spanish'),DateParserES, DateDisplayES)
|
||||
|
||||
|
@ -145,5 +145,5 @@ class DateDisplayFR(DateDisplay):
|
||||
# Register classes
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from DateHandler import add_format
|
||||
from DateHandler import register_datehandler
|
||||
register_datehandler(('fr_FR','french'),DateParserFR, DateDisplayFR)
|
||||
|
@ -160,6 +160,6 @@ class DateDisplayRU(DateDisplay):
|
||||
# Register classes
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from DateHandler import add_format
|
||||
from DateHandler import register_datehandler
|
||||
register_datehandler(('ru_RU','russian'),DateParserRU, DateDisplayRU)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user