2008-01-15 Raphael Ackermann <raphael.ackermann@gmail.com>

* src/GrampsDbUtils/_GrampsDbWriteXML.py
    * src/GrampsDbUtils/_WriteGedcom.py
    * src/plugins/ExportCSV.py
    * src/plugins/ExportVCalendar.py
    * src/plugins/ExportVCard.py
    * src/plugins/WriteCD.py
    * src/plugins/WriteFtree.py
    * src/plugins/WriteGeneWeb.py
    * src/plugins/WritePkg.py
    * src/PluginUtils/_PluginMgr.py: pylint fixes
    pylint fixes and work on 0001597 

svn: r9812
This commit is contained in:
Raphael Ackermann
2008-01-15 09:16:45 +00:00
parent ae138d2d01
commit 2225ac3d78
11 changed files with 189 additions and 179 deletions

View File

@@ -1,3 +1,16 @@
2008-01-15 Raphael Ackermann <raphael.ackermann@gmail.com>
* src/GrampsDbUtils/_GrampsDbWriteXML.py
* src/GrampsDbUtils/_WriteGedcom.py
* src/plugins/ExportCSV.py
* src/plugins/ExportVCalendar.py
* src/plugins/ExportVCard.py
* src/plugins/WriteCD.py
* src/plugins/WriteFtree.py
* src/plugins/WriteGeneWeb.py
* src/plugins/WritePkg.py
* src/PluginUtils/_PluginMgr.py: pylint fixes
pylint fixes and work on 0001597
2008-01-14 Raphael Ackermann <raphael.ackermann@gmail.com> 2008-01-14 Raphael Ackermann <raphael.ackermann@gmail.com>
* src/DbLoader.py: typo * src/DbLoader.py: typo
* src/plugins/ImportCSV.py: register text/csv as another mime type for csv * src/plugins/ImportCSV.py: register text/csv as another mime type for csv

View File

@@ -54,12 +54,12 @@ log = logging.getLogger(".WriteXML")
import gen.lib import gen.lib
from BasicUtils import UpdateCallback from BasicUtils import UpdateCallback
from gen.db.dbconst import \ #from gen.db.dbconst import \
PERSON_KEY,FAMILY_KEY,SOURCE_KEY,EVENT_KEY,\ # PERSON_KEY,FAMILY_KEY,SOURCE_KEY,EVENT_KEY,\
MEDIA_KEY,PLACE_KEY,REPOSITORY_KEY,NOTE_KEY # MEDIA_KEY,PLACE_KEY,REPOSITORY_KEY,NOTE_KEY
#
from gen.db.exceptions import * from gen.db.exceptions import GrampsDbWriteFailure
from gen.utils.longop import LongOpStatus #from gen.utils.longop import LongOpStatus
import gen.proxy import gen.proxy
@@ -91,7 +91,6 @@ def escxml(d):
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
def exportData(database, filename, person, option_box, callback, version="unknown"): def exportData(database, filename, person, option_box, callback, version="unknown"):
ret = 0
if os.path.isfile(filename): if os.path.isfile(filename):
try: try:
shutil.copyfile(filename, filename + ".bak") shutil.copyfile(filename, filename + ".bak")
@@ -117,8 +116,7 @@ def exportData(database, filename, person, option_box, callback, version="unknow
database = gen.proxy.FilterProxyDb(database, option_box.cfilter) database = gen.proxy.FilterProxyDb(database, option_box.cfilter)
g = GrampsDbXmlWriter(database, 0, compress, version, callback) g = GrampsDbXmlWriter(database, 0, compress, version, callback)
ret = g.write(filename) return g.write(filename)
return ret
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
@@ -1001,8 +999,8 @@ class GrampsDbXmlWriter(UpdateCallback):
(sp,corner1_x,corner1_y,corner2_x,corner2_y)) (sp,corner1_x,corner1_y,corner2_x,corner2_y))
self.write_attribute_list(proplist,indent+1) self.write_attribute_list(proplist,indent+1)
for ref in refslist: for ref in refslist:
self.dump_source_ref(ref,indent+1) self.dump_source_ref(ref, indent+1)
self.write_note_list(nreflist,indent+1) self.write_note_list(nreflist, indent+1)
self.g.write('%s</objref>\n' % sp) self.g.write('%s</objref>\n' % sp)
def write_data_map(self,datamap,indent=3): def write_data_map(self,datamap,indent=3):
@@ -1012,9 +1010,9 @@ class GrampsDbXmlWriter(UpdateCallback):
sp = ' '*indent sp = ' '*indent
for key in datamap.keys(): for key in datamap.keys():
self.g.write('%s<data_item key="%s" value="%s"/>\n' % self.g.write('%s<data_item key="%s" value="%s"/>\n' %
(sp,self.fix(key),self.fix(datamap[key]))) (sp,self.fix(key), self.fix(datamap[key])))
def write_reporef_list(self,rrlist,index=1): def write_reporef_list(self, rrlist, index=1):
for reporef in rrlist: for reporef in rrlist:
if not reporef or not reporef.ref: if not reporef or not reporef.ref:
continue continue
@@ -1037,16 +1035,16 @@ class GrampsDbXmlWriter(UpdateCallback):
note_list = reporef.get_note_list() note_list = reporef.get_note_list()
if len(note_list) == 0: if len(note_list) == 0:
self.write_ref('reporef',reporef.ref,index,close=True, self.write_ref('reporef', reporef.ref, index, close=True,
extra_text=priv_text+callno_text+type_text) extra_text=priv_text+callno_text+type_text)
else: else:
self.write_ref('reporef',reporef.ref,index,close=False, self.write_ref('reporef', reporef.ref, index, close=False,
extra_text=priv_text+callno_text+type_text) extra_text=priv_text+callno_text+type_text)
self.write_note_list(note_list,index+1) self.write_note_list(note_list, index+1)
sp = " "*index sp = " "*index
self.g.write('%s</reporef>\n' % sp) self.g.write('%s</reporef>\n' % sp)
def write_url_list(self,list,index=1): def write_url_list(self, list, index=1):
sp = " "*index sp = " "*index
for url in list: for url in list:
url_type = url.get_type().xml_str() url_type = url.get_type().xml_str()
@@ -1062,10 +1060,10 @@ class GrampsDbXmlWriter(UpdateCallback):
desc_text = '' desc_text = ''
path_text = ' href="%s"' % self.fix(url.get_path()) path_text = ' href="%s"' % self.fix(url.get_path())
self.g.write('%s<url%s%s%s%s/>\n' % \ self.g.write('%s<url%s%s%s%s/>\n' % \
(sp,priv_text,path_text,type_text,desc_text)) (sp, priv_text, path_text, type_text, desc_text))
def write_place_obj(self,place,index=1): def write_place_obj(self, place, index=1):
self.write_primary_tag("placeobj",place,index) self.write_primary_tag("placeobj", place, index)
title = self.fix(place.get_title()) title = self.fix(place.get_title())
longitude = self.fix(place.get_longitude()) longitude = self.fix(place.get_longitude())
@@ -1081,23 +1079,23 @@ class GrampsDbXmlWriter(UpdateCallback):
if title == "": if title == "":
title = self.build_place_title(place.get_main_location()) title = self.build_place_title(place.get_main_location())
self.write_line_nofix("ptitle",title,index+1) self.write_line_nofix("ptitle", title, index+1)
if longitude or lat: if longitude or lat:
self.g.write('%s<coord long="%s" lat="%s"/>\n' self.g.write('%s<coord long="%s" lat="%s"/>\n'
% (" "*(index+1),longitude,lat)) % (" "*(index+1), longitude, lat))
self.dump_location(main_loc) self.dump_location(main_loc)
for loc in place.get_alternate_locations(): for loc in place.get_alternate_locations():
self.dump_location(loc) self.dump_location(loc)
self.write_media_list(place.get_media_list(),index+1) self.write_media_list(place.get_media_list(), index+1)
self.write_url_list(place.get_url_list()) self.write_url_list(place.get_url_list())
self.write_note_list(place.get_note_list(),index+1) self.write_note_list(place.get_note_list(), index+1)
for s in place.get_source_references(): for s in place.get_source_references():
self.dump_source_ref(s,index+1) self.dump_source_ref(s, index+1)
self.g.write("%s</placeobj>\n" % (" "*index)) self.g.write("%s</placeobj>\n" % (" "*index))
def write_object(self,obj,index=1): def write_object(self, obj, index=1):
self.write_primary_tag("object",obj,index) self.write_primary_tag("object", obj, index)
handle = obj.get_gramps_id() handle = obj.get_gramps_id()
mime_type = obj.get_mime_type() mime_type = obj.get_mime_type()
path = obj.get_path() path = obj.get_path()
@@ -1109,18 +1107,18 @@ class GrampsDbXmlWriter(UpdateCallback):
if self.strip_photos == 1: if self.strip_photos == 1:
path = os.path.basename(path) path = os.path.basename(path)
elif self.strip_photos == 2 and (len(path)>0 and os.path.isabs(path)): elif self.strip_photos == 2 and (len(path)>0 and os.path.isabs(path)):
drive,path = os.path.splitdrive(path) drive, path = os.path.splitdrive(path)
path = path[1:] path = path[1:]
self.g.write('%s<file src="%s" mime="%s"%s/>\n' self.g.write('%s<file src="%s" mime="%s"%s/>\n'
% (" "*(index+1),self.fix(path),mime_type,desc_text)) % (" "*(index+1), self.fix(path), mime_type, desc_text))
self.write_attribute_list(obj.get_attribute_list()) self.write_attribute_list(obj.get_attribute_list())
self.write_note_list(obj.get_note_list(),index+1) self.write_note_list(obj.get_note_list(), index+1)
dval = obj.get_date_object() dval = obj.get_date_object()
if not dval.is_empty(): if not dval.is_empty():
self.write_date(dval,index+1) self.write_date(dval, index+1)
for s in obj.get_source_references(): for s in obj.get_source_references():
self.dump_source_ref(s,index+1) self.dump_source_ref(s, index+1)
self.g.write("%s</object>\n" % (" "*index)) self.g.write("%s</object>\n" % (" "*index))
#------------------------------------------------------------------------- #-------------------------------------------------------------------------

View File

@@ -322,7 +322,7 @@ class GedcomWriter(BasicUtils.UpdateCallback):
self.__writeln(0, "TRLR") self.__writeln(0, "TRLR")
self.gedcom_file.close() self.gedcom_file.close()
return 1 return True
def __writeln(self, level, token, textlines="", limit=72): def __writeln(self, level, token, textlines="", limit=72):
""" """
@@ -1378,7 +1378,7 @@ def export_data(database, filename, person, option_box, callback=None):
""" """
External interface used to register with the plugin system. External interface used to register with the plugin system.
""" """
ret = 0 ret = False
try: try:
ged_write = GedcomWriter(database, person, 0, ged_write = GedcomWriter(database, person, 0,
option_box, callback) option_box, callback)

View File

@@ -137,27 +137,27 @@ def load_plugins(direct):
# Plugin registering # Plugin registering
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
def register_export(exportData,title,description='',config=None,filename=''): def register_export(exportData, title, description='', config=None, filename=''):
""" """
Register an export filter, taking the task, file filter, Register an export filter, taking the task, file filter,
and the list of patterns for the filename matching. and the list of patterns for the filename matching.
""" """
if description and filename: if description and filename:
del_index = -1 del_index = -1
for i in range(0,len(export_list)): for i in range(0, len(export_list)):
if export_list[i][1] == title: if export_list[i][1] == title:
del_index = i del_index = i
if del_index != -1: if del_index != -1:
del export_list[del_index] del export_list[del_index]
export_list.append((exportData,title,description,config,filename)) export_list.append((exportData, title, description, config, filename))
mod2text[exportData.__module__] = description mod2text[exportData.__module__] = description
def register_import(task, ffilter, mime=None, native_format=0, format_name=""): def register_import(task, ffilter, mime=None, native_format=0, format_name=""):
"""Register an import filter, taking the task and file filter""" """Register an import filter, taking the task and file filter"""
if mime: if mime:
del_index = -1 del_index = -1
for i in range(0,len(import_list)): for i in range(0, len(import_list)):
if import_list[i][2] == mime: if import_list[i][2] == mime:
del_index = i del_index = i
if del_index != -1: if del_index != -1:

View File

@@ -69,10 +69,8 @@ import DateHandler
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
def exportData(database,filename,person,option_box,callback=None): def exportData(database,filename,person,option_box,callback=None):
ret = 0
gw = CSVWriter(database,person,0,filename,option_box,callback) gw = CSVWriter(database,person,0,filename,option_box,callback)
ret = gw.export_data() return gw.export_data()
return ret
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
@@ -333,10 +331,10 @@ class CSVWriter:
except IOError,msg: except IOError,msg:
msg2 = _("Could not create %s") % self.filename msg2 = _("Could not create %s") % self.filename
ErrorDialog(msg2,str(msg)) ErrorDialog(msg2,str(msg))
return 0 return False
except: except:
ErrorDialog(_("Could not create %s") % self.filename) ErrorDialog(_("Could not create %s") % self.filename)
return 0 return False
######################### initialize progress bar ######################### initialize progress bar
self.count = 0 self.count = 0
self.total = 0 self.total = 0
@@ -490,7 +488,7 @@ class CSVWriter:
self.update() self.update()
self.writeln() self.writeln()
self.g.close() self.g.close()
return 1 return True
def format_date(self, date): def format_date(self, date):
return DateHandler.get_date(date) return DateHandler.get_date(date)

View File

@@ -2,7 +2,7 @@
# Gramps - a GTK+/GNOME based genealogy program # Gramps - a GTK+/GNOME based genealogy program
# #
# Copyright (C) 2004 Martin Hawlisch # Copyright (C) 2004 Martin Hawlisch
# Copyright (C) 2005-2006 Donald N. Allingham # Copyright (C) 2005-2006, 2008 Donald N. Allingham
# #
# This program is free software; you can redistribute it and/or modify # 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 # it under the terms of the GNU General Public License as published by
@@ -53,7 +53,7 @@ log = logging.getLogger(".ExportVCal")
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
from Filters import GenericFilter, Rules, build_filter_menu from Filters import GenericFilter, Rules, build_filter_menu
import const #import const
import Utils import Utils
from gen.lib import Date, EventType from gen.lib import Date, EventType
import Errors import Errors
@@ -70,7 +70,7 @@ class CalendarWriterOptionBox:
Create a VBox with the option widgets and define methods to retrieve Create a VBox with the option widgets and define methods to retrieve
the options. the options.
""" """
def __init__(self,person): def __init__(self, person):
self.person = person self.person = person
def get_option_box(self): def get_option_box(self):
@@ -79,7 +79,7 @@ class CalendarWriterOptionBox:
if not os.path.isfile(glade_file): if not os.path.isfile(glade_file):
glade_file = "plugins/vcalendarexport.glade" glade_file = "plugins/vcalendarexport.glade"
self.topDialog = gtk.glade.XML(glade_file,"calendarExport","gramps") self.topDialog = gtk.glade.XML(glade_file, "calendarExport", "gramps")
filter_obj = self.topDialog.get_widget("filter") filter_obj = self.topDialog.get_widget("filter")
self.copy = 0 self.copy = 0
@@ -109,7 +109,7 @@ class CalendarWriterOptionBox:
com.add_rule(Rules.Person.HasCommonAncestorWith( com.add_rule(Rules.Person.HasCommonAncestorWith(
[self.person.get_gramps_id()])) [self.person.get_gramps_id()]))
the_filters += [all,des,ans,com] the_filters += [all, des, ans, com]
from Filters import CustomFilters from Filters import CustomFilters
the_filters.extend(CustomFilters.get_filters('Person')) the_filters.extend(CustomFilters.get_filters('Person'))
@@ -127,8 +127,8 @@ class CalendarWriterOptionBox:
class CalendarWriter: class CalendarWriter:
def __init__(self,database,person,cl=0,filename="", def __init__(self, database, person, cl=0, filename="", option_box=None,
option_box=None,callback=None): callback=None):
self.db = database self.db = database
self.person = person self.person = person
self.option_box = option_box self.option_box = option_box
@@ -160,8 +160,8 @@ class CalendarWriter:
for p in self.option_box.cfilter.apply(self.db, self.db.get_person_handles(sort_handles=False)): for p in self.option_box.cfilter.apply(self.db, self.db.get_person_handles(sort_handles=False)):
self.plist[p] = 1 self.plist[p] = 1
except Errors.FilterError, msg: except Errors.FilterError, msg:
(m1,m2) = msg.messages() (m1, m2) = msg.messages()
ErrorDialog(m1,m2) ErrorDialog(m1, m2)
return return
self.flist = {} self.flist = {}
@@ -191,21 +191,21 @@ class CalendarWriter:
for family_handle in p.get_family_handle_list(): for family_handle in p.get_family_handle_list():
self.flist[family_handle] = 1 self.flist[family_handle] = 1
def writeln(self,text): def writeln(self, text):
self.g.write('%s\n' % (text.encode('iso-8859-1'))) self.g.write('%s\n' % (text.encode('iso-8859-1')))
def export_data(self,filename): def export_data(self, filename):
self.dirname = os.path.dirname (filename) self.dirname = os.path.dirname (filename)
try: try:
self.g = open(filename,"w") self.g = open(filename,"w")
except IOError,msg: except IOError,msg:
msg2 = _("Could not create %s") % filename msg2 = _("Could not create %s") % filename
ErrorDialog(msg2,str(msg)) ErrorDialog(msg2, str(msg))
return 0 return False
except: except:
ErrorDialog(_("Could not create %s") % filename) ErrorDialog(_("Could not create %s") % filename)
return 0 return False
self.writeln("BEGIN:VCALENDAR"); self.writeln("BEGIN:VCALENDAR");
self.writeln("PRODID:-//GNU//Gramps//EN"); self.writeln("PRODID:-//GNU//Gramps//EN");
@@ -226,9 +226,9 @@ class CalendarWriter:
self.writeln("END:VCALENDAR"); self.writeln("END:VCALENDAR");
self.g.close() self.g.close()
return 1 return True
def write_family(self,family_handle): def write_family(self, family_handle):
family = self.db.get_family_from_handle(family_handle) family = self.db.get_family_from_handle(family_handle)
if family: if family:
for event_ref in family.get_event_ref_list(): for event_ref in family.get_event_ref_list():
@@ -236,7 +236,8 @@ class CalendarWriter:
if event.get_type() == EventType.MARRIAGE: if event.get_type() == EventType.MARRIAGE:
m_date = event.get_date_object() m_date = event.get_date_object()
place_handle = event.get_place_handle() place_handle = event.get_place_handle()
text = _("Marriage of %s") % Utils.family_name(family,self.db) text = _("Marriage of %s") % Utils.family_name(family,
self.db)
if place_handle: if place_handle:
place = self.db.get_place_from_handle(place_handle) place = self.db.get_place_from_handle(place_handle)
self.write_vevent( text, m_date, place.get_title()) self.write_vevent( text, m_date, place.get_title())
@@ -271,9 +272,9 @@ class CalendarWriter:
self.write_vevent(_("Death of %s") % person.get_primary_name().get_name(), d_date) self.write_vevent(_("Death of %s") % person.get_primary_name().get_name(), d_date)
def format_single_date(self,subdate,thisyear,cal): def format_single_date(self, subdate, thisyear, cal):
retval = "" retval = ""
(day,month,year,sl) = subdate (day, month, year, sl) = subdate
if thisyear: if thisyear:
year = localtime().tm_year year = localtime().tm_year
@@ -288,7 +289,7 @@ class CalendarWriter:
return retval return retval
def format_date(self,date,thisyear=0): def format_date(self, date, thisyear=0):
retval = "" retval = ""
if date.get_modifier() == Date.MOD_TEXTONLY: if date.get_modifier() == Date.MOD_TEXTONLY:
return "" return ""
@@ -296,14 +297,19 @@ class CalendarWriter:
mod = date.get_modifier() mod = date.get_modifier()
cal = cal = date.get_calendar() cal = cal = date.get_calendar()
if mod == Date.MOD_SPAN or mod == Date.MOD_RANGE: if mod == Date.MOD_SPAN or mod == Date.MOD_RANGE:
start = self.format_single_date(date.get_start_date(),thisyear,cal) start = self.format_single_date(date.get_start_date(),
end = self.format_single_date(date.get_stop_date(),thisyear,cal) thisyear, cal)
end = self.format_single_date(date.get_stop_date(),
thisyear, cal)
if start and end: if start and end:
retval = "DTSTART:%sT000001\nDTEND:%sT235959" % (start,end) retval = "DTSTART:%sT000001\nDTEND:%sT235959" % (start,
end)
elif mod == Date.MOD_NONE: elif mod == Date.MOD_NONE:
start = self.format_single_date(date.get_start_date(),thisyear,cal) start = self.format_single_date(date.get_start_date(),
thisyear, cal)
if start: if start:
retval = "DTSTART:%sT000001\nDTEND:%sT235959" % (start,start) retval = "DTSTART:%sT000001\nDTEND:%sT235959" % (start,
start)
return retval return retval
def write_vevent(self, event_text, date, location=""): def write_vevent(self, event_text, date, location=""):
@@ -317,7 +323,7 @@ class CalendarWriter:
self.writeln(date_string) self.writeln(date_string)
self.writeln("END:VEVENT"); self.writeln("END:VEVENT");
date_string = self.format_date(date,1) date_string = self.format_date(date, 1)
self.writeln(""); self.writeln("");
self.writeln("BEGIN:VEVENT"); self.writeln("BEGIN:VEVENT");
self.writeln("SUMMARY:"+_("Anniversary: %s") % event_text); self.writeln("SUMMARY:"+_("Anniversary: %s") % event_text);
@@ -332,11 +338,9 @@ class CalendarWriter:
# #
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
def exportData(database,filename,person,option_box,callback=None): def exportData(database, filename, person, option_box, callback=None):
ret = 0 cw = CalendarWriter(database, person, 0, filename, option_box, callback)
cw = CalendarWriter(database,person,0,filename,option_box,callback) return cw.export_data(filename)
ret = cw.export_data(filename)
return ret
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
@@ -345,7 +349,7 @@ def exportData(database,filename,person,option_box,callback=None):
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
_title = _('vCalendar') _title = _('vCalendar')
_description = _('vCalendar is used in many calendaring and pim applications.') _description = _('vCalendar is used in many calendaring and pim applications.')
_config = (_('vCalendar export options'),CalendarWriterOptionBox) _config = (_('vCalendar export options'), CalendarWriterOptionBox)
_filename = 'vcs' _filename = 'vcs'
register_export(exportData,_title,_description,_config,_filename) register_export(exportData, _title, _description, _config, _filename)

View File

@@ -2,7 +2,7 @@
# Gramps - a GTK+/GNOME based genealogy program # Gramps - a GTK+/GNOME based genealogy program
# #
# Copyright (C) 2004 Martin Hawlisch # Copyright (C) 2004 Martin Hawlisch
# Copyright (C) 2005-2006 Donald N. Allingham # Copyright (C) 2005-2008 Donald N. Allingham
# #
# This program is free software; you can redistribute it and/or modify # 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 # it under the terms of the GNU General Public License as published by
@@ -66,7 +66,7 @@ class CardWriterOptionBox:
Create a VBox with the option widgets and define methods to retrieve Create a VBox with the option widgets and define methods to retrieve
the options. the options.
""" """
def __init__(self,person): def __init__(self, person):
self.person = person self.person = person
def get_option_box(self): def get_option_box(self):
@@ -105,7 +105,7 @@ class CardWriterOptionBox:
com.add_rule(Rules.Person.HasCommonAncestorWith( com.add_rule(Rules.Person.HasCommonAncestorWith(
[self.person.get_gramps_id()])) [self.person.get_gramps_id()]))
the_filters += [all,des,ans,com] the_filters += [all, des, ans, com]
from Filters import CustomFilters from Filters import CustomFilters
the_filters.extend(CustomFilters.get_filters('Person')) the_filters.extend(CustomFilters.get_filters('Person'))
@@ -122,8 +122,8 @@ class CardWriterOptionBox:
self.cfilter = self.filter_menu.get_active().get_data("filter") self.cfilter = self.filter_menu.get_active().get_data("filter")
class CardWriter: class CardWriter:
def __init__(self,database,person,cl=0,filename="", def __init__(self, database, person, cl=0, filename="", option_box=None,
option_box=None,callback=None): callback=None):
self.db = database self.db = database
self.person = person self.person = person
self.option_box = option_box self.option_box = option_box
@@ -147,11 +147,12 @@ class CardWriter:
self.plist[p] = 1 self.plist[p] = 1
else: else:
try: try:
for p in self.option_box.cfilter.apply(self.db, self.db.get_person_handles(sort_handles=False)): for p in self.option_box.cfilter.apply(self.db,
self.db.get_person_handles(sort_handles=False)):
self.plist[p] = 1 self.plist[p] = 1
except Errors.FilterError, msg: except Errors.FilterError, msg:
(m1,m2) = msg.messages() (m1, m2) = msg.messages()
ErrorDialog(m1,m2) ErrorDialog(m1, m2)
return return
def update_empty(self): def update_empty(self):
@@ -168,21 +169,21 @@ class CardWriter:
for p in self.db.get_person_handles(sort_handles=False): for p in self.db.get_person_handles(sort_handles=False):
self.plist[p] = 1 self.plist[p] = 1
def writeln(self,text): def writeln(self, text):
self.g.write('%s\n' % (text.encode('iso-8859-1'))) self.g.write('%s\n' % (text.encode('iso-8859-1')))
def export_data(self,filename): def export_data(self, filename):
self.dirname = os.path.dirname (filename) self.dirname = os.path.dirname (filename)
try: try:
self.g = open(filename,"w") self.g = open(filename,"w")
except IOError,msg: except IOError,msg:
msg2 = _("Could not create %s") % filename msg2 = _("Could not create %s") % filename
ErrorDialog(msg2,str(msg)) ErrorDialog(msg2, str(msg))
return 0 return False
except: except:
ErrorDialog(_("Could not create %s") % filename) ErrorDialog(_("Could not create %s") % filename)
return 0 return False
self.count = 0 self.count = 0
self.oldval = 0 self.oldval = 0
@@ -192,7 +193,7 @@ class CardWriter:
self.update() self.update()
self.g.close() self.g.close()
return 1 return True
def write_person(self, person_handle): def write_person(self, person_handle):
person = self.db.get_person_from_handle(person_handle) person = self.db.get_person_from_handle(person_handle)
@@ -215,9 +216,10 @@ class CardWriter:
not b_date.is_empty() and not b_date.is_empty() and
not mod == Date.MOD_SPAN and not mod == Date.MOD_SPAN and
not mod == Date.MOD_RANGE): not mod == Date.MOD_RANGE):
(day,month,year,sl) = b_date.get_start_date() (day, month, year, sl) = b_date.get_start_date()
if day > 0 and month > 0 and year > 0: if day > 0 and month > 0 and year > 0:
self.writeln("BDAY:%s-%02d-%02d" % (year,month,day)) self.writeln("BDAY:%s-%02d-%02d" % (year, month,
day))
address_list = person.get_address_list() address_list = person.get_address_list()
for address in address_list: for address in address_list:
@@ -229,7 +231,10 @@ class CardWriter:
zip = address.get_postal_code() zip = address.get_postal_code()
country = address.get_country() country = address.get_country()
if street or city or state or zip or country: if street or city or state or zip or country:
self.writeln("ADR:%s;%s;%s;%s;%s;%s;%s" % (postbox,ext,street,city,state,zip,country)) self.writeln("ADR:%s;%s;%s;%s;%s;%s;%s" % (postbox, ext,
street, city,
state, zip,
country))
phone = address.get_phone() phone = address.get_phone()
if phone: if phone:
@@ -249,11 +254,9 @@ class CardWriter:
# #
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
def exportData(database,filename,person,option_box,callback=None): def exportData(database, filename, person, option_box, callback=None):
ret = 0 cw = CardWriter(database, person, 0, filename, option_box, callback)
cw = CardWriter(database,person,0,filename,option_box,callback) return cw.export_data(filename)
ret = cw.export_data(filename)
return ret
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
@@ -262,7 +265,7 @@ def exportData(database,filename,person,option_box,callback=None):
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
_title = _('vCard') _title = _('vCard')
_description = _('vCard is used in many addressbook and pim applications.') _description = _('vCard is used in many addressbook and pim applications.')
_config = (_('vCard export options'),CardWriterOptionBox) _config = (_('vCard export options'), CardWriterOptionBox)
_filename = 'vcf' _filename = 'vcf'
register_export(exportData,_title,_description,_config,_filename) register_export(exportData, _title, _description, _config, _filename)

View File

@@ -1,7 +1,7 @@
# #
# Gramps - a GTK+/GNOME based genealogy program # Gramps - a GTK+/GNOME based genealogy program
# #
# Copyright (C) 2000-2007 Donald N. Allingham # Copyright (C) 2000-2008 Donald N. Allingham
# #
# This program is free software; you can redistribute it and/or modify # 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 # it under the terms of the GNU General Public License as published by
@@ -29,7 +29,7 @@
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
import os import os
import sys import sys
from cStringIO import StringIO #from cStringIO import StringIO
from gettext import gettext as _ from gettext import gettext as _
#------------------------------------------------------------------------ #------------------------------------------------------------------------
@@ -67,8 +67,8 @@ except:
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
from GrampsDbUtils import XmlWriter from GrampsDbUtils import XmlWriter
import Mime #import Mime
import const #import const
import QuestionDialog import QuestionDialog
from PluginUtils import register_export from PluginUtils import register_export
@@ -80,9 +80,8 @@ _title_string = _("Export to CD")
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
def writeData(database, filename, person, option_box=None, callback=None): def writeData(database, filename, person, option_box=None, callback=None):
ret = 0
writer = PackageWriter(database, filename, callback) writer = PackageWriter(database, filename, callback)
writer.export() return writer.export()
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
@@ -99,9 +98,9 @@ class PackageWriter:
def export(self): def export(self):
if self.cl: if self.cl:
self.cl_run() return self.cl_run()
else: else:
self.gui_run() return self.gui_run()
def cl_run(self): def cl_run(self):
base = os.path.basename(self.filename) base = os.path.basename(self.filename)
@@ -112,12 +111,12 @@ class PackageWriter:
except FileExistsError, msg: except FileExistsError, msg:
QuestionDialog.ErrorDialog(_("CD export preparation failed"), QuestionDialog.ErrorDialog(_("CD export preparation failed"),
"1 %s " % str(msg)) "1 %s " % str(msg))
return return False
except: except:
uri_name = "burn:///" + base uri_name = "burn:///" + base
QuestionDialog.ErrorDialog("CD export preparation failed", QuestionDialog.ErrorDialog("CD export preparation failed",
'Could not create %s' % uri_name) 'Could not create %s' % uri_name)
return return False
for obj_id in self.db.get_media_object_handles(): for obj_id in self.db.get_media_object_handles():
obj = self.db.get_object_from_handle(obj_id) obj = self.db.get_object_from_handle(obj_id)
@@ -134,6 +133,7 @@ class PackageWriter:
gfile = XmlWriter(self.db, None, 2) gfile = XmlWriter(self.db, None, 2)
gfile.write_handle(g) gfile.write_handle(g)
g.close() g.close()
return True
def gui_run(self): def gui_run(self):
missmedia_action = 0 missmedia_action = 0
@@ -146,12 +146,12 @@ class PackageWriter:
except FileExistsError: except FileExistsError:
QuestionDialog.ErrorDialog(_("CD export preparation failed"), QuestionDialog.ErrorDialog(_("CD export preparation failed"),
"File already exists") "File already exists")
return return False
except: except:
uri_name = "burn:///" + base uri_name = "burn:///" + base
QuestionDialog.ErrorDialog(_("CD export preparation failed"), QuestionDialog.ErrorDialog(_("CD export preparation failed"),
_('Could not create %s') % uri_name) _('Could not create %s') % uri_name)
return return False
try: try:
uri = URI('burn:///%s/.thumb' % base) uri = URI('burn:///%s/.thumb' % base)
@@ -159,12 +159,12 @@ class PackageWriter:
except FileExistsError, msg: except FileExistsError, msg:
QuestionDialog.ErrorDialog("CD export preparation failed", QuestionDialog.ErrorDialog("CD export preparation failed",
"4 %s " % str(msg)) "4 %s " % str(msg))
return return False
except: except:
uri_name = "burn:///" + base + "/.thumb" uri_name = "burn:///" + base + "/.thumb"
QuestionDialog.ErrorDialog(_("CD export preparation failed"), QuestionDialog.ErrorDialog(_("CD export preparation failed"),
_('Could not create %s') % uri_name) _('Could not create %s') % uri_name)
return return False
#-------------------------------------------------------- #--------------------------------------------------------
def remove_clicked(): def remove_clicked():
@@ -272,7 +272,7 @@ class PackageWriter:
gfile.write_handle(g) gfile.write_handle(g)
g.close() g.close()
os.system("nautilus --no-desktop burn:///") os.system("nautilus --no-desktop burn:///")
return 1 return True
def copy_file(self, src, dest): def copy_file(self, src, dest):
original = open(src, "r") original = open(src, "r")

View File

@@ -1,7 +1,7 @@
# #
# Gramps - a GTK+/GNOME based genealogy program # Gramps - a GTK+/GNOME based genealogy program
# #
# Copyright (C) 2003-2006 Donald N. Allingham # Copyright (C) 2003-2006, 2008 Donald N. Allingham
# #
# This program is free software; you can redistribute it and/or modify # 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 # it under the terms of the GNU General Public License as published by
@@ -63,18 +63,16 @@ from PluginUtils import register_export
# writeData # writeData
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
def writeData(database,filename,person,option_box,callback=None): def writeData(database, filename, person, option_box, callback=None):
ret = 0 writer = FtreeWriter(database, person, 0, filename, option_box, callback)
writer = FtreeWriter(database,person,0,filename,option_box,callback) return writer.export_data()
ret = writer.export_data()
return ret
class FtreeWriterOptionBox: class FtreeWriterOptionBox:
""" """
Create a VBox with the option widgets and define methods to retrieve Create a VBox with the option widgets and define methods to retrieve
the options. the options.
""" """
def __init__(self,person): def __init__(self, person):
self.person = person self.person = person
def get_option_box(self): def get_option_box(self):
@@ -82,7 +80,7 @@ class FtreeWriterOptionBox:
base = os.path.dirname(__file__) base = os.path.dirname(__file__)
glade_file = "%s/%s" % (base,"writeftree.glade") glade_file = "%s/%s" % (base,"writeftree.glade")
self.top = gtk.glade.XML(glade_file,"top","gramps") self.top = gtk.glade.XML(glade_file, "top", "gramps")
filter_obj = self.top.get_widget("filter") filter_obj = self.top.get_widget("filter")
@@ -111,7 +109,7 @@ class FtreeWriterOptionBox:
com.add_rule(Rules.Person.HasCommonAncestorWith( com.add_rule(Rules.Person.HasCommonAncestorWith(
[self.person.get_gramps_id()])) [self.person.get_gramps_id()]))
the_filters += [all,des,ans,com] the_filters += [all, des, ans, com]
from Filters import CustomFilters from Filters import CustomFilters
the_filters.extend(CustomFilters.get_filters('Person')) the_filters.extend(CustomFilters.get_filters('Person'))
@@ -135,8 +133,8 @@ class FtreeWriterOptionBox:
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
class FtreeWriter: class FtreeWriter:
def __init__(self,database,person,cl=0,filename="", def __init__(self, database, person, cl=0, filename="", option_box=None,
option_box=None,callback = None): callback = None):
self.db = database self.db = database
self.person = person self.person = person
self.option_box = option_box self.option_box = option_box
@@ -164,8 +162,8 @@ class FtreeWriter:
for p in self.option_box.cfilter.apply(self.db, self.db.get_person_handles(sort_handles=False)): for p in self.option_box.cfilter.apply(self.db, self.db.get_person_handles(sort_handles=False)):
self.plist[p] = 1 self.plist[p] = 1
except Errors.FilterError, msg: except Errors.FilterError, msg:
(m1,m2) = msg.messages() (m1, m2) = msg.messages()
ErrorDialog(m1,m2) ErrorDialog(m1, m2)
return return
def update_empty(self): def update_empty(self):
@@ -197,7 +195,7 @@ class FtreeWriter:
sn = pn.get_surname() sn = pn.get_surname()
items = pn.get_first_name().split() items = pn.get_first_name().split()
if len(items) > 0: if len(items) > 0:
n = "%s %s" % (items[0],sn) n = "%s %s" % (items[0], sn)
else: else:
n = sn n = sn
@@ -205,7 +203,7 @@ class FtreeWriter:
if name_map.has_key(n): if name_map.has_key(n):
count = 0 count = 0
while 1: while 1:
nn = "%s%d" % (n,count) nn = "%s%d" % (n, count)
if not name_map.has_key(nn): if not name_map.has_key(nn):
break; break;
count += 1 count += 1
@@ -214,7 +212,7 @@ class FtreeWriter:
else: else:
name_map[n] = key name_map[n] = key
id_map[key] = n id_map[key] = n
id_name[key] = get_name(pn,count) id_name[key] = get_name(pn, count)
f = open(self.filename,"w") f = open(self.filename,"w")
@@ -252,13 +250,13 @@ class FtreeWriter:
death = None death = None
if self.restrict: if self.restrict:
alive = Utils.probably_alive(p,self.db) alive = Utils.probably_alive(p, self.db)
else: else:
alive = 0 alive = 0
if birth and not alive: if birth and not alive:
if death and not alive : if death and not alive :
dates = "%s-%s" % (fdate(birth),fdate(death)) dates = "%s-%s" % (fdate(birth), fdate(death))
else: else:
dates = fdate(birth) dates = fdate(birth)
else: else:
@@ -267,24 +265,26 @@ class FtreeWriter:
else: else:
dates = "" dates = ""
f.write('%s;%s;%s;%s;%s;%s\n' % (name,father,mother,email,web,dates)) f.write('%s;%s;%s;%s;%s;%s\n' % (name, father, mother, email, web,
dates))
f.close() f.close()
return 1 return True
def fdate(val): def fdate(val):
if val.get_year_valid(): if val.get_year_valid():
if val.get_month_valid(): if val.get_month_valid():
if val.get_day_valid(): if val.get_day_valid():
return "%d/%d/%d" % (val.get_day(),val.get_month(),val.get_year()) return "%d/%d/%d" % (val.get_day(), val.get_month(),
val.get_year())
else: else:
return "%d/%d" % (val.get_month(),val.get_year()) return "%d/%d" % (val.get_month(), val.get_year())
else: else:
return "%d" % val.get_year() return "%d" % val.get_year()
else: else:
return "" return ""
def get_name(name,count): def get_name(name, count):
"""returns a name string built from the components of the Name """returns a name string built from the components of the Name
instance, in the form of Firstname Surname""" instance, in the form of Firstname Surname"""
if count == -1: if count == -1:
@@ -310,7 +310,7 @@ def get_name(name,count):
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
_title = _('_Web Family Tree') _title = _('_Web Family Tree')
_description = _('Web Family Tree format.') _description = _('Web Family Tree format.')
_config = (_('Web Family Tree export options'),FtreeWriterOptionBox) _config = (_('Web Family Tree export options'), FtreeWriterOptionBox)
_filename = 'wft' _filename = 'wft'
register_export(writeData,_title,_description,_config,_filename) register_export(writeData, _title, _description, _config,_filename)

View File

@@ -2,7 +2,7 @@
# Gramps - a GTK+/GNOME based genealogy program # Gramps - a GTK+/GNOME based genealogy program
# #
# Copyright (C) 2004 Martin Hawlisch # Copyright (C) 2004 Martin Hawlisch
# Copyright (C) 2004-2006 Donald N. Allingham # Copyright (C) 2004-2006, 2008 Donald N. Allingham
# #
# This program is free software; you can redistribute it and/or modify # 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 # it under the terms of the GNU General Public License as published by
@@ -53,7 +53,7 @@ log = logging.getLogger(".WriteGeneWeb")
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
import gen.lib import gen.lib
from Filters import GenericFilter, Rules, build_filter_menu from Filters import GenericFilter, Rules, build_filter_menu
import const #import const
import Utils import Utils
import Errors import Errors
from QuestionDialog import ErrorDialog from QuestionDialog import ErrorDialog
@@ -69,7 +69,7 @@ class GeneWebWriterOptionBox:
Create a VBox with the option widgets and define methods to retrieve Create a VBox with the option widgets and define methods to retrieve
the options. the options.
""" """
def __init__(self,person): def __init__(self, person):
self.person = person self.person = person
def get_option_box(self): def get_option_box(self):
@@ -80,7 +80,7 @@ class GeneWebWriterOptionBox:
if not os.path.isfile(glade_file): if not os.path.isfile(glade_file):
glade_file = "plugins/genewebexport.glade" glade_file = "plugins/genewebexport.glade"
self.topDialog = gtk.glade.XML(glade_file,"genewebExport","gramps") self.topDialog = gtk.glade.XML(glade_file, "genewebExport", "gramps")
self.topDialog.signal_autoconnect({ self.topDialog.signal_autoconnect({
"on_restrict_toggled": self.on_restrict_toggled "on_restrict_toggled": self.on_restrict_toggled
}) })
@@ -113,7 +113,7 @@ class GeneWebWriterOptionBox:
com.add_rule(Rules.Person.HasCommonAncestorWith( com.add_rule(Rules.Person.HasCommonAncestorWith(
[self.person.get_gramps_id()])) [self.person.get_gramps_id()]))
the_filters += [all,des,ans,com] the_filters += [all, des, ans, com]
from Filters import CustomFilters from Filters import CustomFilters
the_filters.extend(CustomFilters.get_filters('Person')) the_filters.extend(CustomFilters.get_filters('Person'))
@@ -126,7 +126,7 @@ class GeneWebWriterOptionBox:
self.topDialog.get_widget("genewebExport").destroy() self.topDialog.get_widget("genewebExport").destroy()
return the_box return the_box
def on_restrict_toggled(self,restrict): def on_restrict_toggled(self, restrict):
active = restrict.get_active () active = restrict.get_active ()
map (lambda x: x.set_sensitive (active), map (lambda x: x.set_sensitive (active),
[self.topDialog.get_widget("living"), [self.topDialog.get_widget("living"),
@@ -153,8 +153,8 @@ class GeneWebWriterOptionBox:
self.images_path = "" self.images_path = ""
class GeneWebWriter: class GeneWebWriter:
def __init__(self,database,person,cl=0,filename="", def __init__(self, database, person, cl=0, filename="", option_box=None,
option_box=None,callback=None): callback=None):
self.db = database self.db = database
self.person = person self.person = person
self.option_box = option_box self.option_box = option_box
@@ -195,8 +195,8 @@ class GeneWebWriter:
for p in self.option_box.cfilter.apply(self.db, self.db.get_person_handles(sort_handles=False)): for p in self.option_box.cfilter.apply(self.db, self.db.get_person_handles(sort_handles=False)):
self.plist[p] = 1 self.plist[p] = 1
except Errors.FilterError, msg: except Errors.FilterError, msg:
(m1,m2) = msg.messages() (m1, m2) = msg.messages()
ErrorDialog(m1,m2) ErrorDialog(m1, m2)
return return
self.flist = {} self.flist = {}
@@ -244,25 +244,25 @@ class GeneWebWriter:
for family_handle in p.get_family_handle_list(): for family_handle in p.get_family_handle_list():
self.flist[family_handle] = 1 self.flist[family_handle] = 1
def writeln(self,text): def writeln(self, text):
self.g.write(self.iso8859('%s\n' % (text))) self.g.write(self.iso8859('%s\n' % (text)))
def export_data(self): def export_data(self):
self.dirname = os.path.dirname (self.filename) self.dirname = os.path.dirname (self.filename)
try: try:
self.g = open(self.filename,"w") self.g = open(self.filename, "w")
except IOError,msg: except IOError,msg:
msg2 = _("Could not create %s") % self.filename msg2 = _("Could not create %s") % self.filename
ErrorDialog(msg2,str(msg)) ErrorDialog(msg2, str(msg))
return 0 return False
except: except:
ErrorDialog(_("Could not create %s") % self.filename) ErrorDialog(_("Could not create %s") % self.filename)
return 0 return False
if len(self.flist) < 1: if len(self.flist) < 1:
ErrorDialog(_("No families matched by selected filter")) ErrorDialog(_("No families matched by selected filter"))
return 0 return False
self.count = 0 self.count = 0
self.oldval = 0 self.oldval = 0
@@ -272,9 +272,9 @@ class GeneWebWriter:
self.writeln("") self.writeln("")
self.g.close() self.g.close()
return 1 return True
def write_family(self,family_handle): def write_family(self, family_handle):
family = self.db.get_family_from_handle(family_handle) family = self.db.get_family_from_handle(family_handle)
if family: if family:
self.update() self.update()
@@ -303,7 +303,7 @@ class GeneWebWriter:
note = note.replace('\r',' ') note = note.replace('\r',' ')
self.writeln("comm %s" % note) self.writeln("comm %s" % note)
def write_witness(self,family): def write_witness(self, family):
# FIXME: witnesses are not in events anymore # FIXME: witnesses are not in events anymore
return return
@@ -570,9 +570,9 @@ class GeneWebWriter:
ret = ret + source.get_title() ret = ret + source.get_title()
return ret return ret
def format_single_date(self,subdate,cal,mode): def format_single_date(self, subdate, cal, mode):
retval = "" retval = ""
(day,month,year,sl) = subdate (day, month, year, sl) = subdate
cal_type = "" cal_type = ""
if cal == gen.lib.Date.CAL_HEBREW: if cal == gen.lib.Date.CAL_HEBREW:
@@ -625,10 +625,8 @@ class GeneWebWriter:
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
def exportData(database,filename,person,option_box,callback=None): def exportData(database,filename,person,option_box,callback=None):
ret = 0
gw = GeneWebWriter(database,person,0,filename,option_box,callback) gw = GeneWebWriter(database,person,0,filename,option_box,callback)
ret = gw.export_data() return gw.export_data()
return ret
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
@@ -637,7 +635,7 @@ def exportData(database,filename,person,option_box,callback=None):
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
_title = _('G_eneWeb') _title = _('G_eneWeb')
_description = _('GeneWeb is a web based genealogy program.') _description = _('GeneWeb is a web based genealogy program.')
_config = (_('GeneWeb export options'),GeneWebWriterOptionBox) _config = (_('GeneWeb export options'), GeneWebWriterOptionBox)
_filename = 'gw' _filename = 'gw'
register_export(exportData,_title,_description,_config,_filename) register_export(exportData, _title, _description, _config, _filename)

View File

@@ -1,7 +1,7 @@
# #
# Gramps - a GTK+/GNOME based genealogy program # Gramps - a GTK+/GNOME based genealogy program
# #
# Copyright (C) 2000-2006 Donald N. Allingham # Copyright (C) 2000-2008 Donald N. Allingham
# #
# This program is free software; you can redistribute it and/or modify # 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 # it under the terms of the GNU General Public License as published by
@@ -34,7 +34,7 @@ import tarfile
from cStringIO import StringIO from cStringIO import StringIO
from gettext import gettext as _ from gettext import gettext as _
import ExportOptions import ExportOptions
from BasicUtils import UpdateCallback #from BasicUtils import UpdateCallback
import gen.proxy import gen.proxy
#------------------------------------------------------------------------ #------------------------------------------------------------------------
@@ -60,7 +60,7 @@ import gtk.glade
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
from GrampsDbUtils import XmlWriter from GrampsDbUtils import XmlWriter
import Utils import Utils
from QuestionDialog import MissingMediaDialog #from QuestionDialog import MissingMediaDialog
from PluginUtils import register_export from PluginUtils import register_export
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
@@ -69,8 +69,6 @@ from PluginUtils import register_export
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
def writeData(database, filename, person, option_box, callback=None): def writeData(database, filename, person, option_box, callback=None):
ret = 0
option_box.parse_options() option_box.parse_options()
restrict = option_box.restrict restrict = option_box.restrict
@@ -86,10 +84,8 @@ def writeData(database, filename, person, option_box, callback=None):
if not option_box.cfilter.is_empty(): if not option_box.cfilter.is_empty():
database = gen.proxy.FilterProxyDb(database, option_box.cfilter) database = gen.proxy.FilterProxyDb(database, option_box.cfilter)
writer = PackageWriter(database, filename, callback) writer = PackageWriter(database, filename, callback)
ret = writer.export() return writer.export()
return ret
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
@@ -98,13 +94,13 @@ def writeData(database, filename, person, option_box, callback=None):
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
class PackageWriter: class PackageWriter:
def __init__(self,database,filename,callback): def __init__(self, database, filename, callback):
self.db = database self.db = database
self.callback = callback self.callback = callback
self.filename = filename self.filename = filename
def export(self): def export(self):
missmedia_action = 0 # missmedia_action = 0
#-------------------------------------------------------------- #--------------------------------------------------------------
def remove_clicked(): def remove_clicked():
# File is lost => remove all references and the object itself # File is lost => remove all references and the object itself
@@ -214,11 +210,11 @@ class PackageWriter:
tarinfo.uid = os.getuid() tarinfo.uid = os.getuid()
tarinfo.gid = os.getgid() tarinfo.gid = os.getgid()
g.seek(0) g.seek(0)
archive.addfile(tarinfo,g) archive.addfile(tarinfo, g)
archive.close() archive.close()
g.close() g.close()
return 1 return True
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #