Commit 71bcb000 authored by Arnaud Fontaine's avatar Arnaud Fontaine

Move _initCreation to BusinessTemplateArchive to avoid code

duplication in its child classes



git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@39868 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent aba82601
......@@ -311,6 +311,14 @@ class BusinessTemplateArchive:
"""
This is the base class for all Business Template archives
"""
def _initCreation(self, path):
self.path = path
try:
os.makedirs(self.path)
except OSError:
# folder already exists, remove it
shutil.rmtree(self.path)
os.makedirs(self.path)
def __init__(self, creation=0, importing=0, file=None, path=None, **kw):
if creation:
......@@ -347,15 +355,6 @@ class BusinessTemplateFolder(BusinessTemplateArchive):
"""
Class archiving business template into a folder tree
"""
def _initCreation(self, path):
self.path = path
try:
os.makedirs(self.path)
except OSError:
# folder already exists, remove it
shutil.rmtree(self.path)
os.makedirs(self.path)
def addFolder(self, name=''):
if name != '':
name = os.path.normpath(name)
......@@ -409,14 +408,9 @@ class BusinessTemplateTarball(BusinessTemplateArchive):
"""
def _initCreation(self, path):
BusinessTemplateArchive._initCreation(self, path)
# make tmp dir, must use stringIO instead
self.path = path
try:
os.makedirs(self.path)
except OSError:
# folder already exists, remove it
shutil.rmtree(self.path)
os.makedirs(self.path)
# init tarfile obj
self.fobj = StringIO()
self.tar = tarfile.open('', 'w:gz', self.fobj)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment