* src/GrampsDb/_GrampsDbBase.py: pychecker

* src/GrampsDb/_GrampsBSDDB.py: pychecker
	* src/RelLib/_CalSdn.py: pychecker
	* src/RelLib/_PrivateSourceNote.py: pychecker
	* src/RelLib/_GenderStats.py: pychecker
	* src/MergePeople.py: pychecker
	* src/SelectObject.py: pychecker
	* src/ScratchPad.py: pychecker
	* src/ImgManip.py: pychecker
	* src/docgen/ODFDoc.py: pychecker
	* src/docgen/OpenOfficeDoc.py: pychecker
	* src/docgen/LPRDoc.py: pychecker
	* src/SelectEvent.py: pychecker


svn: r6418
This commit is contained in:
Don Allingham 2006-04-23 04:29:14 +00:00
parent acde4393f8
commit 291173dc52
14 changed files with 59 additions and 81 deletions

View File

@ -3,6 +3,19 @@
* src/plugins/NavWebPage.py: keep up with RelLib changes * src/plugins/NavWebPage.py: keep up with RelLib changes
2006-04-22 Don Allingham <don@gramps-project.org> 2006-04-22 Don Allingham <don@gramps-project.org>
* src/GrampsDb/_GrampsDbBase.py: pychecker
* src/GrampsDb/_GrampsBSDDB.py: pychecker
* src/RelLib/_CalSdn.py: pychecker
* src/RelLib/_PrivateSourceNote.py: pychecker
* src/RelLib/_GenderStats.py: pychecker
* src/MergePeople.py: pychecker
* src/SelectObject.py: pychecker
* src/ScratchPad.py: pychecker
* src/ImgManip.py: pychecker
* src/docgen/ODFDoc.py: pychecker
* src/docgen/OpenOfficeDoc.py: pychecker
* src/docgen/LPRDoc.py: pychecker
* src/SelectEvent.py: pychecker
* src/GrampsDb/_ReadXML.py: fix Type str_from_xml calls * src/GrampsDb/_ReadXML.py: fix Type str_from_xml calls
* src/DataViews/_MediaView.py: Shorten tab name * src/DataViews/_MediaView.py: Shorten tab name
* src/DataViews/_RepositoryView.py: Shorten tab name * src/DataViews/_RepositoryView.py: Shorten tab name

View File

@ -1217,7 +1217,7 @@ class GrampsBSDDB(GrampsDbBase):
while data: while data:
handle,val = data handle,val = data
p = Person(val) p = Person(val)
self.genderStats.count_person(p,self) self.genderStats.count_person(p)
data = cursor.next() data = cursor.next()
cursor.close() cursor.close()
self.metadata.put('version',7) self.metadata.put('version',7)

View File

@ -405,9 +405,9 @@ class GrampsDbBase(GrampsDBCallback):
if (old_data[2] != person.gender or if (old_data[2] != person.gender or
old_data[3][2]!= person.primary_name.first_name): old_data[3][2]!= person.primary_name.first_name):
self.genderStats.uncount_person(old_person) self.genderStats.uncount_person(old_person)
self.genderStats.count_person(person, self) self.genderStats.count_person(person)
else: else:
self.genderStats.count_person(person, self) self.genderStats.count_person(person)
for attr in person.attribute_list: for attr in person.attribute_list:
self.individual_attributes.add(str(attr.type)) self.individual_attributes.add(str(attr.type))
@ -831,7 +831,7 @@ class GrampsDbBase(GrampsDBCallback):
obj.handle = self.create_id() obj.handle = self.create_id()
commit_func(obj, transaction) commit_func(obj, transaction)
if obj.__class__.__name__ == 'Person': if obj.__class__.__name__ == 'Person':
self.genderStats.count_person (obj, self) self.genderStats.count_person (obj)
return obj.handle return obj.handle
def add_person(self, person, transaction): def add_person(self, person, transaction):

View File

@ -67,9 +67,6 @@ class ImgManip:
return (self.width, self.height) return (self.width, self.height)
def fmt_thumbnail(self,dest,width,height,cnv): def fmt_thumbnail(self,dest,width,height,cnv):
w = int(width)
h = int(height)
scaled = self.img.scale_simple(width, height, gtk.gdk.INTERP_BILINEAR) scaled = self.img.scale_simple(width, height, gtk.gdk.INTERP_BILINEAR)
scaled.save(dest,cnv) scaled.save(dest,cnv)

View File

@ -55,7 +55,7 @@ sex = ( _("female"), _("male"), _("unknown"))
class Compare: class Compare:
def __init__(self, db, person1, person2, update) : def __init__(self, db, person1, person2, update) :
self.glade = gtk.glade.XML(const.mergeFile,"merge") self.glade = gtk.glade.XML(const.merge_glade, "merge")
self.top = self.glade.get_widget('merge') self.top = self.glade.get_widget('merge')
self.text1 = self.glade.get_widget('text1') self.text1 = self.glade.get_widget('text1')
self.text2 = self.glade.get_widget('text2') self.text2 = self.glade.get_widget('text2')
@ -166,7 +166,7 @@ class Compare:
if spouse_id: if spouse_id:
spouse = self.db.get_person_from_handle(spouse_id) spouse = self.db.get_person_from_handle(spouse_id)
self.add(tobj,indent,"%s:\t%s" % (_('Spouse'),name_of(spouse))) self.add(tobj,indent,"%s:\t%s" % (_('Spouse'),name_of(spouse)))
relstr = const.family_relations[family.get_relationship()][0] relstr = str(family.get_relationship())
self.add(tobj,indent,"%s:\t%s" % (_('Type'),relstr)) self.add(tobj,indent,"%s:\t%s" % (_('Type'),relstr))
event = ReportUtils.find_marriage(self.db,family) event = ReportUtils.find_marriage(self.db,family)
if event: if event:
@ -256,7 +256,7 @@ def check_for_child(p1, p2):
class MergePeopleUI: class MergePeopleUI:
def __init__(self,db,person1,person2,update): def __init__(self,db,person1,person2,update):
glade = gtk.glade.XML(const.mergeFile,'merge_people') glade = gtk.glade.XML(const.merge_glade, 'merge_people')
top = glade.get_widget('merge_people') top = glade.get_widget('merge_people')
p1 = glade.get_widget('person1') p1 = glade.get_widget('person1')
p2 = glade.get_widget('person2') p2 = glade.get_widget('person2')
@ -572,7 +572,7 @@ class MergePeople:
# of the families, and adding the families to the merged # of the families, and adding the families to the merged
# person # person
for (family_handle,mrel,frel) in parent_list: for family_handle in parent_list:
self.convert_child_ids(family_handle, self.new_handle, self.convert_child_ids(family_handle, self.new_handle,
self.old_handle, trans) self.old_handle, trans)
new.add_parent_family_handle(family_handle, mrel, frel) new.add_parent_family_handle(family_handle, mrel, frel)
@ -584,13 +584,14 @@ class MergePeople:
""" """
family = self.db.get_family_from_handle(fhandle) family = self.db.get_family_from_handle(fhandle)
new_child_list = [] new_child_list = []
orig_list = family.get_child_handle_list() orig_list = family.get_child_ref_list()
# loop through original child list. If a handle matches the # loop through original child list. If a handle matches the
# old handle, replace it with the new handle if the new handle # old handle, replace it with the new handle if the new handle
# is not already in the list # is not already in the list
for child_id in orig_list:
if child_id == old_handle: for child_ref in orig_list:
if child_ref.ref == old_handle:
if new_handle not in new_child_list: if new_handle not in new_child_list:
new_child_list.append(new_handle) new_child_list.append(new_handle)
elif child_id not in new_child_list: elif child_id not in new_child_list:
@ -599,7 +600,7 @@ class MergePeople:
# compare the new list with the original list. If this list # compare the new list with the original list. If this list
# is different, we need to save the changes to the database. # is different, we need to save the changes to the database.
if new_child_list != orig_list: if new_child_list != orig_list:
family.set_child_handle_list(new_child_list) family.set_child_ref_list(new_child_list)
self.db.commit_family(family,trans) self.db.commit_family(family,trans)
def merge_relationships(self,new,trans): def merge_relationships(self,new,trans):

View File

@ -25,7 +25,7 @@
# Python modules # Python modules
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
import cmath import math
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
@ -482,24 +482,24 @@ def persian_sdn(year, month, day):
v1 = (month - 1) * 31 v1 = (month - 1) * 31
else: else:
v1 = ((month - 1) * 30) + 6 v1 = ((month - 1) * 30) + 6
v2 = cmath.floor(((epyear * 682) - 110) / 2816) v2 = math.floor(((epyear * 682) - 110) / 2816)
v3 = (epyear - 1) * 365 + day v3 = (epyear - 1) * 365 + day
v4 = cmath.floor(epbase / 2820) * 1029983 v4 = math.floor(epbase / 2820) * 1029983
return int(cmath.ceil(v1 + v2 + v3 + v4 + _PRS_EPOCH - 1)) return int(math.ceil(v1 + v2 + v3 + v4 + _PRS_EPOCH - 1))
def persian_ymd(sdn): def persian_ymd(sdn):
sdn = cmath.floor(sdn) + 0.5 sdn = math.floor(sdn) + 0.5
depoch = sdn - 2121446 depoch = sdn - 2121446
cycle = cmath.floor(depoch / 1029983) cycle = math.floor(depoch / 1029983)
cyear = depoch % 1029983 cyear = depoch % 1029983
if cyear == 1029982: if cyear == 1029982:
ycycle = 2820 ycycle = 2820
else: else:
aux1 = cmath.floor(cyear / 366) aux1 = math.floor(cyear / 366)
aux2 = cyear % 366 aux2 = cyear % 366
ycycle = cmath.floor(((2134*aux1)+(2816*aux2)+2815)/1028522) + aux1 + 1 ycycle = math.floor(((2134*aux1)+(2816*aux2)+2815)/1028522) + aux1 + 1
year = ycycle + (2820 * cycle) + 474 year = ycycle + (2820 * cycle) + 474
if year <= 0: if year <= 0:
@ -507,22 +507,22 @@ def persian_ymd(sdn):
yday = sdn - persian_sdn(year, 1, 1) + 1 yday = sdn - persian_sdn(year, 1, 1) + 1
if yday < 186: if yday < 186:
month = cmath.ceil(yday / 31) month = math.ceil(yday / 31)
else: else:
month = cmath.ceil((yday - 6) / 30) month = math.ceil((yday - 6) / 30)
day = (sdn - persian_sdn(year, month, 1)) + 1 day = (sdn - persian_sdn(year, month, 1)) + 1
return (int(year), int(month), int(day)) return (int(year), int(month), int(day))
def islamic_sdn(year, month, day): def islamic_sdn(year, month, day):
v1 = cmath.ceil(29.5 * (month - 1)) v1 = math.ceil(29.5 * (month - 1))
v2 = (year - 1) * 354 v2 = (year - 1) * 354
v3 = cmath.floor((3 + (11 *year)) / 30) v3 = math.floor((3 + (11 *year)) / 30)
return int(cmath.ceil((day + v1 + v2 + v3 + _ISM_EPOCH) - 1)) return int(math.ceil((day + v1 + v2 + v3 + _ISM_EPOCH) - 1))
def islamic_ymd(sdn): def islamic_ymd(sdn):
sdn = cmath.floor(sdn) + 0.5 sdn = math.floor(sdn) + 0.5
year = int(cmath.floor(((30*(sdn-_ISM_EPOCH))+10646)/10631)) year = int(math.floor(((30*(sdn-_ISM_EPOCH))+10646)/10631))
month = int(min(12, cmath.ceil((sdn-(29+islamic_sdn(year,1,1)))/29.5) + 1)) month = int(min(12, math.ceil((sdn-(29+islamic_sdn(year,1,1)))/29.5) + 1))
day = int((sdn - islamic_sdn(year,month,1)) + 1) day = int((sdn - islamic_sdn(year,month,1)) + 1)
return (year,month,day) return (year,month,day)

View File

@ -63,7 +63,7 @@ class GenderStats:
return self.stats[name] return self.stats[name]
return (0, 0, 0) return (0, 0, 0)
def count_person (self, person, db, undo = 0): def count_person (self, person, undo = 0):
if not person: if not person:
return return
# Let the Person do their own counting later # Let the Person do their own counting later
@ -90,7 +90,7 @@ class GenderStats:
return return
def uncount_person (self, person): def uncount_person (self, person):
return self.count_person (person, None, undo = 1) return self.count_person (person, undo = 1)
def guess_gender (self, name): def guess_gender (self, name):
name = self._get_key_from_name (name) name = self._get_key_from_name (name)

View File

@ -24,6 +24,9 @@
PrivateSourceNote class for GRAMPS PrivateSourceNote class for GRAMPS
""" """
from _SourceNote import SourceNote
from _PrivacyBase import PrivacyBase
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
# PrivateSourceNote class # PrivateSourceNote class
@ -32,4 +35,5 @@ PrivateSourceNote class for GRAMPS
class PrivateSourceNote(SourceNote,PrivacyBase): class PrivateSourceNote(SourceNote,PrivacyBase):
# FIXME: this class is only present to enable db upgrade # FIXME: this class is only present to enable db upgrade
def __init__(self): def __init__(self):
pass SourceNote.__init__(self)
PrivacyBase.__init__(self)

View File

@ -29,7 +29,6 @@ import cPickle as pickle
import os import os
from xml.sax.saxutils import escape from xml.sax.saxutils import escape
from gettext import gettext as _ from gettext import gettext as _
import Utils
from time import strftime as strftime from time import strftime as strftime
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
@ -193,9 +192,6 @@ class ScratchPadLocation(ScratchPadGrampsTypeWrapper):
"\t<b>%s:</b>\t%s\n"\ "\t<b>%s:</b>\t%s\n"\
"\t<b>%s:</b>\n"\ "\t<b>%s:</b>\n"\
"\t\t%s\n"\ "\t\t%s\n"\
"\t\t%s\n"\
"\t\t%s\n"\
"\t\t%s\n"\
"\t<b>%s:</b>\t%s\n" % ( "\t<b>%s:</b>\t%s\n" % (
_("Location"), _("Location"),
escape(self._obj.get_city()), escape(self._obj.get_city()),
@ -259,8 +255,8 @@ class ScratchPadFamilyEvent(ScratchPadGrampsTypeWrapper):
DRAG_TARGET = DdTargets.FAMILY_EVENT DRAG_TARGET = DdTargets.FAMILY_EVENT
ICON = BLANK_PIC ICON = BLANK_PIC
def __init__(self,db,obj): def __init__(self, dbstate, obj):
ScratchPadGrampsTypeWrapper.__init__(self,db,obj) ScratchPadGrampsTypeWrapper.__init__(self, dbstate, obj)
self._type = _("Family Event") self._type = _("Family Event")
self._title = str(self._obj.get_type()) self._title = str(self._obj.get_type())
self._value = self._obj.get_description() self._value = self._obj.get_description()
@ -277,7 +273,7 @@ class ScratchPadFamilyEvent(ScratchPadGrampsTypeWrapper):
_("Family Event"), _("Family Event"),
_("Type"),escape(str(self._obj.get_type())), _("Type"),escape(str(self._obj.get_type())),
_("Date"),escape(DateHandler.get_date(self._obj)), _("Date"),escape(DateHandler.get_date(self._obj)),
_("Place"),escape(place_title(self.db,self._obj)), _("Place"),escape(place_title(self._db, self._obj)),
_("Cause"),escape(self._obj.get_cause()), _("Cause"),escape(self._obj.get_cause()),
_("Description"), escape(self._obj.get_description())) _("Description"), escape(self._obj.get_description()))
@ -325,7 +321,7 @@ class ScratchPadAttribute(ScratchPadGrampsTypeWrapper):
def __init__(self, db, obj): def __init__(self, db, obj):
ScratchPadGrampsTypeWrapper.__init__(self, db, obj) ScratchPadGrampsTypeWrapper.__init__(self, db, obj)
self._type = _("Attribute") self._type = _("Attribute")
self._title = Utils.format_personal_attribute(self._obj.get_type()) self._title = str(self._obj.get_type())
self._value = self._obj.get_value() self._value = self._obj.get_value()
def tooltip(self): def tooltip(self):
@ -334,7 +330,7 @@ class ScratchPadAttribute(ScratchPadGrampsTypeWrapper):
"\t<b>%s:</b>\t%s\n"\ "\t<b>%s:</b>\t%s\n"\
"\t<b>%s:</b>\t%s" % (_("Attribute"), "\t<b>%s:</b>\t%s" % (_("Attribute"),
_("Type"), _("Type"),
escape(Utils.format_personal_attribute(self._obj.get_type())), escape(str(self._obj.get_type())),
_("Value"), _("Value"),
escape(self._obj.get_value())) escape(self._obj.get_value()))
@ -358,7 +354,7 @@ class ScratchPadFamilyAttribute(ScratchPadGrampsTypeWrapper):
def __init__(self, db, obj): def __init__(self, db, obj):
ScratchPadGrampsTypeWrapper.__init__(self, db, obj) ScratchPadGrampsTypeWrapper.__init__(self, db, obj)
self._type = _("Family Attribute") self._type = _("Family Attribute")
self._title = Utils.format_family_attribute(self._obj.get_type()) self._title = str(self._obj.get_type())
self._value = self._obj.get_value() self._value = self._obj.get_value()
def tooltip(self): def tooltip(self):
@ -367,7 +363,7 @@ class ScratchPadFamilyAttribute(ScratchPadGrampsTypeWrapper):
"\t<b>%s:</b>\t%s\n"\ "\t<b>%s:</b>\t%s\n"\
"\t<b>%s:</b>\t%s" % (_("Family Attribute"), "\t<b>%s:</b>\t%s" % (_("Family Attribute"),
_("Type"), _("Type"),
escape(Utils.format_family_attribute(self._obj.get_type())), escape(str(self._obj.get_type())),
_("Value"), _("Value"),
escape(self._obj.get_value())) escape(self._obj.get_value()))
@ -506,7 +502,7 @@ class ScratchMediaObj(ScratchPadWrapper):
DRAG_TARGET = DdTargets.MEDIAOBJ DRAG_TARGET = DdTargets.MEDIAOBJ
ICON = LINK_PIC ICON = LINK_PIC
def __init__(self, db, nobj): def __init__(self, db, obj):
ScratchPadWrapper.__init__(self, db, obj) ScratchPadWrapper.__init__(self, db, obj)
self._type = _("Media Object") self._type = _("Media Object")

View File

@ -49,7 +49,6 @@ import gtk.glade
import const import const
import Utils import Utils
import ListModel import ListModel
import RelLib
import DateHandler import DateHandler
#------------------------------------------------------------------------- #-------------------------------------------------------------------------

View File

@ -108,36 +108,6 @@ class SelectObject:
self.object_model.add([pixbuf,title,obj.get_gramps_id(),the_type],key) self.object_model.add([pixbuf,title,obj.get_gramps_id(),the_type],key)
self.object_model.connect_model() self.object_model.connect_model()
def on_select_row(self,obj):
store,node = self.object_model.get_selected()
if not node:
return
data = self.object_model.get_data(node,range(self.ncols))
handle = data[4]
obj = self.db.get_object_from_handle(handle)
the_type = obj.get_mime_type()
path = obj.get_path()
if the_type and the_type.startswith("image/"):
image = ImgManip.get_thumbnail_image(path,the_type)
else:
image = Mime.find_mime_type_pixbuf(the_type)
self.preview.set_from_pixbuf(image)
self.object_handle.set_text(obj.get_gramps_id())
if the_type:
self.object_type.set_text(the_type)
else:
self.object_type.set_text("")
self.object_desc.set_text(obj.get_description())
if len(path) == 0:
self.object_path.set_text(_("The file no longer exists"))
elif path[0] == "/":
self.object_path.set_text(path)
else:
self.object_path.set_text("<local>")
self.object_details.set_text(Utils.get_detail_text(obj,0))
def run(self): def run(self):
val = self.top.run() val = self.top.run()

View File

@ -60,6 +60,8 @@ else:
print " or wait for the next gnome-python release." print " or wait for the next gnome-python release."
### end FIXME ### ### end FIXME ###
import Errors
#------------------------------------------------------------------------ #------------------------------------------------------------------------
# #
# gramps modules # gramps modules
@ -773,7 +775,6 @@ class LPRDoc(BaseDoc.BaseDoc):
photo.get_rowstride()) photo.get_rowstride())
self.gpc.grestore() self.gpc.grestore()
x = x
y = y - height y = y - height
return (x,y) return (x,y)

View File

@ -38,7 +38,6 @@ from math import pi, cos, sin, fabs
# Gramps modules # Gramps modules
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
import Errors
import BaseDoc import BaseDoc
import const import const
from PluginUtils import ReportUtils, \ from PluginUtils import ReportUtils, \

View File

@ -28,7 +28,6 @@
import os import os
import zipfile import zipfile
import time import time
import locale
from cStringIO import StringIO from cStringIO import StringIO
from math import pi, cos, sin, fabs from math import pi, cos, sin, fabs
from gettext import gettext as _ from gettext import gettext as _
@ -39,7 +38,6 @@ from xml.sax.saxutils import escape
# Gramps modules # Gramps modules
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
import Errors
import BaseDoc import BaseDoc
import const import const
from PluginUtils import ReportUtils, \ from PluginUtils import ReportUtils, \