2008-01-16 Benny Malengier <benny.malengier@gramps-project.org>

* src/GrampsDbUtils/_GrampsDbWriteXML.py: import gzip only once



svn: r9838
This commit is contained in:
Benny Malengier 2008-01-16 08:49:43 +00:00
parent 0ba34220a1
commit 00c4692b28
2 changed files with 19 additions and 15 deletions

View File

@ -1,3 +1,6 @@
2008-01-16 Benny Malengier <benny.malengier@gramps-project.org>
* src/GrampsDbUtils/_GrampsDbWriteXML.py: import gzip only once
2008-01-16 Peter Landgren <peter.talken@telia.com>
* man/Makefile.am: Swedish added (sv).
* man/sv/gramps.1.in: Added Swedish man page (sv).

View File

@ -54,13 +54,19 @@ 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 GrampsDbWriteFailure
#from gen.utils.longop import LongOpStatus
#-------------------------------------------------------------------------
#
# Attempt to load the GZIP library. Some version of python do not seem
# to be compiled with this available.
#
#-------------------------------------------------------------------------
try:
import gzip
_gzip_ok = 1
except:
_gzip_ok = 0
_xml_version = "1.2.0"
@ -103,10 +109,7 @@ class GrampsDbXmlWriter(UpdateCallback):
"""
UpdateCallback.__init__(self, callback)
self.compress = compress
if self.compress:
try:
import gzip
except:
if not _gzip_ok:
self.compress = False
self.db = db
self.strip_photos = strip_photos
@ -141,8 +144,7 @@ class GrampsDbXmlWriter(UpdateCallback):
self.fileroot = os.path.dirname(filename)
try:
if self.compress:
import gzip
if self.compress and _gzip_ok:
try:
g = gzip.open(filename,"wb")
except:
@ -166,8 +168,7 @@ class GrampsDbXmlWriter(UpdateCallback):
Write the database to the specified file handle.
"""
if self.compress:
import gzip
if self.compress and _gzip_ok:
try:
g = gzip.GzipFile(mode="wb",fileobj=handle)
except: