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

@@ -3,10 +3,12 @@
# copied from http://code.activestate.com/recipes/576693/
try:
from thread import get_ident as _get_ident
from threading import get_ident as _get_ident
except ImportError:
from dummy_thread import get_ident as _get_ident
try:
from thread import get_ident as _get_ident
except ImportError:
from dummy_thread import get_ident as _get_ident
try:
from _abcoll import KeysView, ValuesView, ItemsView
except ImportError:
@@ -267,11 +269,11 @@ class MultiOrderedDict(OrderedDict):
def __setitem__(self, key, val, i=None):
if key not in self:
# print "__setitem__ key = ", key, " val = ", val
# print("__setitem__ key = " + key + " val = " + val)
OrderedDict.__setitem__(
self, key, val if isinstance(val, list) else [val])
return
# print "inserting key = ", key, " val = ", val
# print("inserting key = " + key + " val = " + val)
vals = self[key]
if i is None:
i = len(vals)