Skip to content

Commit 2d423bd

Browse files
author
stroeder
committed
PEP-8 for ldap.cidict
1 parent 376f304 commit 2d423bd

File tree

1 file changed

+88
-88
lines changed

1 file changed

+88
-88
lines changed

Lib/ldap/cidict.py

Lines changed: 88 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -6,98 +6,98 @@
66
See https://www.python-ldap.org/ for details.
77
"""
88

9-
from ldap import __version__
10-
119
from UserDict import IterableUserDict
1210

11+
from ldap import __version__
12+
1313

1414
class cidict(IterableUserDict):
15-
"""
16-
Case-insensitive but case-respecting dictionary.
17-
"""
18-
19-
def __init__(self,default=None):
20-
self._keys = {}
21-
IterableUserDict.__init__(self,{})
22-
self.update(default or {})
23-
24-
def __getitem__(self,key):
25-
return self.data[key.lower()]
26-
27-
def __setitem__(self,key,value):
28-
lower_key = key.lower()
29-
self._keys[lower_key] = key
30-
self.data[lower_key] = value
31-
32-
def __delitem__(self,key):
33-
lower_key = key.lower()
34-
del self._keys[lower_key]
35-
del self.data[lower_key]
36-
37-
def update(self,dict):
38-
for key in dict.keys():
39-
self[key] = dict[key]
40-
41-
def has_key(self,key):
42-
return key in self
43-
44-
def __contains__(self,key):
45-
return IterableUserDict.__contains__(self, key.lower())
46-
47-
def get(self,key,failobj=None):
48-
try:
49-
return self[key]
50-
except KeyError:
51-
return failobj
52-
53-
def keys(self):
54-
return self._keys.values()
55-
56-
def items(self):
57-
result = []
58-
for k in self._keys.values():
59-
result.append((k,self[k]))
15+
"""
16+
Case-insensitive but case-respecting dictionary.
17+
"""
18+
19+
def __init__(self, default=None):
20+
self._keys = {}
21+
IterableUserDict.__init__(self, {})
22+
self.update(default or {})
23+
24+
def __getitem__(self, key):
25+
return self.data[key.lower()]
26+
27+
def __setitem__(self, key, value):
28+
lower_key = key.lower()
29+
self._keys[lower_key] = key
30+
self.data[lower_key] = value
31+
32+
def __delitem__(self, key):
33+
lower_key = key.lower()
34+
del self._keys[lower_key]
35+
del self.data[lower_key]
36+
37+
def update(self, data):
38+
for key in data.keys():
39+
self[key] = data[key]
40+
41+
def has_key(self, key):
42+
return key in self
43+
44+
def __contains__(self, key):
45+
return IterableUserDict.__contains__(self, key.lower())
46+
47+
def get(self, key, failobj=None):
48+
try:
49+
return self[key]
50+
except KeyError:
51+
return failobj
52+
53+
def keys(self):
54+
return self._keys.values()
55+
56+
def items(self):
57+
result = []
58+
for k in self._keys.values():
59+
result.append((k, self[k]))
60+
return result
61+
62+
63+
def strlist_minus(a, b):
64+
"""
65+
Return list of all items in a which are not in b (a - b).
66+
a,b are supposed to be lists of case-insensitive strings.
67+
"""
68+
temp = cidict()
69+
for elt in b:
70+
temp[elt] = elt
71+
result = [
72+
elt
73+
for elt in a
74+
if elt not in temp
75+
]
76+
return result
77+
78+
79+
def strlist_intersection(a, b):
80+
"""
81+
Return intersection of two lists of case-insensitive strings a,b.
82+
"""
83+
temp = cidict()
84+
for elt in a:
85+
temp[elt] = elt
86+
result = [
87+
temp[elt]
88+
for elt in b
89+
if elt in temp
90+
]
6091
return result
6192

6293

63-
def strlist_minus(a,b):
64-
"""
65-
Return list of all items in a which are not in b (a - b).
66-
a,b are supposed to be lists of case-insensitive strings.
67-
"""
68-
temp = cidict()
69-
for elt in b:
70-
temp[elt] = elt
71-
result = [
72-
elt
73-
for elt in a
74-
if elt not in temp
75-
]
76-
return result
77-
78-
79-
def strlist_intersection(a,b):
80-
"""
81-
Return intersection of two lists of case-insensitive strings a,b.
82-
"""
83-
temp = cidict()
84-
for elt in a:
85-
temp[elt] = elt
86-
result = [
87-
temp[elt]
88-
for elt in b
89-
if elt in temp
90-
]
91-
return result
92-
93-
94-
def strlist_union(a,b):
95-
"""
96-
Return union of two lists of case-insensitive strings a,b.
97-
"""
98-
temp = cidict()
99-
for elt in a:
100-
temp[elt] = elt
101-
for elt in b:
102-
temp[elt] = elt
103-
return temp.values()
94+
def strlist_union(a, b):
95+
"""
96+
Return union of two lists of case-insensitive strings a,b.
97+
"""
98+
temp = cidict()
99+
for elt in a:
100+
temp[elt] = elt
101+
for elt in b:
102+
temp[elt] = elt
103+
return temp.values()

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy