sip_to_pjsip: Enable python3 compatibility.

The script remains compatible with Python 2.7 but now also works with
Python 3.3 and newer; to ease the migration from chan_sip to chan_pjsip.

ASTERISK-27811

Change-Id: I59cc6b52a1a89777eebcf25b3023bdf93babf835
This commit is contained in:
Alexander Traud
2018-04-18 09:27:51 +02:00
committed by Corey Farrell
parent 9f1e1d153a
commit 2d81709ab1
5 changed files with 69 additions and 63 deletions

View File

@@ -49,7 +49,7 @@ class Section(MultiOrderedDict):
"""
Use self.id as means of determining equality
"""
return cmp(self.id, other.id)
return (self.id > other.id) - (self.id < other.id)
def __eq__(self, other):
"""
@@ -445,7 +445,7 @@ class MultiOrderedConfigParser:
with open(filename, 'rt') as config_file:
self._read(config_file, sect)
except IOError:
print "Could not open file ", filename, " for reading"
print("Could not open file " + filename + " for reading")
def _read(self, config_file, sect):
"""Parse configuration information from the config_file"""
@@ -490,4 +490,4 @@ class MultiOrderedConfigParser:
with open(config_file, 'wt') as fp:
self.write(fp)
except IOError:
print "Could not open file ", config_file, " for writing"
print("Could not open file " + config_file + " for writing")