+def function_properties(python_path, fn_name):
+ """
+ python_path : path to a python file
+ fn_name : name of a function in the file
+ return : properties of the function. see class FunctionProperties
+ """
+ with open(python_path, 'r') as f:
+ text_file = f.read()
+ functions,errors = get_properties(text_file)
+ result = [fn for fn in functions if fn.name == fn_name]
+ if len(result) < 1:
+ raise Exception("Function not found: {}".format(fn_name))
+ result = result[0]
+ error_string = ""
+ if len(errors) > 0:
+ error_string += "Global errors in file {}\n".format(python_path)
+ error_string += '\n'.join(errors)
+ raise Exception(error_string)
+ if len(result.errors) > 0:
+ error_string += "Errors when parsing function {}\n".format(fn_name)
+ error_string += '\n'.join(result.errors)
+ raise Exception(error_string)
+ return result
+
+