Commit 6190d1f1 authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki

code simplification.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@34172 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 6e38a93a
......@@ -564,7 +564,7 @@ class Document(PermanentURLMixIn, XMLObject, UrlMixIn, CachedConvertableMixin, S
if method is not None:
if callable(method):
val = method()
if isinstance(val, list) or isinstance(val, tuple):
if isinstance(val, (list, tuple)):
return list(val)
return [str(val)]
val = self.getPropertyList(property)
......
......@@ -1062,7 +1062,7 @@ class SimulationTool(BaseTool):
if metric_type is None:
# use the default metric type
metric_type = quantity_unit.split("/", 1)[0]
elif isinstance(quantity_unit, int) or isinstance(quantity_unit, float):
elif isinstance(quantity_unit, (int, float)):
# quantity_unit used to be a numerical parameter..
raise ValueError('Numeric values for quantity_unit are not supported')
......
......@@ -44,7 +44,7 @@ def calcPythonObjectMemorySize(i):
if isinstance(i, dict):
for k, v in i.items():
s += calcPythonObjectMemorySize(k) + calcPythonObjectMemorySize(v)
elif isinstance(i, list) or isinstance(i, tuple):
elif isinstance(i, (list, tuple)):
for v in i:
s += calcPythonObjectMemorySize(v)
return s
......
......@@ -179,7 +179,7 @@ class FolderMixIn(ExtensionClass.Base):
error_message = 'deleteContent only accepts string or list of strings not '
if isinstance(id, str):
self._delObject(id)
elif isinstance(id, list) or isinstance(id, tuple):
elif isinstance(id, (list, tuple)):
for my_id in id:
if isinstance(my_id, str):
self._delObject(my_id)
......
......@@ -60,7 +60,7 @@ if BaseMailTemplate is not None:
if value is not None:
values[key]=value
# turn some sequences in coma-seperated strings
if isinstance(value,tuple) or isinstance(value,list):
if isinstance(value, (tuple, list)):
value = ', '.join(value)
# make sure we have no unicode headers
if isinstance(value,unicode):
......
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