no processing if file does not exist (yet), thus avoiding erroneous value for documentPropertiesAccessible attribute

This commit is contained in:
Helmut Merz 2014-04-14 19:05:40 +02:00
parent a47b6a02a0
commit 6a91788d9e

View file

@ -89,11 +89,15 @@ class OfficeFile(ExternalFileAdapter):
def docPropertyDom(self):
fn = self.docFilename
result = dict(core=[], custom=[])
if not os.path.exists(fn):
# may happen before file has been created
return result
root, ext = os.path.splitext(fn)
if not ext.lower() in self.fileExtensions:
return result
try:
zf = ZipFile(fn, 'r')
self.documentPropertiesAccessible = True
except (IOError, BadZipfile), e:
from logging import getLogger
self.logger.warn(e)