Skip to content

Commit

Permalink
__cmp__ is removed in python3
Browse files Browse the repository at this point in the history
  • Loading branch information
davidlange6 committed Apr 5, 2019
1 parent e37bcff commit 5f930a3
Showing 1 changed file with 35 additions and 15 deletions.
50 changes: 35 additions & 15 deletions FWCore/ParameterSet/python/Types.py
Expand Up @@ -4,7 +4,7 @@
from .Mixins import saveOrigin
from .ExceptionHandling import format_typename, format_outerframe
from past.builtins import long

import codecs
import copy
import math
import six
Expand Down Expand Up @@ -167,7 +167,8 @@ def pythonValue(self, options=PrintOptions()):
@staticmethod
def formatValueForConfig(value):
l = len(value)
value = value.encode("string-escape")
t=codecs.escape_encode(value.encode('utf-8'))
value = t[0].decode('utf-8')
newL = len(value)
if l != newL:
#get rid of the hex encoding
Expand Down Expand Up @@ -481,13 +482,26 @@ def pythonValue(self, options=PrintOptions()):
@staticmethod
def _isValid(value):
return True
def __cmp__(self,other):
v = self.__moduleLabel != other.__moduleLabel
if not v:
v= self.__productInstance != other.__productInstance
if not v:
v=self.__processName != other.__processName
return v
def __eq__(self,other):
return ((self.__moduleLabel,self.__productInstance,self.__processName) ==
(other.__moduleLabel,other.__productInstance,other.__processName))
def __ne__(self,other):
return ((self.__moduleLabel,self.__productInstance,self.__processName) !=
(other.__moduleLabel,other.__productInstance,other.__processName))
def __lt__(self,other):
return ((self.__moduleLabel,self.__productInstance,self.__processName) <
(other.__moduleLabel,other.__productInstance,other.__processName))
def __gt__(self,other):
return ((self.__moduleLabel,self.__productInstance,self.__processName) >
(other.__moduleLabel,other.__productInstance,other.__processName))
def __le__(self,other):
return ((self.__moduleLabel,self.__productInstance,self.__processName) <=
(other.__moduleLabel,other.__productInstance,other.__processName))
def __ge__(self,other):
return ((self.__moduleLabel,self.__productInstance,self.__processName) >=
(other.__moduleLabel,other.__productInstance,other.__processName))


def value(self):
"Return the string rep"
return self.configValue()
Expand All @@ -505,7 +519,6 @@ def _setValues(self,moduleLabel,productInstanceLabel='',processName=''):
self.__moduleLabel = moduleLabel
self.__productInstance = productInstanceLabel
self.__processName=processName

if -1 != moduleLabel.find(":"):
toks = moduleLabel.split(":")
self.__moduleLabel = toks[0]
Expand Down Expand Up @@ -557,11 +570,18 @@ def pythonValue(self, options=PrintOptions()):
@staticmethod
def _isValid(value):
return True
def __cmp__(self,other):
v = self.__moduleLabel != other.__moduleLabel
if not v:
v= self.__data != other.__data
return v
def __eq__(self,other):
return ((self.__moduleLabel,self.__data) == (other.__moduleLabel,other.__data))
def __ne__(self,other):
return ((self.__moduleLabel,self.__data) != (other.__moduleLabel,other.__data))
def __lt__(self,other):
return ((self.__moduleLabel,self.__data) < (other.__moduleLabel,other.__data))
def __gt__(self,other):
return ((self.__moduleLabel,self.__data) > (other.__moduleLabel,other.__data))
def __le__(self,other):
return ((self.__moduleLabel,self.__data) <= (other.__moduleLabel,other.__data))
def __ge__(self,other):
return ((self.__moduleLabel,self.__data) >= (other.__moduleLabel,other.__data))
def value(self):
"Return the string rep"
return self.configValue()
Expand Down

0 comments on commit 5f930a3

Please sign in to comment.