Commit abe53192 authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki Committed by Arnaud Fontaine

py2/py3: long does not exist in Python 3.

parent 2de4acee
......@@ -27,6 +27,10 @@ from mimetools import choose_boundary
from Products.CMFCore.utils import _setCacheHeaders, _ViewEmulator
from DateTime import DateTime
import re
import six
if six.PY3:
long = int
class BigFile(File):
"""
......
......@@ -49,6 +49,9 @@ from Testing import ZopeTestCase
from zLOG import LOG
from six.moves import range
if six.PY3:
long = int
def format_stack(thread=None):
frame_dict = sys._current_frames()
if thread is not None:
......
# export_only : allow to disable the uid column and the id of columns
import six
result = ''
request = context.REQUEST
......@@ -9,7 +10,7 @@ listboxline_list = context.get_value('default', render_format='list', REQUEST=re
def encode(value):
if isinstance(value, bool):
return '"%s"' % value
if isinstance(value, (int, long, float)):
if isinstance(value, six.integer_types + (float,)):
return str(value)
else:
if isinstance(value, str):
......
......@@ -238,7 +238,7 @@
error python: value[2]"
class="DataA" align="left"
tal:attributes="class python: error and (css + 'Error') or css;
align python: isinstance(original_value, (float, int, long)) and 'right' or 'left'">
align python: isinstance(original_value, modules['six'].integer_types + (float,)) and 'right' or 'left'">
<input tal:condition="not: repeat/value/index"
type="hidden" value="1" name="listbox_uid:list"
tal:attributes="value python: line.getUid() or '';
......@@ -268,7 +268,7 @@
<tal:block tal:repeat="value here/getStatValueList">
<td class="Data" align="left"
tal:define="original_value python: value[0]; processed_value python: value[1]"
tal:attributes="align python: isinstance(original_value, (float, int, long)) and 'right' or 'left'"
tal:attributes="align python: isinstance(original_value, modules['six'].integer_types + (float,)) and 'right' or 'left'"
tal:content="structure processed_value" />
</tal:block>
</tr>
......
......@@ -63,6 +63,7 @@ from Products.ERP5Type.Message import Message
from collections import OrderedDict
from Products.ERP5Form.Selection import Selection
from Products.PythonScripts.standard import Object
import six
MARKER = Object()
......@@ -83,7 +84,7 @@ def toBasicTypes(obj):
"""Ensure that obj contains only basic types."""
if obj is None:
return obj
if isinstance(obj, (bool, int, float, long, str, unicode)):
if isinstance(obj, (bool, float, str) + six.integer_types + six.text_type):
return obj
if isinstance(obj, list):
return [toBasicTypes(x) for x in obj]
......
......@@ -273,9 +273,9 @@
</span>
<span style="color: green;">&nbsp;:&nbsp;</span>
<tal:block tal:condition="show_search_line">
<span tal:condition="python: isinstance(original_value,(float, int, long))"
<span tal:condition="python: isinstance(original_value, modules['six'].integer_types + (float,))"
id="data_short" tal:content="python: original_value" />
<span tal:condition="python: not isinstance(original_value,(float, int, long))"
<span tal:condition="python: not isinstance(original_value, modules['six'].integer_types + (float,))"
id="data_short" tal:content="data_short" />
</tal:block>
<tal:block tal:condition="not:show_search_line">
......@@ -302,7 +302,7 @@
<tal:block tal:condition="python: original_value is not None">
<span align="right"
tal:define="original_value python: valueZ[0]; processed_value python: valueZ[1]"
tal:attributes="align python: isinstance(original_value, (float, int, long)) and 'right' or 'left'"
tal:attributes="align python: isinstance(original_value, modules['six'].integer_types + (float,)) and 'right' or 'left'"
tal:content="structure processed_value" />
</tal:block>
</div>
......
......@@ -100,7 +100,7 @@
-->
<tal:block metal:define-macro="cell_value">
<tal:block tal:define="is_list python:same_type(value, []) or same_type(value, ());
is_float python: isinstance(value, (int, long, float));">
is_float python: isinstance(value, modules['six'].integer_types + (float,));">
<tal:block tal:condition="python: is_list">
......@@ -116,7 +116,7 @@
</tal:block>
<tal:block tal:condition="python: value is not None and not is_list">
<tal:block tal:condition="is_float">
<tal:block tal:condition="python: isinstance(value, (int, long))">
<tal:block tal:condition="python: isinstance(value, modules['six'].integer_types)">
<table:table-cell tal:define="field python: editable_fields.get(column_id, None)"
tal:attributes="office:value value;
table:style-name string:${style_prefix}figure"
......
......@@ -3,6 +3,7 @@ import datetime
import time
import json
from DateTime import DateTime
import six
response = container.REQUEST.RESPONSE
start = time.time()
......@@ -32,7 +33,7 @@ for line in results.tuples():
v = v.isoformat()
elif isinstance(v, Decimal):
v = float(v)
elif isinstance(v, (long, int, float)) and not isSafeInteger(v):
elif isinstance(v, six.integer_types + (float,)) and not isSafeInteger(v):
# if numbers are too large to be handled by javascript, we simply return them
# as string, this will still not work for pivot table, but at least the spreadsheet
# will not display truncated values.
......
......@@ -40,6 +40,10 @@ from lxml import etree
from zLOG import LOG, ERROR, INFO
from erp5.component.tool.WebServiceTool import ConnectionError
from Products.ERP5Type.Cache import CachingMethod
import six
if six.PY3:
long = int
ID_SEPARATOR="-"
......
......@@ -330,7 +330,7 @@
error python: value[2]"
class="DataA" align="left"
tal:attributes="class python: error and (css + 'Error') or css;
align python: isinstance(original_value, (float, int, long)) and 'right' or 'left'">
align python: isinstance(original_value, modules['six'].integer_types + (float,)) and 'right' or 'left'">
<input tal:condition="not: repeat/value/index"
type="hidden" value="1" name="listbox_uid:list"
tal:attributes="value python: line.getUid() or '';
......@@ -348,7 +348,7 @@
<tal:block tal:repeat="value here/getStatValueList">
<td class="Data" align="left"
tal:define="original_value python: value[0]; processed_value python: value[1]"
tal:attributes="align python: isinstance(original_value, (float, int, long)) and 'right' or 'left'"
tal:attributes="align python: isinstance(original_value, modules['six'].integer_types + (float,)) and 'right' or 'left'"
tal:content="structure processed_value" />
</tal:block>
</tr>
......
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