0001-wip.patch
src/ldaptools/synchronize.py | ||
---|---|---|
236 | 236 |
entries.sort(key=lambda (dn, entry): len(str2dn(dn))) |
237 | 237 |
for dn, entry in entries: |
238 | 238 |
for key in entry.keys(): |
239 |
if not key in self.attributes:
|
|
239 |
if not str(key.lower()) in self.attributes:
|
|
240 | 240 |
del entry[key] |
241 | 241 |
# First create, rename and update |
242 | 242 |
for batch in batch_generator(entries, self.BATCH_SIZE): |
src/ldaptools/utils.py | ||
---|---|---|
1 | 1 |
import ldap.dn |
2 |
from six import string_types |
|
2 | 3 | |
3 | 4 | |
4 | 5 |
# Copied from http://code.activestate.com/recipes/194371-case-insensitive-strings/ |
... | ... | |
7 | 8 |
Performs like str except comparisons are case insensitive.""" |
8 | 9 | |
9 | 10 |
def __init__(self, strMe): |
10 |
str.__init__(self, strMe)
|
|
11 |
str.__init__(self) |
|
11 | 12 |
self.__lowerCaseMe = strMe.lower() |
12 | 13 | |
13 | 14 |
def __repr__(self): |
... | ... | |
80 | 81 |
def findkey(self, item): |
81 | 82 |
"""A caseless way of checking if a key exists or not. |
82 | 83 |
It returns None or the correct key.""" |
83 |
if not isinstance(item, str): |
|
84 |
if not isinstance(item, string_types):
|
|
84 | 85 |
raise TypeError('Keywords for this object must be strings. You supplied %s' % type(item)) |
85 | 86 |
key = item.lower() |
86 | 87 |
try: |
... | ... | |
147 | 148 | |
148 | 149 |
def has_key(self, item): |
149 | 150 |
"""A case insensitive test for keys.""" |
150 |
if not isinstance(item, str): |
|
151 |
if not isinstance(item, string_types):
|
|
151 | 152 |
return False # should never have a non-string key |
152 | 153 |
return item.lower() in self._keydict # does the key exist |
153 | 154 | |
154 | 155 |
def __contains__(self, item): |
155 | 156 |
"""A case insensitive __contains__.""" |
156 |
if not isinstance(item, str): |
|
157 |
if not isinstance(item, string_types):
|
|
157 | 158 |
return False # should never have a non-string key |
158 | 159 |
return item.lower() in self._keydict # does the key exist |
159 | 160 |
tox.ini | ||
---|---|---|
5 | 5 | |
6 | 6 |
[tox] |
7 | 7 |
toxworkdir = {env:TMPDIR:/tmp}/tox-{env:USER}/ldaptools/ |
8 |
envlist = coverage,package |
|
8 |
envlist = coverage-ldappre3,coverage,package
|
|
9 | 9 | |
10 | 10 |
[testenv] |
11 | 11 |
usedevelop = true |
... | ... | |
16 | 16 |
pytest |
17 | 17 |
pytest-cov |
18 | 18 |
pytest-random |
19 |
python-ldap<3 |
|
19 |
ldappre3: python-ldap<3 |
|
20 |
!ldappre3: python-ldap>=3 |
|
20 | 21 |
commands = |
21 | 22 |
py.test {env:COVERAGE:} {posargs:--random tests} |
22 | 23 | |
23 |
- |