forked from upstream/UXP-mirror
Issue #2974 - Part 3: Adapt filter.
2to3 . --fix filter -wpn Py2 filter was a list, now filter is an iterator. This lets you have the old behavior. Mechanical. Ref: https://www.artima.com/weblogs/viewpost.jsp?thread=208549
This commit is contained in:
1 parent
49615281cd
commit
42fbdd74fd
49 files changed
+111
-120
No files matched your search
@@ -129,8 +129,8 @@ def parse_items(stream, items_in, items_out):
|
||||
bits_read += bits
|
||||
total_bits_read += bits
|
||||
elif len(item) == 3 or len(item) == 4:
|
||||
requirements = list(filter(lambda x: isinstance(x, dict), item[2]))
|
||||
sub_items = list(filter(lambda x: isinstance(x, tuple), item[2]))
|
||||
requirements = list([x for x in item[2] if isinstance(x, dict)])
|
||||
sub_items = list([x for x in item[2] if isinstance(x, tuple)])
|
||||
|
||||
if not meets_requirements(items_out, requirements): continue
|
||||
|
||||
@@ -438,8 +438,8 @@ def processMachoBinary(filename):
|
||||
|
||||
|
||||
|
||||
segment_commands = list(filter(lambda x: x[0].cmd == lc_segment, header.commands))
|
||||
text_segment_commands = list(filter(lambda x: x[1].segname.decode("utf-8").startswith("__TEXT"), segment_commands))
|
||||
segment_commands = list([x for x in header.commands if x[0].cmd == lc_segment])
|
||||
text_segment_commands = list([x for x in segment_commands if x[1].segname.decode("utf-8").startswith("__TEXT")])
|
||||
|
||||
|
||||
code_segment_digests = SetOfCodeSegmentDigest()
|
||||
@@ -518,7 +518,7 @@ def processCOFFBinary(stream):
|
||||
|
||||
arch_digest.setComponentByName('cpuSubType', CPUSubType('IMAGE_UNUSED'))
|
||||
|
||||
text_section_headers = list(filter(lambda x: (x.items['Characteristics'] & IMAGE_SCN_MEM_EXECUTE) == IMAGE_SCN_MEM_EXECUTE, coff_header.section_headers))
|
||||
text_section_headers = list([x for x in coff_header.section_headers if (x.items['Characteristics'] & IMAGE_SCN_MEM_EXECUTE) == IMAGE_SCN_MEM_EXECUTE])
|
||||
|
||||
code_segment_digests = SetOfCodeSegmentDigest()
|
||||
code_segment_idx = 0
|
||||
|
||||
@@ -542,7 +542,7 @@ To see more help for a specific command, run:
|
||||
return path
|
||||
|
||||
files = map(find_in_dir, self.settings_paths)
|
||||
files = filter(bool, files)
|
||||
files = list(filter(bool, files))
|
||||
|
||||
self.settings.load_files(files)
|
||||
|
||||
|
||||
@@ -144,4 +144,4 @@ class MachOStandalone(object):
|
||||
flipwritable(fn, old_mode)
|
||||
|
||||
allfiles = [mm.locate(node.filename) for node in machfiles]
|
||||
return set(filter(None, allfiles))
|
||||
return set([_f for _f in allfiles if _f])
|
||||
@@ -269,8 +269,8 @@ class RecursiveMakeTraversal(object):
|
||||
Helper function to call a filter from compute_dependencies and
|
||||
traverse.
|
||||
"""
|
||||
return filter(current, self._traversal.get(current,
|
||||
self.SubDirectories()))
|
||||
return list(filter(current, self._traversal.get(current,
|
||||
self.SubDirectories())))
|
||||
|
||||
def compute_dependencies(self, filter=None):
|
||||
"""
|
||||
|
||||
@@ -296,7 +296,7 @@ class Traceback(list):
|
||||
by default this removes all the TracebackItems which are hidden
|
||||
(see ishidden() above)
|
||||
"""
|
||||
return Traceback(filter(fn, self))
|
||||
return Traceback(list(filter(fn, self)))
|
||||
|
||||
def getcrashentry(self):
|
||||
""" return last non-hidden traceback entry that lead
|
||||
|
||||
@@ -92,7 +92,7 @@ class KeywordMapper:
|
||||
""" set a consumer for a set of keywords. """
|
||||
# normalize to tuples
|
||||
if isinstance(keywords, str):
|
||||
keywords = tuple(filter(None, keywords.split()))
|
||||
keywords = tuple([_f for _f in keywords.split() if _f])
|
||||
elif hasattr(keywords, '_keywords'):
|
||||
keywords = keywords._keywords
|
||||
elif not isinstance(keywords, tuple):
|
||||
|
||||
@@ -279,7 +279,7 @@ class LocalPath(FSBase):
|
||||
res = []
|
||||
parts = self.strpath.split(self.sep)
|
||||
|
||||
args = filter(None, spec.split(',') )
|
||||
args = [_f for _f in spec.split(',') if _f]
|
||||
append = res.append
|
||||
for name in args:
|
||||
if name == 'drive':
|
||||
|
||||
@@ -300,7 +300,7 @@ if verbose is True, then the LogEntry instances also know which files changed.
|
||||
from xml.dom import minidom
|
||||
tree = minidom.parse(xmlpipe)
|
||||
result = []
|
||||
for logentry in filter(None, tree.firstChild.childNodes):
|
||||
for logentry in [_f for _f in tree.firstChild.childNodes if _f]:
|
||||
if logentry.nodeType == logentry.ELEMENT_NODE:
|
||||
result.append(svncommon.LogEntry(logentry))
|
||||
return result
|
||||
|
||||
@@ -875,7 +875,7 @@ if verbose is True, then the LogEntry instances also know which files changed.
|
||||
except ExpatError:
|
||||
raise ValueError('no such revision')
|
||||
result = []
|
||||
for logentry in filter(None, tree.firstChild.childNodes):
|
||||
for logentry in [_f for _f in tree.firstChild.childNodes if _f]:
|
||||
if logentry.nodeType == logentry.ELEMENT_NODE:
|
||||
result.append(LogEntry(logentry))
|
||||
return result
|
||||
@@ -1215,7 +1215,7 @@ def importxml(cache=[]):
|
||||
class LogEntry:
|
||||
def __init__(self, logentry):
|
||||
self.rev = int(logentry.getAttribute('revision'))
|
||||
for lpart in filter(None, logentry.childNodes):
|
||||
for lpart in [_f for _f in logentry.childNodes if _f]:
|
||||
if lpart.nodeType == lpart.ELEMENT_NODE:
|
||||
if lpart.nodeName == 'author':
|
||||
self.author = lpart.firstChild.nodeValue
|
||||
@@ -1230,7 +1230,7 @@ class LogEntry:
|
||||
self.date = parse_apr_time(timestr)
|
||||
elif lpart.nodeName == 'paths':
|
||||
self.strpaths = []
|
||||
for ppart in filter(None, lpart.childNodes):
|
||||
for ppart in [_f for _f in lpart.childNodes if _f]:
|
||||
if ppart.nodeType == ppart.ELEMENT_NODE:
|
||||
self.strpaths.append(PathEntry(ppart))
|
||||
def __repr__(self):
|
||||
|
||||
@@ -200,7 +200,7 @@ def strip_html_comments(text):
|
||||
lines = text.splitlines(True) # preserve line endings.
|
||||
|
||||
# Remove HTML comments (which we only allow to take a special form).
|
||||
new_lines = filter(lambda line: not line.startswith("<!--"), lines)
|
||||
new_lines = [line for line in lines if not line.startswith("<!--")]
|
||||
|
||||
return "".join(new_lines)
|
||||
|
||||
|
||||
@@ -301,7 +301,7 @@ class Traceback(list):
|
||||
by default this removes all the TracebackEntries which are hidden
|
||||
(see ishidden() above)
|
||||
"""
|
||||
return Traceback(filter(fn, self))
|
||||
return Traceback(list(filter(fn, self)))
|
||||
|
||||
def getcrashentry(self):
|
||||
""" return last non-hidden traceback entry that lead
|
||||
|
||||
@@ -870,8 +870,8 @@ class Testdir:
|
||||
|
||||
"""
|
||||
env = os.environ.copy()
|
||||
env['PYTHONPATH'] = os.pathsep.join(filter(None, [
|
||||
str(os.getcwd()), env.get('PYTHONPATH', '')]))
|
||||
env['PYTHONPATH'] = os.pathsep.join([_f for _f in [
|
||||
str(os.getcwd()), env.get('PYTHONPATH', '')] if _f])
|
||||
kw['env'] = env
|
||||
return subprocess.Popen(cmdargs,
|
||||
stdout=stdout, stderr=stderr, **kw)
|
||||
|
||||
@@ -861,7 +861,7 @@ class CallSpec2(object):
|
||||
|
||||
@property
|
||||
def id(self):
|
||||
return "-".join(map(str, filter(None, self._idlist)))
|
||||
return "-".join(map(str, [_f for _f in self._idlist if _f]))
|
||||
|
||||
def setmulti(self, valtypes, argnames, valset, id, keywords, scopenum,
|
||||
param_index):
|
||||
|
||||
@@ -201,7 +201,7 @@ class Retry(object):
|
||||
def is_exhausted(self):
|
||||
""" Are we out of retries? """
|
||||
retry_counts = (self.total, self.connect, self.read, self.redirect)
|
||||
retry_counts = list(filter(None, retry_counts))
|
||||
retry_counts = list([_f for _f in retry_counts if _f])
|
||||
if not retry_counts:
|
||||
return False
|
||||
|
||||
|
||||
Reference in new issue
Block a user