Improved documenatation generators, fixed GEDCOM note read problem
svn: r27
This commit is contained in:
parent
457ea855d6
commit
8c11e3ac09
@ -24,7 +24,6 @@ import string
|
||||
import re
|
||||
|
||||
from TextDoc import *
|
||||
from latin_utf8 import latin_to_utf8
|
||||
import const
|
||||
|
||||
_top = [
|
||||
|
@ -1,136 +0,0 @@
|
||||
#
|
||||
# Gramps - a GTK+/GNOME based genealogy program
|
||||
#
|
||||
# Copyright (C) 2000 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
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#
|
||||
|
||||
import os
|
||||
import re
|
||||
import time
|
||||
import tempfile
|
||||
import const
|
||||
|
||||
meta_creator = re.compile(r"""\s*<meta:initial-creator>""")
|
||||
dc_creator = re.compile(r"""\s*<dc:creator>""")
|
||||
meta_date = re.compile(r"""\s*<meta:creation-date>""")
|
||||
dc_date = re.compile(r"""\s*<dc:date>""")
|
||||
|
||||
class OpenOfficeCore:
|
||||
|
||||
def __init__(self,filename,template,ext,owner=""):
|
||||
self.template = template
|
||||
self.owner = owner
|
||||
if filename[-4:] != ext:
|
||||
self.filename = filename + ext
|
||||
else:
|
||||
self.filename = filename
|
||||
self.first = []
|
||||
self.last = []
|
||||
self.file = None
|
||||
self.image_list = []
|
||||
self.tempdir = ""
|
||||
|
||||
def setup(self):
|
||||
templateFile = open(self.template,"r")
|
||||
lines = templateFile.readlines()
|
||||
templateFile.close()
|
||||
|
||||
in_last = 0
|
||||
t = time.localtime(time.time())
|
||||
time_str="%04d-%02d-%02dT%02d:%02d:%02d" % \
|
||||
(t[0],t[1],t[2],t[3],t[4],t[5])
|
||||
for line in lines:
|
||||
if line[1:15] == "</office:body>":
|
||||
in_last = 1
|
||||
self.last.append(line);
|
||||
elif in_last == 0:
|
||||
if meta_creator.match(line):
|
||||
self.first.append("<meta:initial-creator>" + self.owner + \
|
||||
"</meta:initial-creator>")
|
||||
elif dc_creator.match(line):
|
||||
self.first.append("<dc:creator>" + self.owner + \
|
||||
"</dc:creator>")
|
||||
elif dc_date.match(line):
|
||||
self.first.append("<dc:date>" + time_str + \
|
||||
"</dc:date>")
|
||||
elif meta_date.match(line):
|
||||
self.first.append("<meta:creation-date>" + time_str + \
|
||||
"</meta:creation-date>")
|
||||
else:
|
||||
self.first.append(line)
|
||||
else:
|
||||
self.last.append(line);
|
||||
|
||||
tempfile.tempdir = "/tmp"
|
||||
self.tempdir = tempfile.mktemp()
|
||||
os.mkdir(self.tempdir,0700)
|
||||
os.mkdir(self.tempdir + os.sep + "Pictures")
|
||||
os.mkdir(self.tempdir + os.sep + "META-INF")
|
||||
self.file = open(self.tempdir + os.sep + "Content.xml","w")
|
||||
for line in self.first:
|
||||
self.file.write(line)
|
||||
return self.file
|
||||
|
||||
#--------------------------------------------------------------------
|
||||
#
|
||||
#
|
||||
#
|
||||
#--------------------------------------------------------------------
|
||||
def add_image(self,name):
|
||||
self.image_list.append(name)
|
||||
return self.tempdir + os.sep + "Pictures" + os.sep + name
|
||||
|
||||
#--------------------------------------------------------------------
|
||||
#
|
||||
#
|
||||
#
|
||||
#--------------------------------------------------------------------
|
||||
def end(self):
|
||||
import shutil
|
||||
|
||||
for line in self.last:
|
||||
self.file.write(line)
|
||||
|
||||
self.file.close()
|
||||
tmpname = tempfile.mktemp()
|
||||
|
||||
file = open(self.tempdir + os.sep + "META-INF" + os.sep + \
|
||||
"manifest.xml","w")
|
||||
file.write('<?xml version="1.0" encoding="UTF-8"?>\n')
|
||||
file.write('<manifest><file-entry media-type="" ')
|
||||
file.write('full-path="Pictures/"/>')
|
||||
for image in self.image_list:
|
||||
file.write('<file-entry media-type="" full-path="Pictures/')
|
||||
file.write(image + '"/>')
|
||||
file.write('<file-entry media-type="" full-path="Content.xml"/>')
|
||||
file.write('</manifest>\n')
|
||||
file.close()
|
||||
os.system("cd " + self.tempdir + "; " + const.zipcmd + " " \
|
||||
+ tmpname + " .")
|
||||
if os.path.isfile(self.filename):
|
||||
os.unlink(self.filename)
|
||||
shutil.copy(tmpname,self.filename)
|
||||
os.unlink(tmpname)
|
||||
os.unlink(self.tempdir + os.sep + "META-INF" + os.sep + "manifest.xml")
|
||||
os.unlink(self.tempdir + os.sep + "Content.xml")
|
||||
for image in self.image_list:
|
||||
os.unlink(self.tempdir + os.sep + "Pictures" + os.sep + image)
|
||||
os.rmdir(self.tempdir + os.sep + "Pictures")
|
||||
os.rmdir(self.tempdir + os.sep + "META-INF")
|
||||
os.rmdir(self.tempdir)
|
||||
|
||||
|
@ -26,6 +26,11 @@ from TextDoc import *
|
||||
from latin_utf8 import latin_to_utf8
|
||||
import const
|
||||
|
||||
try:
|
||||
from codecs import *
|
||||
except:
|
||||
def EncodedFile(a,b,c):
|
||||
return a
|
||||
|
||||
class OpenOfficeDoc(TextDoc):
|
||||
|
||||
@ -54,7 +59,9 @@ class OpenOfficeDoc(TextDoc):
|
||||
os.mkdir(self.tempdir + os.sep + "Pictures")
|
||||
os.mkdir(self.tempdir + os.sep + "META-INF")
|
||||
|
||||
self.f = open(self.tempdir + os.sep + "content.xml","w")
|
||||
fname = self.tempdir + os.sep + "content.xml"
|
||||
self.f = EncodedFile(open(fname,"wb"),'latin-1','utf-8')
|
||||
|
||||
self.f.write('<?xml version="1.0" encoding="UTF-8"?>\n')
|
||||
self.f.write('<office:document-content ')
|
||||
self.f.write('xmlns:office="http://openoffice.org/2000/office" ')
|
||||
@ -138,8 +145,34 @@ class OpenOfficeDoc(TextDoc):
|
||||
self._write_styles_file()
|
||||
self._write_manifest()
|
||||
self._write_meta_file()
|
||||
self._write_photos()
|
||||
self._write_zip()
|
||||
|
||||
def add_photo(self,name,x,y):
|
||||
import GdkImlib
|
||||
|
||||
image = GdkImlib.Image(name)
|
||||
scale = float(y)/float(image.rgb_height)
|
||||
act_width = int(image.rgb_width * scale)
|
||||
act_height = int(image.rgb_height * scale)
|
||||
|
||||
self.photo_list.append((name,act_width,act_height))
|
||||
|
||||
base = os.path.basename(name)
|
||||
tag = string.replace(base,'.','_')
|
||||
|
||||
self.f.write('<draw:image draw:style-name="photo" ')
|
||||
self.f.write('draw:name="')
|
||||
self.f.write(tag)
|
||||
self.f.write('" text:anchor-type="paragraph" ')
|
||||
self.f.write('svg:width="%.3fcm" ' % (float(act_width)/72.0))
|
||||
self.f.write('svg:height="%.3fcm" ' % (float(act_height)/72.0))
|
||||
self.f.write('draw:z-index="0" ')
|
||||
self.f.write('xlink:href="#Pictures/')
|
||||
self.f.write(base)
|
||||
self.f.write('" xlink:type="simple" xlink:show="embed" ')
|
||||
self.f.write('xlink:actuate="onLoad"/>\n')
|
||||
|
||||
def start_table(self,name,style_name):
|
||||
self.f.write('<table:table table:name="')
|
||||
self.f.write(name)
|
||||
@ -185,15 +218,18 @@ class OpenOfficeDoc(TextDoc):
|
||||
os.unlink(self.tempdir + os.sep + "content.xml")
|
||||
os.unlink(self.tempdir + os.sep + "meta.xml")
|
||||
os.unlink(self.tempdir + os.sep + "styles.xml")
|
||||
# for image in self.image_list:
|
||||
# os.unlink(self.tempdir + os.sep + "Pictures" + os.sep + image)
|
||||
for image in self.photo_list:
|
||||
base = os.path.basename(image[0])
|
||||
os.unlink(self.tempdir + os.sep + "Pictures" + os.sep + base)
|
||||
os.rmdir(self.tempdir + os.sep + "Pictures")
|
||||
os.rmdir(self.tempdir + os.sep + "META-INF")
|
||||
os.rmdir(self.tempdir)
|
||||
|
||||
def _write_styles_file(self):
|
||||
file = self.tempdir + os.sep + "styles.xml"
|
||||
self.f = open(file,"w")
|
||||
|
||||
self.f = EncodedFile(open(file,"wb"),'latin-1','utf-8')
|
||||
|
||||
self.f.write('<?xml version="1.0" encoding="UTF-8"?>\n')
|
||||
self.f.write('<office:document-styles ')
|
||||
self.f.write('xmlns:office="http://openoffice.org/2000/office" ')
|
||||
@ -230,6 +266,13 @@ class OpenOfficeDoc(TextDoc):
|
||||
self.f.write('</style:default-style>\n')
|
||||
self.f.write('<style:style style:name="Standard" ')
|
||||
self.f.write('style:family="paragraph" style:class="text"/>\n')
|
||||
self.f.write('<style:style style:name="photo" style:family="graphics">\n')
|
||||
self.f.write('<style:properties text:anchor-type="paragraph" ')
|
||||
self.f.write('svg:x="0cm" svg:y="0cm" style:wrap="none" ')
|
||||
self.f.write('style:vertical-pos="top" style:vertical-rel="paragraph" ')
|
||||
self.f.write('style:horizontal-pos="center" style:horizontal-rel="paragraph"/>\n')
|
||||
self.f.write('</style:style>\n')
|
||||
|
||||
for key in self.style_list.keys():
|
||||
style = self.style_list[key]
|
||||
self.f.write('<style:style style:name="' + key + '" ')
|
||||
@ -342,15 +385,33 @@ class OpenOfficeDoc(TextDoc):
|
||||
text = string.replace(text,'\n','<text:line-break/>')
|
||||
self.f.write(latin_to_utf8(text))
|
||||
|
||||
def _write_photos(self):
|
||||
|
||||
for file_tuple in self.photo_list:
|
||||
file = file_tuple[0]
|
||||
width = file_tuple[1]
|
||||
height = file_tuple[2]
|
||||
base = os.path.basename(file)
|
||||
image_name = self.tempdir + os.sep + "Pictures" + os.sep + base
|
||||
cmd = "%s -size %dx%d %s %s" % (const.convert,width,height,file,image_name)
|
||||
os.system(cmd)
|
||||
|
||||
def _write_manifest(self):
|
||||
file = self.tempdir + os.sep + "META-INF" + os.sep + "manifest.xml"
|
||||
self.f = open(file,"w")
|
||||
self.f = EncodedFile(open(file,"wb"),'latin-1','utf-8')
|
||||
self.f.write('<?xml version="1.0" encoding="UTF-8"?>\n')
|
||||
self.f.write('<manifest:manifest ')
|
||||
self.f.write('xmlns:manifest="http://openoffice.org/2001/manifest">')
|
||||
self.f.write('<manifest:file-entry ')
|
||||
self.f.write('manifest:media-type="application/vnd.sun.xml.writer" ')
|
||||
self.f.write('manifest:full-path="/"/>')
|
||||
for image in self.photo_list:
|
||||
i = image[0]
|
||||
base = os.path.basename(i)
|
||||
self.f.write('<manifest:file-entry manifest:media-type="" ')
|
||||
self.f.write('manifest:full-path="Pictures/')
|
||||
self.f.write(base)
|
||||
self.f.write('"/>')
|
||||
self.f.write('<manifest:file-entry manifest:media-type="" ')
|
||||
self.f.write('manifest:full-path="Pictures/"/>')
|
||||
self.f.write('<manifest:file-entry manifest:media-type="text/xml" ')
|
||||
@ -359,15 +420,13 @@ class OpenOfficeDoc(TextDoc):
|
||||
self.f.write('manifest:full-path="styles.xml"/>')
|
||||
self.f.write('<manifest:file-entry manifest:media-type="text/xml" ')
|
||||
self.f.write('manifest:full-path="meta.xml"/>')
|
||||
#self.f.write('<manifest:file-entry manifest:media-type="text/xml" ')
|
||||
#self.f.write('manifest:full-path="settings.xml"/>')
|
||||
self.f.write('</manifest:manifest>\n')
|
||||
self.f.close()
|
||||
|
||||
def _write_meta_file(self):
|
||||
file = self.tempdir + os.sep + "meta.xml"
|
||||
name = latin_to_utf8(self.name)
|
||||
self.f = open(file,"w")
|
||||
self.f = EncodedFile(open(file,"wb"),'latin-1','utf-8')
|
||||
self.f.write('<?xml version="1.0" encoding="UTF-8"?>\n')
|
||||
self.f.write('<office:document-meta ')
|
||||
self.f.write('xmlns:office="http://openoffice.org/2000/office" ')
|
||||
|
@ -21,9 +21,6 @@
|
||||
FONT_SANS_SERIF = 0
|
||||
FONT_SERIF = 1
|
||||
|
||||
PAPER_US_LETTER = 0
|
||||
PAPER_A4 = 1
|
||||
|
||||
PAPER_PORTRAIT = 0
|
||||
PAPER_LANDSCAPE = 1
|
||||
|
||||
@ -144,13 +141,6 @@ class TableStyle:
|
||||
self.width = 0
|
||||
self.columns = 0
|
||||
self.colwid = [ 0 ] * 10
|
||||
# self.cells = {}
|
||||
|
||||
# def add_cell_style(self,name,style):
|
||||
# self.cells[name] = style
|
||||
|
||||
# def get_cell_styles(self,name,style):
|
||||
# return self.cells
|
||||
|
||||
def set_width(self,width):
|
||||
self.width = width
|
||||
@ -240,6 +230,7 @@ class ParagraphStyle:
|
||||
self.right_border = p.right_border
|
||||
self.left_border = p.left_border
|
||||
self.pad = p.pad
|
||||
self.bgcolor = p.bgcolor
|
||||
else:
|
||||
self.font = FontStyle()
|
||||
self.rmargin = 0
|
||||
@ -252,8 +243,7 @@ class ParagraphStyle:
|
||||
self.right_border = 0
|
||||
self.left_border = 0
|
||||
self.pad = 0
|
||||
|
||||
self.actfont = self.font
|
||||
self.bgcolor = (255,255,255)
|
||||
|
||||
def set_header_level(self,level):
|
||||
self.level = level
|
||||
@ -288,6 +278,12 @@ class ParagraphStyle:
|
||||
def set_left_border(self,val):
|
||||
self.left_border = val
|
||||
|
||||
def get_background_color(self):
|
||||
return self.bgcolor
|
||||
|
||||
def set_background_color(self,color):
|
||||
self.bgcolor = color
|
||||
|
||||
def get_left_border(self):
|
||||
return self.left_border
|
||||
|
||||
@ -347,12 +343,15 @@ class TextDoc:
|
||||
self.rmargin = 2.54
|
||||
|
||||
self.font = FontStyle()
|
||||
self.actfont = self.font
|
||||
self.style_list = {}
|
||||
self.table_styles = {}
|
||||
self.cell_styles = {}
|
||||
self.name = ""
|
||||
self.photo_list = []
|
||||
|
||||
def add_photo(self,name,x,y):
|
||||
pass
|
||||
|
||||
def get_usable_width(self):
|
||||
return self.width - (self.rmargin + self.lmargin)
|
||||
|
||||
@ -371,18 +370,6 @@ class TextDoc:
|
||||
def add_cell_style(self,name,style):
|
||||
self.cell_styles[name] = TableCellStyle(style)
|
||||
|
||||
def change_font(self,font):
|
||||
self.actfont = FontStyle(font)
|
||||
|
||||
def restore_font(self):
|
||||
self.actfont = self.font
|
||||
|
||||
def get_default_font(self):
|
||||
return self.font
|
||||
|
||||
def get_active_font(self):
|
||||
return self.actfont
|
||||
|
||||
def open(self,filename):
|
||||
pass
|
||||
|
||||
|
@ -197,8 +197,10 @@ def exportData(database, filename, callback):
|
||||
|
||||
g.write("<people")
|
||||
person = database.getDefaultPerson()
|
||||
print person
|
||||
if person:
|
||||
g.write(" default=\"" + str(person.getId()) + "\"")
|
||||
print str(person.getId())
|
||||
g.write(">\n")
|
||||
|
||||
total = len(personList) + len(familyList)
|
||||
|
@ -7,4 +7,4 @@ echo "Working on python files"
|
||||
./get_strings *.py >> glade.c
|
||||
echo "Building template.po"
|
||||
xgettext -C -s -a -o template.po glade.c
|
||||
rm glade.c
|
||||
#rm glade.c
|
||||
|
@ -30,7 +30,6 @@ import re
|
||||
import sort
|
||||
import utils
|
||||
import string
|
||||
import OpenOffice
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
#
|
||||
@ -49,6 +48,9 @@ from libglade import *
|
||||
import ListColors
|
||||
import Filter
|
||||
import const
|
||||
from TextDoc import *
|
||||
from OpenSpreadSheet import *
|
||||
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
#
|
||||
@ -68,43 +70,43 @@ FILTER = "x"
|
||||
#
|
||||
#------------------------------------------------------------------------
|
||||
class TableReport:
|
||||
def __init__(self,filename):
|
||||
|
||||
def __init__(self,filename,doc):
|
||||
self.filename = filename
|
||||
|
||||
def initialize(self):
|
||||
pass
|
||||
|
||||
def finalize(self):
|
||||
pass
|
||||
|
||||
def write_table_head():
|
||||
pass
|
||||
|
||||
def set_row(self,val):
|
||||
pass
|
||||
|
||||
def write_table_data():
|
||||
pass
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
#
|
||||
#
|
||||
#
|
||||
#------------------------------------------------------------------------
|
||||
class OpenOfficeTable(TableReport):
|
||||
|
||||
#--------------------------------------------------------------------
|
||||
#
|
||||
#
|
||||
#
|
||||
#--------------------------------------------------------------------
|
||||
def initialize(self):
|
||||
templateFile = const.dataDir + os.sep + "table.sxc"
|
||||
self.doc = doc
|
||||
|
||||
self.open_office = OpenOffice.OpenOfficeCore(self.filename,\
|
||||
templateFile,".sxc")
|
||||
self.file = self.open_office.setup()
|
||||
self.file.write('<table:table table:name="Sheet1" table:style-name="ta1">\n')
|
||||
#--------------------------------------------------------------------
|
||||
#
|
||||
#
|
||||
#
|
||||
#--------------------------------------------------------------------
|
||||
def initialize(self,cols):
|
||||
|
||||
t = TableStyle()
|
||||
t.set_columns(cols)
|
||||
for index in range(0,cols):
|
||||
t.set_column_width(index,4)
|
||||
self.doc.add_table_style("mytbl",t)
|
||||
|
||||
f = FontStyle()
|
||||
f.set_type_face(FONT_SANS_SERIF)
|
||||
f.set_size(12)
|
||||
f.set_bold(1)
|
||||
p = ParagraphStyle()
|
||||
p.set_font(f)
|
||||
p.set_background_color((0xcc,0xff,0xff))
|
||||
p.set_padding(0.1)
|
||||
self.doc.add_style("head",p)
|
||||
|
||||
f = FontStyle()
|
||||
f.set_type_face(FONT_SANS_SERIF)
|
||||
f.set_size(10)
|
||||
p = ParagraphStyle()
|
||||
p.set_font(f)
|
||||
self.doc.add_style("data",p)
|
||||
|
||||
self.doc.open(self.filename)
|
||||
self.doc.start_page("Page 1","mytbl")
|
||||
|
||||
#--------------------------------------------------------------------
|
||||
#
|
||||
@ -112,8 +114,8 @@ class OpenOfficeTable(TableReport):
|
||||
#
|
||||
#--------------------------------------------------------------------
|
||||
def finalize(self):
|
||||
self.file.write('</table:table>\n')
|
||||
self.open_office.end()
|
||||
self.doc.end_page()
|
||||
self.doc.close()
|
||||
|
||||
#--------------------------------------------------------------------
|
||||
#
|
||||
@ -122,14 +124,13 @@ class OpenOfficeTable(TableReport):
|
||||
#--------------------------------------------------------------------
|
||||
def write_table_data(self,data):
|
||||
length = len(data)
|
||||
|
||||
self.file.write('<table:table-row table:style-name="ro1">\n')
|
||||
|
||||
self.doc.start_row()
|
||||
for item in data:
|
||||
self.file.write('<table:table-cell table:style-name="ce' + str(self.row))
|
||||
self.file.write('" table:value-type="string">\n')
|
||||
self.file.write('<text:p>' + item + '</text:p>\n')
|
||||
self.file.write('</table:table-cell>\n')
|
||||
self.file.write('</table:table-row>\n')
|
||||
self.doc.start_cell("data")
|
||||
self.doc.write_text(item)
|
||||
self.doc.end_cell()
|
||||
self.doc.end_row()
|
||||
|
||||
#--------------------------------------------------------------------
|
||||
#
|
||||
@ -147,105 +148,13 @@ class OpenOfficeTable(TableReport):
|
||||
def write_table_head(self,data):
|
||||
length = len(data)
|
||||
self.prev = 3
|
||||
self.file.write('<table:table-column table:style-name="co1" ')
|
||||
self.file.write('table:number-columns-repeated="' + str(length+1) + '"/>\n')
|
||||
self.file.write('<table:table-row table:style-name="ro1">\n')
|
||||
|
||||
self.doc.start_row()
|
||||
for item in data:
|
||||
self.file.write('<table:table-cell table:style-name="ce1" ')
|
||||
self.file.write('table:value-type="string">\n')
|
||||
self.file.write('<text:p>' + item + '</text:p>\n')
|
||||
self.file.write('</table:table-cell>\n')
|
||||
self.file.write('</table:table-row>\n')
|
||||
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
#
|
||||
#
|
||||
#
|
||||
#------------------------------------------------------------------------
|
||||
class HtmlTable(TableReport):
|
||||
|
||||
#--------------------------------------------------------------------
|
||||
#
|
||||
#
|
||||
#
|
||||
#--------------------------------------------------------------------
|
||||
def __init__(self,file,template):
|
||||
self.template = template
|
||||
TableReport.__init__(self,file)
|
||||
|
||||
#--------------------------------------------------------------------
|
||||
#
|
||||
#
|
||||
#
|
||||
#--------------------------------------------------------------------
|
||||
def initialize(self):
|
||||
if self.template == "":
|
||||
self.template = const.dataDir + os.sep + "table.html"
|
||||
|
||||
templateFile = open(self.template,"r")
|
||||
lines = templateFile.readlines()
|
||||
templateFile.close()
|
||||
|
||||
self.last = []
|
||||
self.first = []
|
||||
in_last = 0
|
||||
for line in lines:
|
||||
if line[0:14] == "<!-- START -->":
|
||||
in_last = 1
|
||||
self.last.append(line);
|
||||
elif in_last == 0:
|
||||
self.first.append(line)
|
||||
else:
|
||||
self.last.append(line);
|
||||
|
||||
self.file = open(self.filename,"w")
|
||||
for line in self.first:
|
||||
self.file.write(line)
|
||||
|
||||
#--------------------------------------------------------------------
|
||||
#
|
||||
#
|
||||
#
|
||||
#--------------------------------------------------------------------
|
||||
def finalize(self):
|
||||
|
||||
self.file.write("</table>")
|
||||
for line in self.last:
|
||||
self.file.write(line)
|
||||
self.file.close()
|
||||
|
||||
#--------------------------------------------------------------------
|
||||
#
|
||||
#
|
||||
#
|
||||
#--------------------------------------------------------------------
|
||||
def write_table_data(self,data):
|
||||
length = len(data)
|
||||
|
||||
self.file.write('<tr>\n')
|
||||
for item in data:
|
||||
self.file.write('<td>\n')
|
||||
if item == "":
|
||||
self.file.write(' ')
|
||||
else:
|
||||
self.file.write(fix(item))
|
||||
self.file.write('\n</td>\n')
|
||||
self.file.write('</tr>\n')
|
||||
|
||||
#--------------------------------------------------------------------
|
||||
#
|
||||
#
|
||||
#
|
||||
#--------------------------------------------------------------------
|
||||
def write_table_head(self,data):
|
||||
self.file.write('<table cellspacing=1 cellpadding=1 border=1>\n')
|
||||
self.file.write('<tr>\n')
|
||||
for item in data:
|
||||
self.file.write('<th>\n')
|
||||
self.file.write(fix(item))
|
||||
self.file.write('\n</th>\n')
|
||||
self.file.write('</tr>\n')
|
||||
self.doc.start_cell("head")
|
||||
self.doc.write_text(item)
|
||||
self.doc.end_cell()
|
||||
self.doc.end_row()
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
#
|
||||
@ -450,17 +359,14 @@ class EventComparison:
|
||||
for item in unsort_list:
|
||||
sort_list.append(item[1])
|
||||
|
||||
event_titles = ["Person","Birth","Death"] + sort_list
|
||||
|
||||
name = self.form.get_widget("filename").get_text()
|
||||
|
||||
if self.form.get_widget("openoffice").get_active():
|
||||
spreadsheet = OpenOfficeTable(name)
|
||||
elif self.form.get_widget("html").get_active():
|
||||
template = self.form.get_widget("htmlfile").get_text()
|
||||
spreadsheet = HtmlTable(name,template)
|
||||
doc = OpenSpreadSheet(PaperStyle("junk",10,10),PAPER_PORTRAIT)
|
||||
spreadsheet = TableReport(name,doc)
|
||||
spreadsheet.initialize(len(event_titles))
|
||||
|
||||
spreadsheet.initialize()
|
||||
|
||||
event_titles = ["Person","Birth","Death"] + sort_list
|
||||
|
||||
spreadsheet.write_table_head(event_titles)
|
||||
|
||||
|
@ -81,6 +81,7 @@ class IndivSummary:
|
||||
font.set_type_face(FONT_SANS_SERIF)
|
||||
font.set_size(16)
|
||||
p = ParagraphStyle()
|
||||
p.set_alignment(PARA_ALIGN_CENTER)
|
||||
p.set_font(font)
|
||||
self.d.add_style("Title",p)
|
||||
|
||||
@ -132,64 +133,6 @@ class IndivSummary:
|
||||
def end(self):
|
||||
self.d.close()
|
||||
|
||||
#--------------------------------------------------------------------
|
||||
#
|
||||
#
|
||||
#
|
||||
#--------------------------------------------------------------------
|
||||
def write_header(self):
|
||||
pass
|
||||
|
||||
#--------------------------------------------------------------------
|
||||
#
|
||||
#
|
||||
#
|
||||
#--------------------------------------------------------------------
|
||||
def write_spouse(self,person):
|
||||
if person:
|
||||
name = person.getPrimaryName().getRegularName()
|
||||
else:
|
||||
name = "unknown"
|
||||
self.file.write('<table:table-row>\n')
|
||||
self.file.write('<table:table-cell ')
|
||||
self.file.write('table:number-columns-spanned="2" ')
|
||||
self.file.write('table:value-type=\"string\">\n')
|
||||
self.file.write('<text:p text:style-name="P2">')
|
||||
self.file.write(name)
|
||||
self.file.write('</text:p>\n')
|
||||
self.file.write("</table:table-cell>\n")
|
||||
self.file.write("<table:covered-table-cell/>\n")
|
||||
self.file.write("</table:table-row>\n")
|
||||
|
||||
#--------------------------------------------------------------------
|
||||
#
|
||||
#
|
||||
#
|
||||
#--------------------------------------------------------------------
|
||||
def write_general(self):
|
||||
|
||||
self.file.write('<table:table table:name="Table1" table:style-name="Table1">\n')
|
||||
self.file.write('<table:table-column table:style-name="Table1.A"/>\n')
|
||||
self.file.write('<table:table-column table:style-name="Table1.B"/>\n')
|
||||
|
||||
name = self.person.getPrimaryName().getRegularName()
|
||||
self.write_simple_row("Name:",name)
|
||||
if self.person.getGender() == RelLib.Person.male:
|
||||
self.write_simple_row("Gender:","Male")
|
||||
else:
|
||||
self.write_simple_row("Gender:","Female")
|
||||
family = self.person.getMainFamily()
|
||||
if family:
|
||||
father = family.getFather().getPrimaryName().getRegularName()
|
||||
mother = family.getMother().getPrimaryName().getRegularName()
|
||||
else:
|
||||
father = ""
|
||||
mother = ""
|
||||
self.write_simple_row("Father:",father)
|
||||
self.write_simple_row("Mother:",mother)
|
||||
|
||||
self.file.write('</table:table>\n')
|
||||
|
||||
#--------------------------------------------------------------------
|
||||
#
|
||||
#
|
||||
@ -227,29 +170,6 @@ class IndivSummary:
|
||||
self.d.end_cell()
|
||||
self.d.end_row()
|
||||
|
||||
|
||||
#--------------------------------------------------------------------
|
||||
#
|
||||
#
|
||||
#
|
||||
#--------------------------------------------------------------------
|
||||
def write_facts(self):
|
||||
|
||||
self.file.write('<text:p text:style-name="Standard"/>')
|
||||
self.file.write('<table:table table:name="Table2" table:style-name="Table1">\n')
|
||||
self.file.write('<table:table-column table:style-name="Table1.A"/>\n')
|
||||
self.file.write('<table:table-column table:style-name="Table1.B"/>\n')
|
||||
|
||||
self.write_header_row("Individual Facts")
|
||||
event_list = [ self.person.getBirth(), self.person.getDeath() ]
|
||||
event_list = event_list + self.person.getEventList()
|
||||
|
||||
for event in event_list:
|
||||
self.write_fact(event)
|
||||
|
||||
self.file.write('</table:table>\n')
|
||||
|
||||
|
||||
#--------------------------------------------------------------------
|
||||
#
|
||||
#
|
||||
@ -316,24 +236,7 @@ class IndivSummary:
|
||||
#
|
||||
#--------------------------------------------------------------------
|
||||
def write_report(self):
|
||||
# photo_list = self.person.getPhotoList()
|
||||
# if len(photo_list) > 0:
|
||||
# import GdkImlib
|
||||
# file = photo_list[0].getPath()
|
||||
# image = GdkImlib.Image(file)
|
||||
# height = image.rgb_height
|
||||
# scale = float(height)/150.0
|
||||
# width = int(image.rgb_width * scale)
|
||||
# height = int(height * scale)
|
||||
# base = os.path.basename(file)
|
||||
# image_name = self.open_office.add_image(base)
|
||||
# cmd = const.convert + " -size " + str(width) + "x150 "\
|
||||
# + file + " " + image_name
|
||||
# os.system(cmd)
|
||||
# self.scale = float(height)/float(width)
|
||||
# self.image = base
|
||||
# else:
|
||||
# self.image = ""
|
||||
photo_list = self.person.getPhotoList()
|
||||
|
||||
self.d.start_paragraph("Title")
|
||||
self.d.write_text('Summary of ')
|
||||
@ -342,6 +245,13 @@ class IndivSummary:
|
||||
|
||||
self.d.start_paragraph("Normal")
|
||||
self.d.end_paragraph()
|
||||
|
||||
if len(photo_list) > 0:
|
||||
file = photo_list[0].getPath()
|
||||
self.d.start_paragraph("Normal")
|
||||
self.d.add_photo(file,300,300)
|
||||
self.d.end_paragraph()
|
||||
|
||||
self.d.start_table("one","IndTable")
|
||||
|
||||
self.d.start_row()
|
||||
|
@ -165,8 +165,8 @@ def importData(database, filename):
|
||||
total = len(allLines)
|
||||
|
||||
value = 0
|
||||
for index in range(1,21):
|
||||
value = value + total/20
|
||||
for index in range(1,51):
|
||||
value = value + total/50
|
||||
values[index] = value
|
||||
|
||||
index = 1
|
||||
@ -179,9 +179,9 @@ def importData(database, filename):
|
||||
elif encoding == 2:
|
||||
line = latin_utf8.utf8_to_latin(line)
|
||||
|
||||
if currentLine == value and index <= 20:
|
||||
if currentLine == value and index <= 50:
|
||||
index = index + 1
|
||||
if index <= 20:
|
||||
if index <= 50:
|
||||
value = values[index]
|
||||
progressWindow.set_percentage(float(currentLine)/float(total))
|
||||
while events_pending():
|
||||
@ -402,6 +402,13 @@ def importData(database, filename):
|
||||
inlocalNote = 0
|
||||
person.setNote(user2note[noteId])
|
||||
|
||||
regex_match = noterefRegexp.match(line)
|
||||
if regex_match :
|
||||
matches = regex_match.groups()
|
||||
print "found note",matches[0]
|
||||
person2note[person] = matches[0]
|
||||
continue
|
||||
|
||||
regex_match = noteactRegexp.match(line)
|
||||
if regex_match :
|
||||
inlocalNote = 1
|
||||
@ -429,12 +436,6 @@ def importData(database, filename):
|
||||
mySource.setPage(matches[0])
|
||||
continue
|
||||
|
||||
regex_match = noterefRegexp.match(line)
|
||||
if regex_match :
|
||||
matches = regex_match.groups()
|
||||
person2note[person] = matches[0]
|
||||
continue
|
||||
|
||||
regex_match = genderRegexp.match(line)
|
||||
if regex_match :
|
||||
matches = regex_match.groups()
|
||||
@ -645,11 +646,10 @@ def on_ok_clicked(obj):
|
||||
statusWindow.destroy()
|
||||
except IOError, val:
|
||||
GnomeErrorDialog("Could not load " + name + "\n" + val[1])
|
||||
except:
|
||||
GnomeErrorDialog("Could not load " + name + \
|
||||
"\n due to an unexpected internal error")
|
||||
statusWindow.destroy()
|
||||
# except:
|
||||
# GnomeErrorDialog("Could not load " + name + \
|
||||
# "\n due to an unexpected internal error")
|
||||
# statusWindow.destroy()
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
|
@ -71,6 +71,7 @@
|
||||
<last_modification_time>Wed, 07 Mar 2001 04:12:28 GMT</last_modification_time>
|
||||
</signal>
|
||||
<stock_button>GNOME_STOCK_BUTTON_APPLY</stock_button>
|
||||
<relief>GTK_RELIEF_NORMAL</relief>
|
||||
</widget>
|
||||
|
||||
<widget>
|
||||
@ -85,6 +86,7 @@
|
||||
<last_modification_time>Tue, 06 Mar 2001 23:40:27 GMT</last_modification_time>
|
||||
</signal>
|
||||
<stock_button>GNOME_STOCK_BUTTON_CANCEL</stock_button>
|
||||
<relief>GTK_RELIEF_NORMAL</relief>
|
||||
</widget>
|
||||
|
||||
<widget>
|
||||
@ -93,6 +95,7 @@
|
||||
<can_default>True</can_default>
|
||||
<can_focus>True</can_focus>
|
||||
<stock_button>GNOME_STOCK_BUTTON_HELP</stock_button>
|
||||
<relief>GTK_RELIEF_NORMAL</relief>
|
||||
</widget>
|
||||
</widget>
|
||||
</widget>
|
||||
@ -344,6 +347,7 @@
|
||||
<last_modification_time>Wed, 07 Mar 2001 02:55:00 GMT</last_modification_time>
|
||||
</signal>
|
||||
<label>Add</label>
|
||||
<relief>GTK_RELIEF_NORMAL</relief>
|
||||
</widget>
|
||||
|
||||
<widget>
|
||||
@ -358,6 +362,7 @@
|
||||
<last_modification_time>Wed, 07 Mar 2001 02:55:12 GMT</last_modification_time>
|
||||
</signal>
|
||||
<label>Delete</label>
|
||||
<relief>GTK_RELIEF_NORMAL</relief>
|
||||
</widget>
|
||||
|
||||
<widget>
|
||||
@ -366,6 +371,7 @@
|
||||
<can_default>True</can_default>
|
||||
<can_focus>True</can_focus>
|
||||
<label>Load</label>
|
||||
<relief>GTK_RELIEF_NORMAL</relief>
|
||||
</widget>
|
||||
|
||||
<widget>
|
||||
@ -380,6 +386,7 @@
|
||||
<last_modification_time>Sun, 18 Mar 2001 13:52:32 GMT</last_modification_time>
|
||||
</signal>
|
||||
<label>Save</label>
|
||||
<relief>GTK_RELIEF_NORMAL</relief>
|
||||
</widget>
|
||||
</widget>
|
||||
</widget>
|
||||
@ -436,6 +443,7 @@
|
||||
<can_default>True</can_default>
|
||||
<can_focus>True</can_focus>
|
||||
<label>Do Nothing</label>
|
||||
<relief>GTK_RELIEF_NORMAL</relief>
|
||||
</widget>
|
||||
|
||||
<widget>
|
||||
@ -450,6 +458,7 @@
|
||||
<last_modification_time>Thu, 15 Mar 2001 20:53:45 GMT</last_modification_time>
|
||||
</signal>
|
||||
<label>Save As...</label>
|
||||
<relief>GTK_RELIEF_NORMAL</relief>
|
||||
</widget>
|
||||
|
||||
<widget>
|
||||
@ -464,6 +473,7 @@
|
||||
<last_modification_time>Thu, 08 Mar 2001 16:10:16 GMT</last_modification_time>
|
||||
</signal>
|
||||
<stock_button>GNOME_STOCK_BUTTON_CLOSE</stock_button>
|
||||
<relief>GTK_RELIEF_NORMAL</relief>
|
||||
</widget>
|
||||
</widget>
|
||||
|
||||
@ -693,6 +703,7 @@
|
||||
<widget>
|
||||
<class>GtkRadioButton</class>
|
||||
<name>html</name>
|
||||
<visible>False</visible>
|
||||
<can_focus>True</can_focus>
|
||||
<signal>
|
||||
<name>toggled</name>
|
||||
@ -729,6 +740,7 @@
|
||||
<widget>
|
||||
<class>GtkLabel</class>
|
||||
<name>label11</name>
|
||||
<visible>False</visible>
|
||||
<label>Template : </label>
|
||||
<justify>GTK_JUSTIFY_CENTER</justify>
|
||||
<wrap>False</wrap>
|
||||
@ -746,6 +758,7 @@
|
||||
<widget>
|
||||
<class>GnomeFileEntry</class>
|
||||
<name>htmltemplate</name>
|
||||
<visible>False</visible>
|
||||
<sensitive>False</sensitive>
|
||||
<history_id>HtmlTemplate</history_id>
|
||||
<max_saved>10</max_saved>
|
||||
|
Loading…
Reference in New Issue
Block a user