Fix GetServiceVersions for Python 3
This commit is contained in:
@@ -28,6 +28,8 @@ from datetime import datetime
|
|||||||
from pyVmomi import Iso8601
|
from pyVmomi import Iso8601
|
||||||
import base64
|
import base64
|
||||||
import threading
|
import threading
|
||||||
|
if PY3:
|
||||||
|
from functools import cmp_to_key
|
||||||
|
|
||||||
if PY3:
|
if PY3:
|
||||||
# python3 removed long, it's the same as int
|
# python3 removed long, it's the same as int
|
||||||
@@ -1144,22 +1146,21 @@ def GetServiceVersions(namespace):
|
|||||||
by compatibility (i.e. any version in the list that is compatible with some version
|
by compatibility (i.e. any version in the list that is compatible with some version
|
||||||
v in the list will preceed v)
|
v in the list will preceed v)
|
||||||
"""
|
"""
|
||||||
versions = dict((v, True) for (v, n) in iteritems(serviceNsMap) if n == namespace)
|
def compare(a, b):
|
||||||
mappings = {}
|
if a == b:
|
||||||
for v in iterkeys(versions):
|
return 0
|
||||||
mappings[v] = set(parent for parent in iterkeys(parentMap[v])
|
if b in parentMap[a]:
|
||||||
if parent != v and parent in versions.keys())
|
return -1
|
||||||
res = []
|
if a in parentMap[b]:
|
||||||
while True:
|
return 1
|
||||||
el = [ k for (k, v) in iteritems(mappings) if len(v) == 0 ]
|
return (a > b) - (a < b)
|
||||||
if len(el) == 0:
|
|
||||||
return res
|
if PY3:
|
||||||
el.sort()
|
return sorted([v for (v, n) in iteritems(serviceNsMap) if n == namespace],
|
||||||
for k in el:
|
key=cmp_to_key(compare))
|
||||||
res.insert(0, k)
|
else:
|
||||||
del mappings[k]
|
return sorted([v for (v, n) in iteritems(serviceNsMap) if n == namespace],
|
||||||
for values in itervalues(mappings):
|
compare)
|
||||||
values.discard(k)
|
|
||||||
|
|
||||||
|
|
||||||
## Set a WSDL method with wsdl namespace and wsdl name
|
## Set a WSDL method with wsdl namespace and wsdl name
|
||||||
|
Reference in New Issue
Block a user