Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
138
Merge Requests
138
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
nexedi
erp5
Commits
741eddb9
Commit
741eddb9
authored
Mar 16, 2023
by
Kazuhiko Shiozaki
Committed by
Jérome Perrin
Aug 21, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert "py2/py3: define OrderableList that uses legacy cmp for ordering."
This reverts commit
d4ab7bb5
.
parent
e77604f8
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
2 additions
and
35 deletions
+2
-35
product/ERP5Type/Utils.py
product/ERP5Type/Utils.py
+1
-24
product/ERP5Type/tests/testERP5Type.py
product/ERP5Type/tests/testERP5Type.py
+1
-11
No files found.
product/ERP5Type/Utils.py
View file @
741eddb9
...
@@ -144,26 +144,6 @@ else:
...
@@ -144,26 +144,6 @@ else:
# Generic sort method
# Generic sort method
#####################################################
#####################################################
class
OrderableList
(
object
):
def
__init__
(
self
,
*
args
):
self
.
__slots__
=
args
def
__lt__
(
self
,
other
):
for
i
,
v
in
enumerate
(
self
.
__slots__
):
try
:
other_v
=
other
.
__slots__
[
i
]
except
IndexError
:
return
False
c
=
cmp
(
v
,
other_v
)
if
c
==
-
1
:
return
True
elif
c
==
1
:
return
False
return
True
def
__repr__
(
self
):
return
repr
(
self
.
__slots__
)
sort_kw_cache
=
{}
sort_kw_cache
=
{}
def
sortValueList
(
value_list
,
sort_on
=
None
,
sort_order
=
None
,
**
kw
):
def
sortValueList
(
value_list
,
sort_on
=
None
,
sort_order
=
None
,
**
kw
):
...
@@ -221,10 +201,7 @@ def sortValueList(value_list, sort_on=None, sort_order=None, **kw):
...
@@ -221,10 +201,7 @@ def sortValueList(value_list, sort_on=None, sort_order=None, **kw):
except
TypeError
:
except
TypeError
:
pass
pass
value_list
.
append
(
x
)
value_list
.
append
(
x
)
if
six
.
PY2
:
return
value_list
return
value_list
else
:
return
OrderableList
(
*
value_list
)
sort_kw
=
{
'key'
:
sortValue
,
'reverse'
:
reverse
}
sort_kw
=
{
'key'
:
sortValue
,
'reverse'
:
reverse
}
sort_kw_cache
[(
sort_on
,
sort_order
)]
=
sort_kw
sort_kw_cache
[(
sort_on
,
sort_order
)]
=
sort_kw
else
:
else
:
...
...
product/ERP5Type/tests/testERP5Type.py
View file @
741eddb9
...
@@ -38,7 +38,7 @@ from Acquisition import aq_base
...
@@ -38,7 +38,7 @@ from Acquisition import aq_base
from
Products.ERP5Type.tests.ERP5TypeTestCase
import
ERP5TypeTestCase
from
Products.ERP5Type.tests.ERP5TypeTestCase
import
ERP5TypeTestCase
from
AccessControl.ZopeGuards
import
guarded_import
from
AccessControl.ZopeGuards
import
guarded_import
from
Products.ERP5Type.tests.utils
import
LogInterceptor
,
createZODBPythonScript
from
Products.ERP5Type.tests.utils
import
LogInterceptor
,
createZODBPythonScript
from
Products.ERP5Type.Utils
import
OrderableList
,
cmp
from
Products.ERP5Type.Utils
import
cmp
class
TestERP5Type
(
ERP5TypeTestCase
,
LogInterceptor
):
class
TestERP5Type
(
ERP5TypeTestCase
,
LogInterceptor
):
"""
"""
...
@@ -296,16 +296,6 @@ class TestERP5Type(ERP5TypeTestCase, LogInterceptor):
...
@@ -296,16 +296,6 @@ class TestERP5Type(ERP5TypeTestCase, LogInterceptor):
self
.
assertEqual
(
cmp
(
None
,
''
),
-
1
)
self
.
assertEqual
(
cmp
(
None
,
''
),
-
1
)
self
.
assertEqual
(
cmp
(
0
,
''
),
-
1
)
self
.
assertEqual
(
cmp
(
0
,
''
),
-
1
)
def
test_OrderableList
(
self
):
o1
=
OrderableList
(
None
,
1
)
o2
=
OrderableList
(
0
,
0
)
self
.
assertEqual
(
sorted
([
o1
,
o2
]),
[
o1
,
o2
])
self
.
assertEqual
(
sorted
([
o2
,
o1
]),
[
o1
,
o2
])
o3
=
OrderableList
(
1
,
2
,
3
)
o4
=
OrderableList
(
1
,
2
,
3
,
4
)
self
.
assertEqual
(
sorted
([
o3
,
o4
]),
[
o3
,
o4
])
self
.
assertEqual
(
sorted
([
o4
,
o3
]),
[
o3
,
o4
])
def
test_suite
():
def
test_suite
():
suite
=
unittest
.
TestSuite
()
suite
=
unittest
.
TestSuite
()
suite
.
addTest
(
unittest
.
makeSuite
(
TestERP5Type
))
suite
.
addTest
(
unittest
.
makeSuite
(
TestERP5Type
))
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment