diff options
author | Vlastimil Zíma <vlastimil.zima@nic.cz> | 2018-03-07 14:21:05 +0100 |
---|---|---|
committer | Vlastimil Zíma <vlastimil.zima@nic.cz> | 2018-03-07 14:21:05 +0100 |
commit | 154ced931e746749ba87eb7305c52cf0aa224fdd (patch) | |
tree | 5bcb7c7f440984222f97b8fb640b62a9552e3fb3 /openid | |
parent | 6006ed0594ed4b120ae7999d75d4594f65fc1f1c (diff) | |
download | openid-154ced931e746749ba87eb7305c52cf0aa224fdd.tar.gz |
Remove disliked functions - map, filter and reduce
Diffstat (limited to 'openid')
-rw-r--r-- | openid/__init__.py | 2 | ||||
-rw-r--r-- | openid/consumer/html_parse.py | 2 | ||||
-rw-r--r-- | openid/dh.py | 2 | ||||
-rw-r--r-- | openid/extensions/draft/pape2.py | 3 | ||||
-rw-r--r-- | openid/extensions/draft/pape5.py | 3 | ||||
-rw-r--r-- | openid/store/filestore.py | 4 | ||||
-rw-r--r-- | openid/store/sqlstore.py | 2 | ||||
-rw-r--r-- | openid/test/test_accept.py | 2 | ||||
-rw-r--r-- | openid/test/test_dh.py | 4 | ||||
-rw-r--r-- | openid/test/test_linkparse.py | 2 | ||||
-rw-r--r-- | openid/test/test_oidutil.py | 4 | ||||
-rw-r--r-- | openid/test/test_trustroot.py | 4 | ||||
-rw-r--r-- | openid/urinorm.py | 4 | ||||
-rw-r--r-- | openid/yadis/__init__.py | 2 | ||||
-rw-r--r-- | openid/yadis/xri.py | 7 |
15 files changed, 19 insertions, 28 deletions
diff --git a/openid/__init__.py b/openid/__init__.py index b172b30..1ef3e0e 100644 --- a/openid/__init__.py +++ b/openid/__init__.py @@ -45,7 +45,7 @@ __all__ = [ # Parse the version info try: - version_info = map(int, __version__.split('.')) + version_info = tuple(int(i) for i in __version__.split('.')) except ValueError: version_info = (None, None, None) else: diff --git a/openid/consumer/html_parse.py b/openid/consumer/html_parse.py index 14ff8cc..3c2a025 100644 --- a/openid/consumer/html_parse.py +++ b/openid/consumer/html_parse.py @@ -249,7 +249,7 @@ def findLinksRel(link_attrs_list, target_rel): as a relationship.""" # XXX: TESTME matchesTarget = partial(linkHasRel, target_rel=target_rel) - return filter(matchesTarget, link_attrs_list) + return [i for i in link_attrs_list if matchesTarget(i)] def findFirstHref(link_attrs_list, target_rel): diff --git a/openid/dh.py b/openid/dh.py index 5b7a440..74065fd 100644 --- a/openid/dh.py +++ b/openid/dh.py @@ -10,7 +10,7 @@ def strxor(x, y): if len(x) != len(y): raise ValueError('Inputs to strxor must have the same length') - return "".join(map(_xor, zip(x, y))) + return "".join(_xor((a, b)) for a, b in zip(x, y)) class DiffieHellman(object): diff --git a/openid/extensions/draft/pape2.py b/openid/extensions/draft/pape2.py index 954c5c0..d1790a8 100644 --- a/openid/extensions/draft/pape2.py +++ b/openid/extensions/draft/pape2.py @@ -145,8 +145,7 @@ class Request(Extension): @returntype: [str] """ - return filter(self.preferred_auth_policies.__contains__, - supported_types) + return [i for i in supported_types if i in self.preferred_auth_policies] Request.ns_uri = ns_uri diff --git a/openid/extensions/draft/pape5.py b/openid/extensions/draft/pape5.py index e7568dd..7065500 100644 --- a/openid/extensions/draft/pape5.py +++ b/openid/extensions/draft/pape5.py @@ -264,8 +264,7 @@ class Request(PAPEExtension): @returntype: [str] """ - return filter(self.preferred_auth_policies.__contains__, - supported_types) + return [i for i in supported_types if i in self.preferred_auth_policies] Request.ns_uri = ns_uri diff --git a/openid/store/filestore.py b/openid/store/filestore.py index 0c5c044..aadf20d 100644 --- a/openid/store/filestore.py +++ b/openid/store/filestore.py @@ -333,9 +333,7 @@ class FileOpenIDStore(OpenIDStore): def _allAssocs(self): all_associations = [] - association_filenames = map( - lambda filename: os.path.join(self.association_dir, filename), - os.listdir(self.association_dir)) + association_filenames = [os.path.join(self.association_dir, f) for f in os.listdir(self.association_dir)] for association_filename in association_filenames: try: association_file = file(association_filename, 'rb') diff --git a/openid/store/sqlstore.py b/openid/store/sqlstore.py index c9e7b23..339931e 100644 --- a/openid/store/sqlstore.py +++ b/openid/store/sqlstore.py @@ -146,7 +146,7 @@ class SQLStore(OpenIDStore): return str(arg) else: return arg - str_args = map(unicode_to_str, args) + str_args = [unicode_to_str(i) for i in args] self.cur.execute(sql, str_args) def __getattr__(self, attr): diff --git a/openid/test/test_accept.py b/openid/test/test_accept.py index 3f8d9ff..0b2fbb9 100644 --- a/openid/test/test_accept.py +++ b/openid/test/test_accept.py @@ -89,7 +89,7 @@ class MatchAcceptTest(unittest.TestCase): def runTest(self): lines = getTestData() chunks = chunk(lines) - data_sets = map(parseLines, chunks) + data_sets = [parseLines(l) for l in chunks] for data in data_sets: lnos = [] lno, accept_header = data['accept'] diff --git a/openid/test/test_dh.py b/openid/test/test_dh.py index 6c78a0b..03ef20b 100644 --- a/openid/test/test_dh.py +++ b/openid/test/test_dh.py @@ -31,8 +31,8 @@ class TestStrXor(unittest.TestCase): ('', 'a'), ('foo', 'ba'), (NUL * 3, NUL * 4), - (''.join(map(chr, xrange(256))), - ''.join(map(chr, xrange(128)))), + (''.join(chr(i) for i in range(256)), + ''.join(chr(i) for i in range(128))), ] for aa, bb in exc_cases: diff --git a/openid/test/test_linkparse.py b/openid/test/test_linkparse.py index 230bd05..077caaf 100644 --- a/openid/test/test_linkparse.py +++ b/openid/test/test_linkparse.py @@ -30,7 +30,7 @@ def parseCase(s): name = lines.pop(0) assert name.startswith('Name: ') desc = name[6:] - return desc, markup, map(parseLink, lines) + return desc, markup, [parseLink(l) for l in lines] def parseTests(s): diff --git a/openid/test/test_oidutil.py b/openid/test/test_oidutil.py index b64898a..a8415e8 100644 --- a/openid/test/test_oidutil.py +++ b/openid/test/test_oidutil.py @@ -27,7 +27,7 @@ class TestBase64(unittest.TestCase): '\x00', '\x01', '\x00' * 100, - ''.join(map(chr, range(256))), + ''.join(chr(i) for i in range(256)), ] for s in cases: @@ -39,7 +39,7 @@ class TestBase64(unittest.TestCase): # Randomized test for _ in xrange(50): n = random.randrange(2048) - s = ''.join(map(chr, map(lambda _: random.randrange(256), range(n)))) + s = ''.join(chr(random.randrange(256)) for i in range(n)) b64 = oidutil.toBase64(s) checkEncoded(b64) s_prime = oidutil.fromBase64(b64) diff --git a/openid/test/test_trustroot.py b/openid/test/test_trustroot.py index 8302141..a470207 100644 --- a/openid/test/test_trustroot.py +++ b/openid/test/test_trustroot.py @@ -42,7 +42,7 @@ class MatchTest(unittest.TestCase): def getTests(grps, head, dat): tests = [] top = head.strip() - gdat = map(str.strip, dat.split('-' * 40 + '\n')) + gdat = [i.strip() for i in dat.split('-' * 40 + '\n')] assert not gdat[0] assert len(gdat) == (len(grps) * 2 + 1), (gdat, grps) i = 1 @@ -57,7 +57,7 @@ def getTests(grps, head, dat): def parseTests(data): - parts = map(str.strip, data.split('=' * 40 + '\n')) + parts = [i.strip() for i in data.split('=' * 40 + '\n')] assert not parts[0] _, ph, pdat, mh, mdat = parts return ph, pdat, mh, mdat diff --git a/openid/urinorm.py b/openid/urinorm.py index 21869c8..e7127d3 100644 --- a/openid/urinorm.py +++ b/openid/urinorm.py @@ -75,9 +75,7 @@ _unreserved[ord('_')] = True _unreserved[ord('~')] = True -_escapeme_re = re.compile('[%s]' % (''.join( - map(lambda m_n: u'%s-%s' % (unichr(m_n[0]), unichr(m_n[1])), - UCSCHAR + IPRIVATE)),)) +_escapeme_re = re.compile('[%s]' % ''.join(u'%s-%s' % (unichr(m_n[0]), unichr(m_n[1])) for m_n in UCSCHAR + IPRIVATE)) def _pct_escape_unicode(char_match): diff --git a/openid/yadis/__init__.py b/openid/yadis/__init__.py index 68a0d44..a163f80 100644 --- a/openid/yadis/__init__.py +++ b/openid/yadis/__init__.py @@ -16,7 +16,7 @@ __version__ = '[library version:1.1.0-rc1]'[17:-1] # Parse the version info try: - version_info = map(int, __version__.split('.')) + version_info = tuple(int(i) for i in __version__.split('.')) except ValueError: version_info = (None, None, None) else: diff --git a/openid/yadis/xri.py b/openid/yadis/xri.py index bd3b29e..60e0675 100644 --- a/openid/yadis/xri.py +++ b/openid/yadis/xri.py @@ -6,7 +6,6 @@ """ import re -from functools import reduce XRI_AUTHORITIES = ['!', '=', '@', '+', '$', '('] @@ -51,9 +50,7 @@ else: ] -_escapeme_re = re.compile('[%s]' % (''.join( - map(lambda m_n: u'%s-%s' % (unichr(m_n[0]), unichr(m_n[1])), - UCSCHAR + IPRIVATE)),)) +_escapeme_re = re.compile('[%s]' % ''.join(u'%s-%s' % (unichr(m_n[0]), unichr(m_n[1])) for m_n in UCSCHAR + IPRIVATE)) def identifierScheme(identifier): @@ -147,7 +144,7 @@ def rootAuthority(xri): else: # IRI reference. XXX: Can IRI authorities have segments? segments = authority.split('!') - segments = reduce(list.__add__, map(lambda s: s.split('*'), segments)) + segments = [c for s in segments for c in s.split('*')] root = segments[0] return XRI(root) |