From b692b36c0a7e86078609e24124f16b8fe25e3723 Mon Sep 17 00:00:00 2001
From: Arnaud Fontaine <arnaud.fontaine@nexedi.com>
Date: Thu, 1 Mar 2012 17:56:54 +0900
Subject: [PATCH] Avoid formatting strings whenever relevant.

---
 product/ERP5/Document/BusinessTemplate.py              | 10 +++++-----
 ...usinessTemplate_migrateSourceCodeFromFilesystem.xml |  2 +-
 product/ERP5/bootstrap/erp5_core/bt/revision           |  2 +-
 product/ERP5/tests/testBusinessTemplate.py             |  5 ++---
 product/ERP5Type/dynamic/component_package.py          |  8 ++++----
 product/ERP5Type/dynamic/portal_type_class.py          | 10 +++++-----
 product/ERP5Type/tests/testDynamicClassGeneration.py   |  2 +-
 7 files changed, 19 insertions(+), 20 deletions(-)

diff --git a/product/ERP5/Document/BusinessTemplate.py b/product/ERP5/Document/BusinessTemplate.py
index 561226a65e..5dd55fb3bd 100644
--- a/product/ERP5/Document/BusinessTemplate.py
+++ b/product/ERP5/Document/BusinessTemplate.py
@@ -3743,7 +3743,7 @@ class PropertySheetTemplateItem(FilesystemToZodbTemplateItem):
     from App.config import getConfiguration
     return os.path.join(getConfiguration().instancehome,
                         "PropertySheet",
-                        "%s.py" % class_id)
+                        class_id + ".py")
 
   @staticmethod
   def _migrateFromFilesystem(tool,
@@ -3799,14 +3799,14 @@ class DocumentTemplateItem(FilesystemToZodbTemplateItem):
 
   @staticmethod
   def _getZodbObjectId(id):
-    return 'erp5.component.document.%s' % id
+    return 'erp5.component.document.' + id
 
   @staticmethod
   def _getFilesystemPath(class_id):
     from App.config import getConfiguration
     return os.path.join(getConfiguration().instancehome,
                         "Document",
-                        "%s.py" % class_id)
+                        class_id + ".py")
 
   def _importFile(self, file_name, file_obj):
     if file_name.endswith('.py'):
@@ -3820,7 +3820,7 @@ class DocumentTemplateItem(FilesystemToZodbTemplateItem):
 
       name = file_name[:-4]
       obj = self._objects[name]
-      with open("%s.py" % file_obj.name[:-4]) as f:
+      with open(file_obj.name[:-4] + ".py") as f:
         obj.text_content = f.read()
 
       # When importing a Business Template, there is no way to determine if it
@@ -3912,7 +3912,7 @@ class ExtensionTemplateItem(DocumentTemplateItem):
 
   @staticmethod
   def _getZodbObjectId(id):
-    return 'erp5.component.extension.%s' % id
+    return 'erp5.component.extension.' + id
 
   def getTemplateIdList(self):
     return self.getTemplateExtensionIdList()
diff --git a/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/BusinessTemplate_migrateSourceCodeFromFilesystem.xml b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/BusinessTemplate_migrateSourceCodeFromFilesystem.xml
index 3bcc6668e6..a74cef3d1b 100644
--- a/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/BusinessTemplate_migrateSourceCodeFromFilesystem.xml
+++ b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/BusinessTemplate_migrateSourceCodeFromFilesystem.xml
@@ -57,7 +57,7 @@ if failed_import_dict:\n
  for name, error in failed_import_dict.iteritems():\n
   failed_import_formatted_list.append("%s (%s)" % (name, error))\n
 \n
- message = "The following component could not be imported: %s" % \', \'.join(failed_import_formatted_list)\n
+ message = "The following component could not be imported: " + \', \'.join(failed_import_formatted_list)\n
 else:\n
  message = "All components were successfully imported from filesystem to ZODB."\n
 \n
diff --git a/product/ERP5/bootstrap/erp5_core/bt/revision b/product/ERP5/bootstrap/erp5_core/bt/revision
index c623c09cb1..0ada5f37a2 100644
--- a/product/ERP5/bootstrap/erp5_core/bt/revision
+++ b/product/ERP5/bootstrap/erp5_core/bt/revision
@@ -1 +1 @@
-41019
\ No newline at end of file
+41020
\ No newline at end of file
diff --git a/product/ERP5/tests/testBusinessTemplate.py b/product/ERP5/tests/testBusinessTemplate.py
index 728141ffc5..7ee72016e7 100644
--- a/product/ERP5/tests/testBusinessTemplate.py
+++ b/product/ERP5/tests/testBusinessTemplate.py
@@ -6890,7 +6890,7 @@ class TestDocumentTemplateItem(BusinessTemplateMixin):
     return super(TestDocumentTemplateItem, self).login(user_name, quiet)
 
   def stepCreateZodbDocument(self, sequence=None, **kw):
-    document_id = '%s.erp5.%s' % (self.component_module, self.document_title)
+    document_id = self.component_module + '.erp5.' + self.document_title
     self.getPortalObject().portal_components.newContent(
       id=document_id,
       version='erp5',
@@ -6933,8 +6933,7 @@ class TestDocumentTemplateItem(BusinessTemplateMixin):
 
     self.assertTrue(os.path.exists(component_bt_tool_path))
 
-    component_id = '%s.erp5.%s' % (self.component_module,
-                                   sequence['document_title'])
+    component_id = self.component_module + '.erp5.' + sequence['document_title']
     base_path = os.path.join(component_bt_tool_path, component_id)
 
     python_source_code_path = base_path + '.py'
diff --git a/product/ERP5Type/dynamic/component_package.py b/product/ERP5Type/dynamic/component_package.py
index c179e6c2ad..ddf0e248ba 100644
--- a/product/ERP5Type/dynamic/component_package.py
+++ b/product/ERP5Type/dynamic/component_package.py
@@ -161,7 +161,7 @@ class ComponentDynamicPackage(ModuleType):
     version += '_version'
     version_package = getattr(self, version, None)
     if version_package is None:
-      version_package_name = '%s.%s' % (self._namespace, version)
+      version_package_name = self._namespace + '.' + version
 
       version_package = ComponentVersionPackage(version_package_name)
       sys.modules[version_package_name] = version_package
@@ -225,7 +225,7 @@ class ComponentDynamicPackage(ModuleType):
 
         return module
 
-      component_id_alias = '%s.%s' % (self._namespace, component_name)
+      component_id_alias = self._namespace + '.' + component_name
 
     component_id = '%s.%s_version.%s' % (self._namespace, version,
                                          component_name)
@@ -240,7 +240,7 @@ class ComponentDynamicPackage(ModuleType):
         sys.modules[component_id_alias] = new_module
 
       # This must be set for imports at least (see PEP 302)
-      new_module.__file__ = "<%s>" % component_name
+      new_module.__file__ = '<' + component_name + '>'
 
       try:
         component.load(new_module.__dict__, validated_only=True)
@@ -282,7 +282,7 @@ class ComponentDynamicPackage(ModuleType):
       elif isinstance(module, ComponentVersionPackage):
         self.reset(sub_package=module)
 
-      module_name = "%s.%s" % (package.__name__, name)
+      module_name = package.__name__ + '.' + name
       LOG("ERP5Type.Tool.ComponentTool", BLATHER, "Resetting " + module_name)
 
       # The module must be deleted first from sys.modules to avoid imports in
diff --git a/product/ERP5Type/dynamic/portal_type_class.py b/product/ERP5Type/dynamic/portal_type_class.py
index c630d5c0d0..04ddf8bfde 100644
--- a/product/ERP5Type/dynamic/portal_type_class.py
+++ b/product/ERP5Type/dynamic/portal_type_class.py
@@ -54,7 +54,7 @@ def _importClass(classpath):
 
     return klass
   except StandardError:
-    raise ImportError('Could not import document class %s' % classpath)
+    raise ImportError('Could not import document class ' + classpath)
 
 # Loading Cache Factory portal type would generate the accessor holder
 # for Cache Factory, itself defined with Standard Property thus
@@ -179,8 +179,8 @@ def generatePortalTypeClass(site, portal_type_name):
     interface_list = []
 
   if type_class is None:
-    raise AttributeError('Document class is not defined on Portal Type %s' \
-            % portal_type_name)
+    raise AttributeError('Document class is not defined on Portal Type ' + \
+                           portal_type_name)
 
   klass = None
   if '.' in type_class:
@@ -194,7 +194,7 @@ def generatePortalTypeClass(site, portal_type_name):
     if not (type_class_namespace.startswith('Products.ERP5Type') or
             portal_type_name in core_portal_type_class_dict):
       try:
-        klass = getattr(__import__('erp5.component.document.%s' % type_class,
+        klass = getattr(__import__('erp5.component.document.' + type_class,
                                    fromlist=['erp5.component.document'],
                                    level=0),
                         type_class)
@@ -277,7 +277,7 @@ def loadTempPortalTypeClass(portal_type_name):
   import erp5.portal_type
   klass = getattr(erp5.portal_type, portal_type_name)
 
-  return type("Temporary %s" % portal_type_name,
+  return type("Temporary " + portal_type_name,
               (TemporaryDocumentMixin, klass), {})
 
 last_sync = -1
diff --git a/product/ERP5Type/tests/testDynamicClassGeneration.py b/product/ERP5Type/tests/testDynamicClassGeneration.py
index c88a6eb1c6..ee20ab9012 100644
--- a/product/ERP5Type/tests/testDynamicClassGeneration.py
+++ b/product/ERP5Type/tests/testDynamicClassGeneration.py
@@ -1265,7 +1265,7 @@ class _TestZodbComponent(SecurityTestCase):
     pass
 
   def _getComponentFullModuleName(self, module_name):
-    return "%s.%s" % (self._getComponentModuleName(), module_name)
+    return self._getComponentModuleName() + '.' + module_name
 
   def failIfModuleImportable(self, module_name):
     full_module_name = self._getComponentFullModuleName(module_name)
-- 
2.30.9