* src/const.py.in: eliminate zipcmd

* src/docgen/OpenSpreadSheet.py: eliminate the need for ZIP, use python
zipfile module instead
* src/plugins/EventCmp.py (DisplayChart.on_save_clicked): fix rows, double lines
no longer used
* configure.in: add check for vfs bindings, eliminate the check for
swig and zip
* gramps.spec.in (Requires): Added gnome-python2-gnomevfs dependency


svn: r2577
This commit is contained in:
Don Allingham 2004-01-01 19:10:23 +00:00
parent cbfa7161ad
commit 8e9f6a4219
5 changed files with 96 additions and 32 deletions

View File

@ -45,8 +45,6 @@ pkgpythondir=\${prefix}/share/\${PACKAGE}
pkgpyexecdir=\${prefix}/share/\${PACKAGE} pkgpyexecdir=\${prefix}/share/\${PACKAGE}
AC_PATH_PROG(BINSH, sh) AC_PATH_PROG(BINSH, sh)
AC_PATH_PROG(SWIG, swig)
AC_PATH_PROG(ZIP, zip) AC_PATH_PROG(ZIP, zip)
AC_PROG_CC AC_PROG_CC
@ -159,6 +157,28 @@ then
fi fi
AC_MSG_RESULT(ok) AC_MSG_RESULT(ok)
AC_MSG_CHECKING(Python bindings for GNOME VFS)
cat > conftest.py <<EOF
$pygtk_require
try:
# Do not import gnome.canvas, this can raise a RuntimeError if the
# display cannot be opened. Just search it.
import imp
imp.find_module('gnome/vfs')
out("YES")
except ImportError:
out("NO")
EOF
$PYTHON conftest.py
has_vfs=`cat conftest.out`
rm -f conftest.out conftest.py
if test YES != "$has_vfs"
then
AC_MSG_ERROR([
**** The python bindings for GNOME canvas (gnome-python2-canvas) could not be found.])
fi
AC_MSG_RESULT(ok)
AC_MSG_CHECKING(Python bindin for glade) AC_MSG_CHECKING(Python bindin for glade)
cat > conftest.py <<EOF cat > conftest.py <<EOF
$pygtk_require $pygtk_require

View File

@ -22,6 +22,7 @@ Requires: python >= 2.2
Requires: gnome-python2 >= 1.99 Requires: gnome-python2 >= 1.99
Requires: gnome-python2-gconf >= 1.99 Requires: gnome-python2-gconf >= 1.99
Requires: gnome-python2-canvas >= 1.99 Requires: gnome-python2-canvas >= 1.99
Requires: gnome-python2-gnomevfs >= 1.99
Requires: pygtk2 >= 1.99 Requires: pygtk2 >= 1.99
Requires: pygtk2-libglade >= 1.99 Requires: pygtk2-libglade >= 1.99

View File

@ -40,7 +40,6 @@ from gettext import gettext as _
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
editor = "gimp" editor = "gimp"
zipcmd = "zip -r -q"
convert = "convert" convert = "convert"
pixdir = "/usr/share/pixmaps" pixdir = "/usr/share/pixmaps"

View File

@ -18,16 +18,32 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
# #
#-------------------------------------------------------------------------
#
# Standard Python Modules
#
#-------------------------------------------------------------------------
import os import os
import tempfile import tempfile
import string import string
import zipfile
#-------------------------------------------------------------------------
#
# Gramps modules
#
#-------------------------------------------------------------------------
import BaseDoc import BaseDoc
from SpreadSheetDoc import * from SpreadSheetDoc import *
from latin_utf8 import latin_to_utf8 from latin_utf8 import latin_to_utf8
import const import const
#-------------------------------------------------------------------------
#
# OpenSpreadSheet
#
#-------------------------------------------------------------------------
class OpenSpreadSheet(SpreadSheetDoc): class OpenSpreadSheet(SpreadSheetDoc):
def __init__(self,type,orientation): def __init__(self,type,orientation):
@ -48,13 +64,16 @@ class OpenSpreadSheet(SpreadSheetDoc):
self.filename = filename + ".sxc" self.filename = filename + ".sxc"
else: else:
self.filename = filename self.filename = filename
self.tempdir = tempfile.TemporaryFile() try:
os.mkdir(self.tempdir,0700) self.content_xml = tempfile.mktemp()
os.mkdir(self.tempdir + os.sep + "Pictures") self.f = open(self.content_xml,"wb")
os.mkdir(self.tempdir + os.sep + "META-INF") except IOError,msg:
raise Errors.ReportError(_("Could not create %s") % self.content_xml, msg)
self.f = open(self.tempdir + os.sep + "content.xml","w") except:
raise Errors.ReportError(_("Could not create %s") % self.content_xml)
self.f = open(self.content_xml,"w")
self.f.write('<?xml version="1.0" encoding="UTF-8"?>\n') self.f.write('<?xml version="1.0" encoding="UTF-8"?>\n')
self.f.write('<office:document-content ') self.f.write('<office:document-content ')
self.f.write('xmlns:office="http://openoffice.org/2000/office" ') self.f.write('xmlns:office="http://openoffice.org/2000/office" ')
@ -182,25 +201,31 @@ class OpenSpreadSheet(SpreadSheetDoc):
def _write_zip(self): def _write_zip(self):
if os.path.isfile(self.filename): file = zipfile.ZipFile(self.filename,"w",zipfile.ZIP_DEFLATED)
os.unlink(self.filename) file.write(self.manifest_xml,str("META-INF/manifest.xml"))
file.write(self.content_xml,str("content.xml"))
file.write(self.meta_xml,str("meta.xml"))
file.write(self.styles_xml,str("styles.xml"))
file.close()
os.system("cd " + self.tempdir + "; " + const.zipcmd + " " \ os.unlink(self.manifest_xml)
+ self.filename + " .") os.unlink(self.content_xml)
os.unlink(self.meta_xml)
os.unlink(self.tempdir + os.sep + "META-INF" + os.sep + "manifest.xml") os.unlink(self.styles_xml)
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)
os.rmdir(self.tempdir + os.sep + "Pictures")
os.rmdir(self.tempdir + os.sep + "META-INF")
os.rmdir(self.tempdir)
def _write_styles_file(self): def _write_styles_file(self):
file = self.tempdir + os.sep + "styles.xml" self.styles_xml = tempfile.mktemp()
self.f = open(file,"w")
try:
self.f = open(self.styles_xml,"wb")
except IOError,msg:
errmsg = "%s\n%s" % (_("Could not create %s") % self.styles_xml, msg)
raise Errors.ReportError(errmsg)
except:
pass
raise Errors.ReportError(_("Could not create %s") % self.styles_xml)
self.f = open(self.styles_xml,"w")
self.f.write('<?xml version="1.0" encoding="UTF-8"?>\n') self.f.write('<?xml version="1.0" encoding="UTF-8"?>\n')
self.f.write('<office:document-styles ') self.f.write('<office:document-styles ')
self.f.write('xmlns:office="http://openoffice.org/2000/office" ') self.f.write('xmlns:office="http://openoffice.org/2000/office" ')
@ -364,8 +389,18 @@ class OpenSpreadSheet(SpreadSheetDoc):
self.f.write(latin_to_utf8(text)) self.f.write(latin_to_utf8(text))
def _write_manifest(self): def _write_manifest(self):
file = self.tempdir + os.sep + "META-INF" + os.sep + "manifest.xml" self.manifest_xml = tempfile.mktemp()
self.f = open(file,"w")
try:
self.f = open(self.manifest_xml,"wb")
except IOError,msg:
errmsg = "%s\n%s" % (_("Could not create %s") % self.manifest_xml, msg)
raise Errors.ReportError(errmsg)
except:
pass
raise Errors.ReportError(_("Could not create %s") % self.manifest_xml)
self.f = open(self.manifest_xml,"w")
self.f.write('<?xml version="1.0" encoding="UTF-8"?>\n') self.f.write('<?xml version="1.0" encoding="UTF-8"?>\n')
self.f.write('<manifest:manifest ') self.f.write('<manifest:manifest ')
self.f.write('xmlns:manifest="http://openoffice.org/2001/manifest">') self.f.write('xmlns:manifest="http://openoffice.org/2001/manifest">')
@ -386,9 +421,19 @@ class OpenSpreadSheet(SpreadSheetDoc):
self.f.close() self.f.close()
def _write_meta_file(self): def _write_meta_file(self):
file = self.tempdir + os.sep + "meta.xml" self.meta_xml = tempfile.mktemp()
try:
self.f = open(self.meta_xml,"wb")
except IOError,msg:
errmsg = "%s\n%s" % (_("Could not create %s") % self.meta_xml, msg)
raise Errors.ReportError(errmsg)
except:
pass
raise Errors.ReportError(_("Could not create %s") % self.meta_xml)
name = latin_to_utf8(self.name) name = latin_to_utf8(self.name)
self.f = open(file,"w") self.f = open(self.meta_xml,"w")
self.f.write('<?xml version="1.0" encoding="UTF-8"?>\n') self.f.write('<?xml version="1.0" encoding="UTF-8"?>\n')
self.f.write('<office:document-meta ') self.f.write('<office:document-meta ')
self.f.write('xmlns:office="http://openoffice.org/2000/office" ') self.f.write('xmlns:office="http://openoffice.org/2000/office" ')

View File

@ -333,11 +333,10 @@ class DisplayChart:
spreadsheet.write_table_head(self.event_titles) spreadsheet.write_table_head(self.event_titles)
index = 0 index = 0
for (top,bottom) in self.row_data: for top in self.row_data:
spreadsheet.set_row(index%2) spreadsheet.set_row(index%2)
index = index + 1 index = index + 1
spreadsheet.write_table_data(top) spreadsheet.write_table_data(top)
spreadsheet.write_table_data(bottom)
spreadsheet.finalize() spreadsheet.finalize()
Utils.destroy_passed_object(obj) Utils.destroy_passed_object(obj)