[Erp5-report] r39868 arnaud.fontaine - /erp5/trunk/products/ERP5/Document/BusinessTemplate.py

nobody at svn.erp5.org nobody at svn.erp5.org
Thu Nov 4 03:56:27 CET 2010


Author: arnaud.fontaine
Date: Thu Nov  4 03:56:24 2010
New Revision: 39868

URL: http://svn.erp5.org?rev=39868&view=rev
Log:
Move _initCreation to BusinessTemplateArchive to avoid code
duplication in its child classes


Modified:
    erp5/trunk/products/ERP5/Document/BusinessTemplate.py

Modified: erp5/trunk/products/ERP5/Document/BusinessTemplate.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/Document/BusinessTemplate.py?rev=39868&r1=39867&r2=39868&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/Document/BusinessTemplate.py [utf8] (original)
+++ erp5/trunk/products/ERP5/Document/BusinessTemplate.py [utf8] Thu Nov  4 03:56:24 2010
@@ -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(BusinessTem
   """
     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(BusinessTe
   """
 
   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)




More information about the Erp5-report mailing list