Change map and filter to list comprehension for py2 and py3 compatible

This commit is contained in:
littmus 2015-04-27 00:10:05 +09:00
parent a438406f68
commit eca9884b25

View File

@ -33,8 +33,8 @@ def get_all_imports(start_path):
logging.debug('Traversing tree, start: %s', start_path)
for root, dirs, files in os.walk(start_path):
packages.append(os.path.basename(root))
files = filter(lambda fn:os.path.splitext(fn)[1] == ".py", files)
packages += map(lambda fn:os.path.splitext(fn)[0], files)
files = [fn for fn in files if os.path.splitext(fn)[1] == ".py"]
packages += [os.path.splitext(fn)[0] for fn in files]
for file_name in files:
with open(os.path.join(root, file_name), "r") as file_object:
lines = filter(lambda l:len(l) > 0, map(lambda l:l.strip(), file_object))