This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
#encoding utf-8 | |
import sys, os | |
from itertools import takewhile | |
def getFuncs(filename, funcDef = "def "): | |
lines = open(filename,'r').readlines() | |
funcDefIn = lambda line: True if line.strip().startswith(funcDef) else False | |
funcs = map(lambda i: [lines[i]] + list(takewhile(lambda x: not funcDefIn(x),lines[i+1:])),filter(lambda i: funcDefIn(lines[i]),range(len(lines)))) | |
# grabs lines until start of next func/end of file lines where functions start |