[Erp5-report] r39865 arnaud.fontaine - /erp5/trunk/products/ERP5/Document/BusinessTemplate.py
nobody at svn.erp5.org
nobody at svn.erp5.org
Thu Nov 4 03:47:20 CET 2010
Author: arnaud.fontaine
Date: Thu Nov 4 03:47:18 2010
New Revision: 39865
URL: http://svn.erp5.org?rev=39865&view=rev
Log:
Move addObject to BusinessTemplateArchive to avoid code duplication in
its children 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=39865&r1=39864&r2=39865&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/Document/BusinessTemplate.py [utf8] (original)
+++ erp5/trunk/products/ERP5/Document/BusinessTemplate.py [utf8] Thu Nov 4 03:47:18 2010
@@ -321,8 +321,24 @@ class BusinessTemplateArchive:
def addFolder(self, **kw):
pass
- def addObject(self, *kw):
- pass
+ def addObject(self, obj, name, path=None, ext='.xml'):
+ name = name.replace('\\', '/')
+ name = quote(name)
+ name = os.path.normpath(name)
+ if path is None:
+ object_path = os.path.join(self.path, name)
+ else:
+ if '%' not in path:
+ tail, path = os.path.splitdrive(path)
+ path = path.replace('\\', '/')
+ path = tail + quote(path)
+ path = os.path.normpath(path)
+ object_path = os.path.join(path, name)
+ f = open(object_path+ext, 'wb')
+ try:
+ f.write(str(obj))
+ finally:
+ f.close()
def finishCreation(self, name=None, **kw):
pass
@@ -348,25 +364,6 @@ class BusinessTemplateFolder(BusinessTem
os.makedirs(path)
return path
- def addObject(self, obj, name, path=None, ext='.xml'):
- name = name.replace('\\', '/')
- name = quote(name)
- name = os.path.normpath(name)
- if path is None:
- object_path = os.path.join(self.path, name)
- else:
- if '%' not in path:
- tail, path = os.path.splitdrive(path)
- path = path.replace('\\', '/')
- path = tail + quote(path)
- path = os.path.normpath(path)
- object_path = os.path.join(path, name)
- f = open(object_path+ext, 'wb')
- try:
- f.write(str(obj))
- finally:
- f.close()
-
def _initImport(self, file=None, path=None, **kw):
# Normalize the paths to eliminate the effect of double-slashes.
root_path_len = len(os.path.normpath(path)) + len(os.sep)
@@ -429,25 +426,6 @@ class BusinessTemplateTarball(BusinessTe
if not os.path.exists(name):
os.makedirs(name)
- def addObject(self, obj, name, path=None, ext='.xml'):
- name = name.replace('\\', '/')
- name = quote(name)
- name = os.path.normpath(name)
- if path is None:
- object_path = os.path.join(self.path, name)
- else:
- if '%' not in path:
- tail, path = os.path.splitdrive(path)
- path = path.replace('\\', '/')
- path = tail + quote(path)
- path = os.path.normpath(path)
- object_path = os.path.join(path, name)
- f = open(object_path+ext, 'wb')
- try:
- f.write(str(obj))
- finally:
- f.close()
-
def finishCreation(self, name):
self.tar.add(name)
self.tar.close()
More information about the Erp5-report
mailing list