Commit f9a89090 authored by Nicolas Dumazet's avatar Nicolas Dumazet

use the builtin filter()


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@32822 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent b8a389e2
...@@ -350,24 +350,22 @@ class XMLMatrix(Folder): ...@@ -350,24 +350,22 @@ class XMLMatrix(Folder):
# Create an index for this base_id # Create an index for this base_id
self.index[base_id] = PersistentMapping() self.index[base_id] = PersistentMapping()
# First, delete all cells which are out of range.
size_list = map(len, kw)
if len_delta < 0:
size_list.extend([1] * (-len_delta))
removed_cell_id_list = []
cell_id_list = [] cell_id_list = []
for cell_id in self.getCellIdList(base_id = base_id): for cell_id in self.getCellIdList(base_id = base_id):
if self.get(cell_id) is not None: if self.get(cell_id) is not None:
cell_id_list.append(cell_id) cell_id_list.append(cell_id)
for cell_id in cell_id_list:
# First, delete all cells which are out of range.
size_list = map(len, kw)
if len_delta < 0:
size_list.extend([1] * (-len_delta))
def is_in_range(cell_id):
for i, index in enumerate(cell_id[len(base_id)+1:].split('_')): for i, index in enumerate(cell_id[len(base_id)+1:].split('_')):
if int(index) >= size_list[i]: if int(index) >= size_list[i]:
removed_cell_id_list.append(cell_id)
break
for cell_id in removed_cell_id_list:
self._delObject(cell_id) self._delObject(cell_id)
cell_id_list.remove(cell_id) return False
return True
cell_id_list = filter(is_in_range, cell_id_list)
# Secondly, rename coordinates. This does not change cell ids. # Secondly, rename coordinates. This does not change cell ids.
for i in range(max(new_len, current_len)): for i in range(max(new_len, current_len)):
......
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