python/samba: Add some compatability PY2/PY3 functions
authorNoel Power <noel.power@suse.com>
Fri, 13 Apr 2018 10:19:10 +0000 (11:19 +0100)
committerNoel Power <npower@samba.org>
Mon, 30 Apr 2018 13:43:19 +0000 (15:43 +0200)
I hope these changes are a short term interim solution for the
absence of the 'six' module/library. I also hope that soon this
module can be removed and be replaced by usage of six.

Signed-off-by: Noel Power <noel.power@suse.com>
Reviewed-by: Alexander Bokovoy <ab@samba.org>
python/samba/compat.py

index 667a1a443b1786cebf6cca6221fcbbf25764c289..d17dc3c2ce97d9eebf7689c79247866197036d34 100644 (file)
@@ -22,8 +22,20 @@ import sys
 PY3 = sys.version_info[0] == 3
 
 if PY3:
+    # compat functions
+    from  urllib.parse import quote as urllib_quote
+    from urllib.request import urlopen as urllib_urlopen
+
+    # compat types
     integer_types = int,
+    string_types = str
     text_type = str
 else:
+    # compat functions
+    from urllib import quote as urllib_quote
+    from urllib import urlopen as urllib_urlopen
+
+    # compat types
     integer_types = (int, long)
+    string_types = basestring
     text_type = unicode