Command-line import from gedcom: cleanup

svn: r1544
This commit is contained in:
Alex Roitman 2003-05-19 19:58:52 +00:00
parent 5c7c278e48
commit 01a1cd061f
2 changed files with 21 additions and 9 deletions

View File

@ -938,9 +938,13 @@ class Gramps:
import ReadGedcom import ReadGedcom
filename = os.path.normpath(os.path.abspath(filename)) filename = os.path.normpath(os.path.abspath(filename))
try: try:
ReadGedcom.importData(self.db,filename) g = ReadGedcom.GedcomParser(self.db,filename,None)
g.parse_gedcom_file()
g.resolve_refns()
del g
except: except:
print "Error importing %s" % filename print "Error importing %s" % filename
os._exit(1)
elif format == 'gramps': elif format == 'gramps':
try: try:
dbname = os.path.join(filename,const.xmlFile) dbname = os.path.join(filename,const.xmlFile)

View File

@ -284,16 +284,22 @@ class GedcomParser:
pass pass
def errmsg(self,msg): def errmsg(self,msg):
if self.window:
try: try:
self.error_text_obj.get_buffer().insert_at_cursor(msg) self.error_text_obj.get_buffer().insert_at_cursor(msg)
except TypeError: except TypeError:
self.error_text_obj.get_buffer().insert_at_cursor(msg,len(msg)) self.error_text_obj.get_buffer().insert_at_cursor(msg,len(msg))
else:
print msg
def infomsg(self,msg): def infomsg(self,msg):
if self.window:
try: try:
self.info_text_obj.get_buffer().insert_at_cursor(msg) self.info_text_obj.get_buffer().insert_at_cursor(msg)
except TypeError: except TypeError:
self.info_text_obj.get_buffer().insert_at_cursor(msg,len(msg)) self.info_text_obj.get_buffer().insert_at_cursor(msg,len(msg))
else:
print msg
def find_file(self,fullname,altpath): def find_file(self,fullname,altpath):
tries = [] tries = []
@ -402,6 +408,8 @@ class GedcomParser:
self.infomsg("\n%s" % msg) self.infomsg("\n%s" % msg)
else: else:
print msg print msg
print "Families: %d" % self.fam_count
print "Individuals: %d" % self.indi_count
return None return None
def break_note_links(self): def break_note_links(self):