#-*- coding:utf-8-*-
from parseFunc import *
from parseIncDep import *
import json
dirname = "."
#输出未定义的函数
#python parseDepFunc.py -f 需要解析的文件 -d 文件所在的目录

def addFunMap(dirname,filename,undefines,passed):
	passed.append(filename)
	funcs = getFunctionPath(dirname,filename,getAllFuncs(dirname,filename))
	funcs = getUndefinedFunc(funcs);
	undefines[filename] = funcs;
	depends = depend(dirname,filename)
	for depname in depends:
		if depname in passed:
			continue
		addFunMap(dirname,depname,undefines,passed)

def printDepUndef():
	undefines = {}
	addFunMap(dirname,filename,undefines,[])
	for d in undefines:
		if len(d) != 0:
			print d,undefines[d]

if __name__ == '__main__':
	opts,args = getopt.getopt(sys.argv[1:],'hf:d:DI');
	filename = ""
	dirname = "."
	for op, value in opts:
		if op == "-f":
			filename = value
		elif op == "-d":
			dirname = value
		elif op == "-h":
			print """python parseDepFunc.py \n
			-d dirname\n
			-f filename\n"""
			sys.exit()
	printDepUndef();
