mirror of
https://github.com/samba-team/samba.git
synced 2025-01-11 05:18:09 +03:00
python/samba: port some isinstance str checks (to cater for unicode)
Signed-off-by: Noel Power <noel.power@suse.com> Reviewed-by: Alexander Bokovoy <ab@samba.org>
This commit is contained in:
parent
b54472f868
commit
141d9081f4
@ -29,6 +29,7 @@ import ldb
|
|||||||
import samba.param
|
import samba.param
|
||||||
from samba import _glue
|
from samba import _glue
|
||||||
from samba._ldb import Ldb as _Ldb
|
from samba._ldb import Ldb as _Ldb
|
||||||
|
from samba.compat import string_types
|
||||||
|
|
||||||
|
|
||||||
def source_tree_topdir():
|
def source_tree_topdir():
|
||||||
@ -249,8 +250,8 @@ def substitute_var(text, values):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
for (name, value) in values.items():
|
for (name, value) in values.items():
|
||||||
assert isinstance(name, str), "%r is not a string" % name
|
assert isinstance(name, string_types), "%r is not a string" % name
|
||||||
assert isinstance(value, str), "Value %r for %s is not a string" % (value, name)
|
assert isinstance(value, string_types), "Value %r for %s is not a string" % (value, name)
|
||||||
text = text.replace("${%s}" % name, value)
|
text = text.replace("${%s}" % name, value)
|
||||||
|
|
||||||
return text
|
return text
|
||||||
|
@ -21,6 +21,7 @@ from __future__ import print_function
|
|||||||
import re
|
import re
|
||||||
import base64
|
import base64
|
||||||
import uuid
|
import uuid
|
||||||
|
from samba.compat import string_types
|
||||||
|
|
||||||
bitFields = {}
|
bitFields = {}
|
||||||
|
|
||||||
@ -172,7 +173,7 @@ def fix_dn(dn):
|
|||||||
|
|
||||||
def __convert_bitfield(key, value):
|
def __convert_bitfield(key, value):
|
||||||
"""Evaluate the OR expression in 'value'"""
|
"""Evaluate the OR expression in 'value'"""
|
||||||
assert(isinstance(value, str))
|
assert(isinstance(value, string_types))
|
||||||
|
|
||||||
value = value.replace("\n ", "")
|
value = value.replace("\n ", "")
|
||||||
value = value.replace(" ", "")
|
value = value.replace(" ", "")
|
||||||
@ -194,7 +195,7 @@ def __write_ldif_one(entry):
|
|||||||
out = []
|
out = []
|
||||||
|
|
||||||
for l in entry:
|
for l in entry:
|
||||||
if isinstance(l[1], str):
|
if isinstance(l[1], string_types):
|
||||||
vl = [l[1]]
|
vl = [l[1]]
|
||||||
else:
|
else:
|
||||||
vl = l[1]
|
vl = l[1]
|
||||||
@ -247,7 +248,7 @@ def __transform_entry(entry, objectClass):
|
|||||||
l[1] = oMObjectClassBER[l[1].strip()]
|
l[1] = oMObjectClassBER[l[1].strip()]
|
||||||
l[2] = True
|
l[2] = True
|
||||||
|
|
||||||
if isinstance(l[1], str):
|
if isinstance(l[1], string_types):
|
||||||
l[1] = fix_dn(l[1])
|
l[1] = fix_dn(l[1])
|
||||||
|
|
||||||
if key == 'dn':
|
if key == 'dn':
|
||||||
|
Loading…
Reference in New Issue
Block a user