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>
* src/DbLoader.py: typo
* 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
from BasicUtils import UpdateCallback
from gen.db.dbconst import \
PERSON_KEY,FAMILY_KEY,SOURCE_KEY,EVENT_KEY,\
MEDIA_KEY,PLACE_KEY,REPOSITORY_KEY,NOTE_KEY
from gen.db.exceptions import *
from gen.utils.longop import LongOpStatus
#from gen.db.dbconst import \
# PERSON_KEY,FAMILY_KEY,SOURCE_KEY,EVENT_KEY,\
# MEDIA_KEY,PLACE_KEY,REPOSITORY_KEY,NOTE_KEY
#
from gen.db.exceptions import GrampsDbWriteFailure
#from gen.utils.longop import LongOpStatus
import gen.proxy
@ -91,7 +91,6 @@ def escxml(d):
#
#-------------------------------------------------------------------------
def exportData(database, filename, person, option_box, callback, version="unknown"):
ret = 0
if os.path.isfile(filename):
try:
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)
g = GrampsDbXmlWriter(database, 0, compress, version, callback)
ret = g.write(filename)
return ret
return g.write(filename)
#-------------------------------------------------------------------------
#

View File

@ -322,7 +322,7 @@ class GedcomWriter(BasicUtils.UpdateCallback):
self.__writeln(0, "TRLR")
self.gedcom_file.close()
return 1
return True
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.
"""
ret = 0
ret = False
try:
ged_write = GedcomWriter(database, person, 0,
option_box, callback)

View File

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

View File

@ -2,7 +2,7 @@
# Gramps - a GTK+/GNOME based genealogy program
#
# 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
# 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
import const
#import const
import Utils
from gen.lib import Date, EventType
import Errors
@ -127,8 +127,8 @@ class CalendarWriterOptionBox:
class CalendarWriter:
def __init__(self,database,person,cl=0,filename="",
option_box=None,callback=None):
def __init__(self, database, person, cl=0, filename="", option_box=None,
callback=None):
self.db = database
self.person = person
self.option_box = option_box
@ -202,10 +202,10 @@ class CalendarWriter:
except IOError,msg:
msg2 = _("Could not create %s") % filename
ErrorDialog(msg2, str(msg))
return 0
return False
except:
ErrorDialog(_("Could not create %s") % filename)
return 0
return False
self.writeln("BEGIN:VCALENDAR");
self.writeln("PRODID:-//GNU//Gramps//EN");
@ -226,7 +226,7 @@ class CalendarWriter:
self.writeln("END:VCALENDAR");
self.g.close()
return 1
return True
def write_family(self, family_handle):
family = self.db.get_family_from_handle(family_handle)
@ -236,7 +236,8 @@ class CalendarWriter:
if event.get_type() == EventType.MARRIAGE:
m_date = event.get_date_object()
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:
place = self.db.get_place_from_handle(place_handle)
self.write_vevent( text, m_date, place.get_title())
@ -296,14 +297,19 @@ class CalendarWriter:
mod = date.get_modifier()
cal = cal = date.get_calendar()
if mod == Date.MOD_SPAN or mod == Date.MOD_RANGE:
start = self.format_single_date(date.get_start_date(),thisyear,cal)
end = self.format_single_date(date.get_stop_date(),thisyear,cal)
start = self.format_single_date(date.get_start_date(),
thisyear, cal)
end = self.format_single_date(date.get_stop_date(),
thisyear, cal)
if start and end:
retval = "DTSTART:%sT000001\nDTEND:%sT235959" % (start,end)
retval = "DTSTART:%sT000001\nDTEND:%sT235959" % (start,
end)
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:
retval = "DTSTART:%sT000001\nDTEND:%sT235959" % (start,start)
retval = "DTSTART:%sT000001\nDTEND:%sT235959" % (start,
start)
return retval
def write_vevent(self, event_text, date, location=""):
@ -333,10 +339,8 @@ class CalendarWriter:
#
#-------------------------------------------------------------------------
def exportData(database, filename, person, option_box, callback=None):
ret = 0
cw = CalendarWriter(database, person, 0, filename, option_box, callback)
ret = cw.export_data(filename)
return ret
return cw.export_data(filename)
#-------------------------------------------------------------------------
#

View File

@ -2,7 +2,7 @@
# Gramps - a GTK+/GNOME based genealogy program
#
# 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
# it under the terms of the GNU General Public License as published by
@ -122,8 +122,8 @@ class CardWriterOptionBox:
self.cfilter = self.filter_menu.get_active().get_data("filter")
class CardWriter:
def __init__(self,database,person,cl=0,filename="",
option_box=None,callback=None):
def __init__(self, database, person, cl=0, filename="", option_box=None,
callback=None):
self.db = database
self.person = person
self.option_box = option_box
@ -147,7 +147,8 @@ class CardWriter:
self.plist[p] = 1
else:
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
except Errors.FilterError, msg:
(m1, m2) = msg.messages()
@ -179,10 +180,10 @@ class CardWriter:
except IOError,msg:
msg2 = _("Could not create %s") % filename
ErrorDialog(msg2, str(msg))
return 0
return False
except:
ErrorDialog(_("Could not create %s") % filename)
return 0
return False
self.count = 0
self.oldval = 0
@ -192,7 +193,7 @@ class CardWriter:
self.update()
self.g.close()
return 1
return True
def write_person(self, person_handle):
person = self.db.get_person_from_handle(person_handle)
@ -217,7 +218,8 @@ class CardWriter:
not mod == Date.MOD_RANGE):
(day, month, year, sl) = b_date.get_start_date()
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()
for address in address_list:
@ -229,7 +231,10 @@ class CardWriter:
zip = address.get_postal_code()
country = address.get_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()
if phone:
@ -250,10 +255,8 @@ class CardWriter:
#
#-------------------------------------------------------------------------
def exportData(database, filename, person, option_box, callback=None):
ret = 0
cw = CardWriter(database, person, 0, filename, option_box, callback)
ret = cw.export_data(filename)
return ret
return cw.export_data(filename)
#-------------------------------------------------------------------------
#

View File

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

View File

@ -1,7 +1,7 @@
#
# 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
# it under the terms of the GNU General Public License as published by
@ -64,10 +64,8 @@ from PluginUtils import register_export
#
#-------------------------------------------------------------------------
def writeData(database, filename, person, option_box, callback=None):
ret = 0
writer = FtreeWriter(database, person, 0, filename, option_box, callback)
ret = writer.export_data()
return ret
return writer.export_data()
class FtreeWriterOptionBox:
"""
@ -135,8 +133,8 @@ class FtreeWriterOptionBox:
#-------------------------------------------------------------------------
class FtreeWriter:
def __init__(self,database,person,cl=0,filename="",
option_box=None,callback = None):
def __init__(self, database, person, cl=0, filename="", option_box=None,
callback = None):
self.db = database
self.person = person
self.option_box = option_box
@ -267,16 +265,18 @@ class FtreeWriter:
else:
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()
return 1
return True
def fdate(val):
if val.get_year_valid():
if val.get_month_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:
return "%d/%d" % (val.get_month(), val.get_year())
else:

View File

@ -2,7 +2,7 @@
# Gramps - a GTK+/GNOME based genealogy program
#
# 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
# it under the terms of the GNU General Public License as published by
@ -53,7 +53,7 @@ log = logging.getLogger(".WriteGeneWeb")
#-------------------------------------------------------------------------
import gen.lib
from Filters import GenericFilter, Rules, build_filter_menu
import const
#import const
import Utils
import Errors
from QuestionDialog import ErrorDialog
@ -153,8 +153,8 @@ class GeneWebWriterOptionBox:
self.images_path = ""
class GeneWebWriter:
def __init__(self,database,person,cl=0,filename="",
option_box=None,callback=None):
def __init__(self, database, person, cl=0, filename="", option_box=None,
callback=None):
self.db = database
self.person = person
self.option_box = option_box
@ -255,14 +255,14 @@ class GeneWebWriter:
except IOError,msg:
msg2 = _("Could not create %s") % self.filename
ErrorDialog(msg2, str(msg))
return 0
return False
except:
ErrorDialog(_("Could not create %s") % self.filename)
return 0
return False
if len(self.flist) < 1:
ErrorDialog(_("No families matched by selected filter"))
return 0
return False
self.count = 0
self.oldval = 0
@ -272,7 +272,7 @@ class GeneWebWriter:
self.writeln("")
self.g.close()
return 1
return True
def write_family(self, family_handle):
family = self.db.get_family_from_handle(family_handle)
@ -625,10 +625,8 @@ class GeneWebWriter:
#
#-------------------------------------------------------------------------
def exportData(database,filename,person,option_box,callback=None):
ret = 0
gw = GeneWebWriter(database,person,0,filename,option_box,callback)
ret = gw.export_data()
return ret
return gw.export_data()
#-------------------------------------------------------------------------
#

View File

@ -1,7 +1,7 @@
#
# 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
# it under the terms of the GNU General Public License as published by
@ -34,7 +34,7 @@ import tarfile
from cStringIO import StringIO
from gettext import gettext as _
import ExportOptions
from BasicUtils import UpdateCallback
#from BasicUtils import UpdateCallback
import gen.proxy
#------------------------------------------------------------------------
@ -60,7 +60,7 @@ import gtk.glade
#-------------------------------------------------------------------------
from GrampsDbUtils import XmlWriter
import Utils
from QuestionDialog import MissingMediaDialog
#from QuestionDialog import MissingMediaDialog
from PluginUtils import register_export
#-------------------------------------------------------------------------
@ -69,8 +69,6 @@ from PluginUtils import register_export
#
#-------------------------------------------------------------------------
def writeData(database, filename, person, option_box, callback=None):
ret = 0
option_box.parse_options()
restrict = option_box.restrict
@ -86,10 +84,8 @@ def writeData(database, filename, person, option_box, callback=None):
if not option_box.cfilter.is_empty():
database = gen.proxy.FilterProxyDb(database, option_box.cfilter)
writer = PackageWriter(database, filename, callback)
ret = writer.export()
return ret
return writer.export()
#-------------------------------------------------------------------------
#
@ -104,7 +100,7 @@ class PackageWriter:
self.filename = filename
def export(self):
missmedia_action = 0
# missmedia_action = 0
#--------------------------------------------------------------
def remove_clicked():
# File is lost => remove all references and the object itself
@ -218,7 +214,7 @@ class PackageWriter:
archive.close()
g.close()
return 1
return True
#-------------------------------------------------------------------------
#