export: create directory on demand

git-svn-id: svn://svn.cy55.de/Zope3/src/loops/trunk@3421 fd906abe-77d9-0310-91a1-e0d9ade77398
This commit is contained in:
helmutm 2009-06-14 08:41:34 +00:00
parent 813acf8c46
commit 17e4be5089

7
external/element.py vendored
View file

@ -1,5 +1,5 @@
#
# Copyright (c) 2008 Helmut Merz helmutm@cy55.de
# Copyright (c) 2009 Helmut Merz helmutm@cy55.de
#
# 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
@ -151,7 +151,10 @@ class ResourceElement(Element):
and isinstance(content, unicode)):
content = content.encode('UTF-8')
fileFlags = 'wt'
dataPath = os.path.join(extractor.resourceDirectory, self['name'])
directory = extractor.resourceDirectory
if not os.path.exists(directory):
os.makedirs(directory)
dataPath = os.path.join(directory, self['name'])
f = open(dataPath, fileFlags)
f.write(content)
f.close()