def get_path_from_frame(frame, parent_path=None):
<EOL>try:<EOL><INDENT>caller_file = eval('<STR_LIT>', frame.f_globals, frame.f_locals)<EOL>d = os.path.dirname(os.path.abspath(caller_file))<EOL><DEDENT>except NameError:<EOL><INDENT>caller_name = eval('<STR_LIT>', frame.f_globals, frame.f_locals)<EOL>__import__(caller_name)<EOL>mod = sys.modules[caller_name]<EOL>if hasattr(mod, '<STR_LIT>'):<EOL><INDENT>d = os.path.dirname(os.path.abspath(mod.__file__))<EOL><DEDENT>else:<EOL><INDENT>d = os.path.abspath('<STR_LIT:.>')<EOL><DEDENT><DEDENT>if parent_path is not None:<EOL><INDENT>d = rel_path(d, parent_path)<EOL><DEDENT>return d or '<STR_LIT:.>'<EOL>
Return path of the module given a frame object from the call stack.

    Returned path is relative to parent_path when given,
    otherwise it is absolute path.