From da99d15fec3a316b5a4df0efbfec0fb9e3f9aa6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9rome=20Perrin?= <jerome@nexedi.com> Date: Tue, 2 Feb 2010 14:53:10 +0000 Subject: [PATCH] detect and report an error when multiple paths are defined, plus other minor style changes git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@32187 20353a03-c40f-0410-a6d1-a30d3c3de9de --- .../Base_getCategoriesSpreadSheetMapping.xml | 32 +++++++++++++------ product/ERP5/bootstrap/erp5_core/bt/revision | 2 +- 2 files changed, 23 insertions(+), 11 deletions(-) diff --git a/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_getCategoriesSpreadSheetMapping.xml b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_getCategoriesSpreadSheetMapping.xml index 309f77bf76..aa9d52ea33 100644 --- a/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_getCategoriesSpreadSheetMapping.xml +++ b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_getCategoriesSpreadSheetMapping.xml @@ -179,7 +179,7 @@ for table_name in spreadsheet_list.keys():\n elif column_id in (None, \'\'):\n # Are we in the middle of the path definition ?\n # If the path definition has started and not ended\n - if path_def_started and path_index != None:\n + if path_def_started and path_index is not None:\n property_map[column_index] = \'path_\' + str(path_index)\n path_index += 1\n # else : The path definition is not started or is finished, so ignore the column\n @@ -188,7 +188,7 @@ for table_name in spreadsheet_list.keys():\n # If there is a new column with a header and the path definition has\n # started, that seems the path definition has ended\n if \'path_0\' in property_map.values():\n - path_index == None\n + path_index == None # FIXME: useless statement, but what was the original intention ??\n property_map[column_index] = column_id.encode(\'utf8\')\n column_index += 1\n \n @@ -215,13 +215,22 @@ for table_name in spreadsheet_list.keys():\n continue\n \n # Prefetch line datas\n - cell_index = 0\n line_data = {}\n - for cell in line:\n + path_defined = []\n + for cell_index, cell in enumerate(line):\n # Get the property corresponding to the cell data\n property_id = property_map[cell_index]\n line_data[property_id] = cell\n - cell_index += 1\n + if cell and property_id.startswith(\'path_\'):\n + path_defined.append(cell)\n + if len(path_defined) > 1:\n + invalid_spreadsheet_error_handler(\n + translateString("More that one path is defined in ${table}"\n + " at line ${line}: ${path_defined}",\n + mapping=dict(path_defined=repr(path_defined),\n + table=table_name,\n + line=line_index)))\n +\n # Analyse every cell of the line\n category_property_list = {}\n cell_index = 0\n @@ -253,7 +262,7 @@ for table_name in spreadsheet_list.keys():\n else:\n path_element_id = cell_id\n # Initialize the list of path elements to the cell element\n - absolut_path_element_list = [path_element_id,]\n + absolute_path_element_list = [path_element_id,]\n # Get the depth of the current element\n element_depth = int(property_id[5:]) # 5 == len(\'path_\')\n # Get a path element for each depth level to reach the 0-level\n @@ -262,10 +271,10 @@ for table_name in spreadsheet_list.keys():\n for element in path_element_list[::-1]:\n if element[\'depth\'] == searched_depth:\n # Element found, add it to the list\n - absolut_path_element_list.append(element[\'value\'])\n + absolute_path_element_list.append(element[\'value\'])\n # Get the next depth\n break\n - path = \'/\'.join([base_category_id,] + absolut_path_element_list[::-1])\n + path = \'/\'.join([base_category_id,] + absolute_path_element_list[::-1])\n if same_type(path, u\'\'):\n path = path.encode(\'utf8\')\n category_property_list[\'path\'] = path\n @@ -420,16 +429,19 @@ else:\n <string>line_index</string> <string>line</string> <string>len</string> - <string>cell_index</string> <string>line_data</string> + <string>path_defined</string> + <string>enumerate</string> + <string>cell_index</string> <string>cell</string> <string>property_id</string> + <string>repr</string> <string>category_property_list</string> <string>cell_data</string> <string>cell_id</string> <string>alt_id_source</string> <string>path_element_id</string> - <string>absolut_path_element_list</string> + <string>absolute_path_element_list</string> <string>int</string> <string>element_depth</string> <string>range</string> diff --git a/product/ERP5/bootstrap/erp5_core/bt/revision b/product/ERP5/bootstrap/erp5_core/bt/revision index ce7224cd64..ac3f740c0f 100644 --- a/product/ERP5/bootstrap/erp5_core/bt/revision +++ b/product/ERP5/bootstrap/erp5_core/bt/revision @@ -1 +1 @@ -1455 \ No newline at end of file +1456 \ No newline at end of file -- 2.30.9