Skip to content

Commit 3ae51ed

Browse files
committed
Update uses of map() to use list/set comprehensions instead
Updates style to modern Python idioms.
1 parent 98c535b commit 3ae51ed

File tree

5 files changed

+9
-10
lines changed

5 files changed

+9
-10
lines changed

Lib/ldap/controls/deref.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ def decodeControlValue(self,encodedControlValue):
108108
for deref_res in decodedValue:
109109
deref_attr,deref_val,deref_vals = deref_res[0],deref_res[1],deref_res[2]
110110
partial_attrs_dict = {
111-
str(tv[0]): map(str,tv[1])
111+
str(tv[0]): [str(v) for v in tv[1]]
112112
for tv in deref_vals or []
113113
}
114114
try:

Lib/ldap/filter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def filter_format(filter_template,assertion_values):
5454
List or tuple of assertion values. Length must match
5555
count of %s in filter_template.
5656
"""
57-
return filter_template % (tuple(map(escape_filter_chars,assertion_values)))
57+
return filter_template % tuple(escape_filter_chars(v) for v in assertion_values)
5858

5959

6060
def time_span_filter(

Lib/ldap/functions.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,7 @@ def escape_str(escape_func,s,*args):
138138
Applies escape_func() to all items of `args' and returns a string based
139139
on format string `s'.
140140
"""
141-
escape_args = map(escape_func,args)
142-
return s % tuple(escape_args)
141+
return s % tuple(escape_func(v) for v in args)
143142

144143

145144
def strf_secs(secs):

Lib/ldap/modlist.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
def addModlist(entry,ignore_attr_types=None):
1313
"""Build modify list for call of method LDAPObject.add()"""
14-
ignore_attr_types = set(map(str.lower,ignore_attr_types or []))
14+
ignore_attr_types = {v.lower() for v in ignore_attr_types or []}
1515
modlist = []
1616
for attrtype in entry.keys():
1717
if attrtype.lower() in ignore_attr_types:
@@ -46,8 +46,8 @@ def modifyModlist(
4646
List of attribute type names for which comparison will be made
4747
case-insensitive
4848
"""
49-
ignore_attr_types = set(map(str.lower,ignore_attr_types or []))
50-
case_ignore_attr_types = set(map(str.lower,case_ignore_attr_types or []))
49+
ignore_attr_types = {v.lower() for v in ignore_attr_types or []}
50+
case_ignore_attr_types = {v.lower() for v in case_ignore_attr_types or []}
5151
modlist = []
5252
attrtype_lower_map = {}
5353
for a in old_entry.keys():
@@ -73,8 +73,8 @@ def modifyModlist(
7373
replace_attr_value = len(old_value)!=len(new_value)
7474
if not replace_attr_value:
7575
if attrtype_lower in case_ignore_attr_types:
76-
old_value_set = set(map(str.lower,old_value))
77-
new_value_set = set(map(str.lower,new_value))
76+
old_value_set = {v.lower() for v in old_value}
77+
new_value_set = {v.lower() for v in new_value}
7878
else:
7979
old_value_set = set(old_value)
8080
new_value_set = set(new_value)

Lib/ldapurl.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ def values(self):
158158
]
159159

160160
def __str__(self):
161-
return ','.join(map(str,self.values()))
161+
return ','.join(str(v) for v in self.values())
162162

163163
def __repr__(self):
164164
return '<%s.%s instance at %s: %s>' % (

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