pychecker fixes, GEDCOM import/export improvements, calendar improvements
svn: r1250
This commit is contained in:
@@ -85,22 +85,26 @@ class GraphVizDialog(ReportDialog):
|
||||
des = GenericFilter.GenericFilter()
|
||||
des.set_name(_("Descendants of %s") % name)
|
||||
des.add_rule(GenericFilter.IsDescendantOf([self.person.getId()]))
|
||||
|
||||
|
||||
ans = GenericFilter.GenericFilter()
|
||||
ans.set_name(_("Ancestors of %s") % name)
|
||||
ans.add_rule(GenericFilter.IsAncestorOf([self.person.getId()]))
|
||||
|
||||
return [all,des,ans]
|
||||
com = GenericFilter.GenericFilter()
|
||||
com.set_name(_("People with common ancestor with %s") % name)
|
||||
com.add_rule(GenericFilter.HasCommonAncestorWith([self.person.getId()]))
|
||||
|
||||
return [all,des,ans,com]
|
||||
|
||||
def add_user_options(self):
|
||||
self.arrowstyle_optionmenu = gtk.OptionMenu()
|
||||
menu = gtk.Menu()
|
||||
|
||||
|
||||
menuitem = gtk.MenuItem(_("Descendants <- Ancestors"))
|
||||
menuitem.set_data('t', ('none', 'normal'))
|
||||
menuitem.show()
|
||||
menu.append(menuitem)
|
||||
|
||||
|
||||
menuitem = gtk.MenuItem(_("Descendants -> Ancestors"))
|
||||
menuitem.set_data('t', ('normal', 'none'))
|
||||
menuitem.show()
|
||||
@@ -162,13 +166,21 @@ class GraphVizDialog(ReportDialog):
|
||||
_("Non-birth relationships will show up "
|
||||
"as dashed lines in the graph."))
|
||||
|
||||
self.show_families_cb = gtk.CheckButton(_("Show family nodes"))
|
||||
self.show_families_cb.set_active(0)
|
||||
self.add_frame_option(_("GraphViz Options"),
|
||||
'',
|
||||
self.show_families_cb,
|
||||
_("Families will show up as circles, linked "
|
||||
"to parents and children."))
|
||||
|
||||
tb_margin_adj = gtk.Adjustment(value=0.5, lower=0.25,
|
||||
upper=100.0, step_incr=0.25)
|
||||
lr_margin_adj = gtk.Adjustment(value=0.5, lower=0.25,
|
||||
upper=100.0, step_incr=0.25)
|
||||
|
||||
self.tb_margin_sb = gtk.SpinButton(adj=tb_margin_adj, digits=2)
|
||||
self.lr_margin_sb = gtk.SpinButton(adj=lr_margin_adj, digits=2)
|
||||
self.tb_margin_sb = gtk.SpinButton(adjustment=tb_margin_adj, digits=2)
|
||||
self.lr_margin_sb = gtk.SpinButton(adjustment=lr_margin_adj, digits=2)
|
||||
|
||||
self.add_frame_option(_("GraphViz Options"),
|
||||
_("Top & Bottom Margins"),
|
||||
@@ -180,8 +192,8 @@ class GraphVizDialog(ReportDialog):
|
||||
hpages_adj = gtk.Adjustment(value=1, lower=1, upper=25, step_incr=1)
|
||||
vpages_adj = gtk.Adjustment(value=1, lower=1, upper=25, step_incr=1)
|
||||
|
||||
self.hpages_sb = gtk.SpinButton(adj=hpages_adj, digits=0)
|
||||
self.vpages_sb = gtk.SpinButton(adj=vpages_adj, digits=0)
|
||||
self.hpages_sb = gtk.SpinButton(adjustment=hpages_adj, digits=0)
|
||||
self.vpages_sb = gtk.SpinButton(adjustment=vpages_adj, digits=0)
|
||||
|
||||
self.add_frame_option(_("GraphViz Options"),
|
||||
_("Number of Horizontal Pages"),
|
||||
@@ -239,13 +251,14 @@ class GraphVizDialog(ReportDialog):
|
||||
self.arrowheadstyle, self.arrowtailstyle = menu.get_active().get_data('t')
|
||||
self.includedates = self.includedates_cb.get_active()
|
||||
self.includeurl = self.includeurl_cb.get_active()
|
||||
self.tb_margin = self.tb_margin_sb.get_value_as_float()
|
||||
self.lr_margin = self.lr_margin_sb.get_value_as_float()
|
||||
self.tb_margin = self.tb_margin_sb.get_value()
|
||||
self.lr_margin = self.lr_margin_sb.get_value()
|
||||
self.colorize = self.colorize_cb.get_active()
|
||||
self.adoptionsdashed = self.adoptionsdashed_cb.get_active()
|
||||
self.hpages = self.hpages_sb.get_value_as_int()
|
||||
self.vpages = self.vpages_sb.get_value_as_int()
|
||||
|
||||
self.show_families = self.show_families_cb.get_active()
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
#
|
||||
# Functions related to creating the actual report document.
|
||||
@@ -258,88 +271,119 @@ class GraphVizDialog(ReportDialog):
|
||||
|
||||
file = open(self.target_path,"w")
|
||||
|
||||
ind_list = self.filter.apply(self.db.getPersonMap().values())
|
||||
ind_list = self.filter.apply(self.db, self.db.getPersonMap().values())
|
||||
|
||||
write_dot(file, ind_list, self.orien, width, height,
|
||||
self.tb_margin, self.lr_margin, self.hpages,
|
||||
self.vpages, self.includedates, self.includeurl,
|
||||
self.colorize, self.adoptionsdashed, self.arrowheadstyle, self.arrowtailstyle)
|
||||
|
||||
self.colorize, self.adoptionsdashed, self.arrowheadstyle,
|
||||
self.arrowtailstyle, self.show_families)
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
#
|
||||
#
|
||||
#
|
||||
#
|
||||
#------------------------------------------------------------------------
|
||||
def report(database,person):
|
||||
GraphVizDialog(database,person)
|
||||
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
#
|
||||
#
|
||||
#
|
||||
#
|
||||
#------------------------------------------------------------------------
|
||||
def write_dot(file, ind_list, orien, width, height, tb_margin,
|
||||
lr_margin, hpages, vpages, includedates, includeurl,
|
||||
colorize, adoptionsdashed, arrowheadstyle, arrowtailstyle):
|
||||
colorize, adoptionsdashed, arrowheadstyle, arrowtailstyle,
|
||||
show_families):
|
||||
file.write("digraph g {\n")
|
||||
file.write("bgcolor=white;\n")
|
||||
file.write("rankdir=LR;\n")
|
||||
file.write("center=1;\n")
|
||||
file.write("margin=0.5;\n")
|
||||
file.write("ratio=fill;\n")
|
||||
file.write("size=\"%3.1fin,%3.1fin\";\n" % ((width*hpages)-(lr_margin*2)-((hpages-1)*1.0),
|
||||
file.write("size=\"%3.1f,%3.1f\";\n" % ((width*hpages)-(lr_margin*2)-((hpages-1)*1.0),
|
||||
(height*vpages)-(tb_margin*2)-((vpages-1)*1.0)))
|
||||
file.write("page=\"%3.1fin,%3.1fin\";\n" % (width,height))
|
||||
file.write("page=\"%3.1f,%3.1f\";\n" % (width,height))
|
||||
|
||||
if orien == PAPER_LANDSCAPE:
|
||||
file.write("rotate=90;\n")
|
||||
|
||||
if len(ind_list) > 1:
|
||||
dump_index(ind_list,file,includedates,includeurl,colorize)
|
||||
dump_person(ind_list,file,adoptionsdashed,arrowheadstyle,arrowtailstyle)
|
||||
dump_index(ind_list,file,includedates,includeurl,colorize,
|
||||
arrowheadstyle,arrowtailstyle,show_families)
|
||||
dump_person(ind_list,file,adoptionsdashed,arrowheadstyle,
|
||||
arrowtailstyle,show_families)
|
||||
|
||||
file.write("}\n")
|
||||
file.close()
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
#
|
||||
#
|
||||
#
|
||||
#
|
||||
#------------------------------------------------------------------------
|
||||
def dump_person(person_list,file,adoptionsdashed,arrowheadstyle,arrowtailstyle):
|
||||
def dump_person(person_list,file,adoptionsdashed,arrowheadstyle,
|
||||
arrowtailstyle,show_families):
|
||||
# Hash people in a dictionary for faster inclusion checking.
|
||||
person_dict = {}
|
||||
for p in person_list:
|
||||
person_dict[p] = 1
|
||||
|
||||
for person in person_list:
|
||||
pid = string.replace(person.getId(),'-','_')
|
||||
family, mrel, frel = person.getMainParentsRel()
|
||||
if family == None:
|
||||
continue
|
||||
father = family.getFather()
|
||||
if father and father in person_list:
|
||||
fid = string.replace(father.getId(),'-','_')
|
||||
file.write('p%s -> p%s [' % (pid, fid))
|
||||
file.write('arrowhead=%s, arrowtail=%s, ' % (arrowheadstyle, arrowtailstyle))
|
||||
if adoptionsdashed and frel != _("Birth"):
|
||||
file.write('style=dashed')
|
||||
for family, mrel, frel in person.getParentList():
|
||||
father = family.getFather()
|
||||
mother = family.getMother()
|
||||
fadopted = frel != _("Birth")
|
||||
madopted = mrel != _("Birth")
|
||||
if show_families and (person_dict.has_key(father) or
|
||||
person_dict.has_key(mother)):
|
||||
# Link to the family node.
|
||||
famid = string.replace(family.getId(),'-','_')
|
||||
file.write('p%s -> f%s [' % (pid, famid))
|
||||
file.write('arrowhead=%s, arrowtail=%s, ' %
|
||||
(arrowheadstyle, arrowtailstyle))
|
||||
if adoptionsdashed and (fadopted or madopted):
|
||||
file.write('style=dashed')
|
||||
else:
|
||||
file.write('style=solid')
|
||||
file.write('];\n')
|
||||
else:
|
||||
file.write('style=solid')
|
||||
file.write('];\n')
|
||||
mother = family.getMother()
|
||||
if mother and mother in person_list:
|
||||
mid = string.replace(mother.getId(),'-','_')
|
||||
file.write('p%s -> p%s [' % (pid, mid))
|
||||
file.write('arrowhead=%s, arrowtail=%s, ' % (arrowheadstyle, arrowtailstyle))
|
||||
if adoptionsdashed and mrel != _("Birth"):
|
||||
file.write('style=dashed')
|
||||
else:
|
||||
file.write('style=solid')
|
||||
file.write('];\n')
|
||||
# Link to the parents' nodes directly.
|
||||
if father and person_dict.has_key(father):
|
||||
fid = string.replace(father.getId(),'-','_')
|
||||
file.write('p%s -> p%s [' % (pid, fid))
|
||||
file.write('arrowhead=%s, arrowtail=%s, ' %
|
||||
(arrowheadstyle, arrowtailstyle))
|
||||
if adoptionsdashed and fadopted:
|
||||
file.write('style=dashed')
|
||||
else:
|
||||
file.write('style=solid')
|
||||
file.write('];\n')
|
||||
if mother and person_dict.has_key(mother):
|
||||
mid = string.replace(mother.getId(),'-','_')
|
||||
file.write('p%s -> p%s [' % (pid, mid))
|
||||
file.write('arrowhead=%s, arrowtail=%s, ' %
|
||||
(arrowheadstyle, arrowtailstyle))
|
||||
if adoptionsdashed and madopted:
|
||||
file.write('style=dashed')
|
||||
else:
|
||||
file.write('style=solid')
|
||||
file.write('];\n')
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
#
|
||||
#
|
||||
#
|
||||
#
|
||||
#------------------------------------------------------------------------
|
||||
def dump_index(person_list,file,includedates,includeurl,colorize):
|
||||
def dump_index(person_list,file,includedates,includeurl,colorize,
|
||||
arrowheadstyle,arrowtailstyle,show_families):
|
||||
# The list of families for which we have output the node, so we
|
||||
# don't do it twice.
|
||||
families_done = []
|
||||
for person in person_list:
|
||||
# Output the person's node.
|
||||
label = person.getPrimaryName().getName()
|
||||
id = string.replace(person.getId(),'-','_')
|
||||
if includedates:
|
||||
@@ -364,10 +408,25 @@ def dump_index(person_list,file,includedates,includeurl,colorize):
|
||||
else:
|
||||
file.write('color=black, ')
|
||||
file.write('fontname="Arial", label="%s"];\n' % label)
|
||||
# Output families's nodes.
|
||||
if show_families:
|
||||
family_list = person.getFamilyList()
|
||||
for fam in family_list:
|
||||
fid = string.replace(fam.getId(),'-','_')
|
||||
if fam not in families_done:
|
||||
file.write('f%s [shape=circle, label="", ' % fid)
|
||||
file.write('weight=8, height=.3];\n')
|
||||
# Link this person to all his/her families.
|
||||
file.write('f%s -> p%s [' % (fid, id))
|
||||
file.write('arrowhead=%s, arrowtail=%s, ' %
|
||||
(arrowheadstyle, arrowtailstyle))
|
||||
file.write('style=solid];\n')
|
||||
|
||||
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
#
|
||||
#
|
||||
#
|
||||
#
|
||||
#------------------------------------------------------------------------
|
||||
def get_description():
|
||||
|
||||
@@ -38,7 +38,6 @@ import time
|
||||
#-------------------------------------------------------------------------
|
||||
import gtk
|
||||
import gtk.glade
|
||||
import gnome.ui
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
@@ -46,9 +45,12 @@ import gnome.ui
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from RelLib import *
|
||||
import Julian
|
||||
import FrenchRepublic
|
||||
import Hebrew
|
||||
|
||||
import Date
|
||||
from ansel_utf8 import ansel_to_utf8
|
||||
|
||||
import latin_utf8
|
||||
import Utils
|
||||
from GedcomInfo import *
|
||||
@@ -1569,11 +1571,11 @@ class GedcomParser:
|
||||
pass
|
||||
|
||||
if cal1 == "FRENCH R":
|
||||
dateobj.set_calendar(Date.FRENCH)
|
||||
dateobj.set_calendar(FrenchRepublic.FrenchRepublic)
|
||||
elif cal1 == "JULIAN":
|
||||
dateobj.set_calendar(Date.JULIAN)
|
||||
dateobj.set_calendar(Julian.Julian)
|
||||
elif cal1 == "HEBREW":
|
||||
dateobj.set_calendar(Date.HEBREW)
|
||||
dateobj.set_calendar(Hebrew.Hebrew)
|
||||
dateobj.get_start_date().set(data1)
|
||||
dateobj.get_stop_date().set(data2)
|
||||
dateobj.set_range(1)
|
||||
@@ -1583,11 +1585,11 @@ class GedcomParser:
|
||||
if match:
|
||||
(abt,cal,data) = match.groups()
|
||||
if cal == "FRENCH R":
|
||||
dateobj.set_calendar(Date.FRENCH)
|
||||
dateobj.set_calendar(FrenchRepublic.FrenchRepublic)
|
||||
elif cal == "JULIAN":
|
||||
dateobj.set_calendar(Date.JULIAN)
|
||||
dateobj.set_calendar(Julian.Julian)
|
||||
elif cal == "HEBREW":
|
||||
dateobj.set_calendar(Date.HEBREW)
|
||||
dateobj.set_calendar(Hebrew.Hebrew)
|
||||
dateobj.set(data)
|
||||
if abt:
|
||||
dateobj.get_start_date().setMode(abt)
|
||||
@@ -1615,7 +1617,6 @@ class GedcomParser:
|
||||
|
||||
def resolve_refns(self):
|
||||
prefix = self.db.iprefix
|
||||
renamed = []
|
||||
index = 0
|
||||
new_pmax = self.db.pmapIndex
|
||||
pmap = self.db.getPersonMap()
|
||||
|
||||
@@ -50,6 +50,10 @@ import const
|
||||
import Utils
|
||||
import Date
|
||||
import Calendar
|
||||
import Julian
|
||||
import Hebrew
|
||||
import FrenchRepublic
|
||||
|
||||
from intl import gettext as _
|
||||
from latin_utf8 import latin_to_utf8
|
||||
from GedcomInfo import *
|
||||
@@ -66,7 +70,7 @@ except:
|
||||
#-------------------------------------------------------------------------
|
||||
|
||||
_hmonth = [
|
||||
"", "ELUL", "TSH", "CSH", "KSL", "TVT", "SHV", "ADR",
|
||||
|
||||
"ADS", "NSN", "IYR", "SVN", "TMZ", "AAV", "ELL" ]
|
||||
|
||||
_fmonth = [
|
||||
@@ -78,9 +82,9 @@ _month = [
|
||||
"JUL", "AUG", "SEP", "OCT", "NOV", "DEC" ]
|
||||
|
||||
_calmap = {
|
||||
Calendar.Hebrew : (_hmonth, '@#HEBREW@'),
|
||||
Calendar.FrenchRepublic : (_fmonth, '@#FRENCH R@'),
|
||||
Calendar.Julian : (_month, '@#JULIAN@'),
|
||||
Hebrew.Hebrew.NAME : (_hmonth, '@#HEBREW@'),
|
||||
FrenchRepublic.FrenchRepublic.NAME : (_fmonth, '@#FRENCH R@'),
|
||||
Julian.Julian.NAME : (_month, '@#JULIAN@'),
|
||||
}
|
||||
|
||||
_caldef = {
|
||||
@@ -201,14 +205,8 @@ def make_date(subdate):
|
||||
mon_valid = subdate.getMonthValid()
|
||||
year_valid = subdate.getYearValid()
|
||||
|
||||
# Adjust `mon' so it can be used as index in our _Xmonth arrays.
|
||||
if mon_valid:
|
||||
mon += 1
|
||||
else:
|
||||
mon = 0
|
||||
|
||||
if _calmap.has_key(subdate.calendar):
|
||||
(mmap,prefix) = _calmap[subdate.calendar]
|
||||
if _calmap.has_key(subdate.calendar.NAME):
|
||||
(mmap,prefix) = _calmap[subdate.calendar.NAME]
|
||||
else:
|
||||
mmap = _month
|
||||
prefix = ""
|
||||
@@ -780,7 +778,7 @@ class GedcomWriter:
|
||||
text = addr_append(text,addr.getPostal())
|
||||
text = addr_append(text,addr.getCountry())
|
||||
if text:
|
||||
self.g.write("2 PLAC %s\n" % string.replace(self.cnvtxt(text)),'\r',' ')
|
||||
self.g.write("2 PLAC %s\n" % string.replace(self.cnvtxt(text),'\r',' '))
|
||||
if addr.getNote():
|
||||
self.write_long_text("NOTE",3,self.cnvtxt(addr.getNote()))
|
||||
for srcref in addr.getSourceRefList():
|
||||
|
||||
Reference in New Issue
Block a user