parameters: (frame, parent_path=None)
return_statement: return d or '.'
docstring: 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.
docstring_summary: Return path of the module given a frame object from the call stack.
docstring_tokens: Return path of the module given a frame object from the call stack .
function: def get_path_from_frame(frame, parent_path=None):
      """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.
      """
  
      # First, try to find if the file name is in the frame.
      try:
          caller_file = eval('__file__', frame.f_globals, frame.f_locals)
          d = os.path.dirname(os.path.abspath(caller_file))
      except NameError:
          # __file__ is not defined, so let's try __name__. We try this second
          # because setuptools spoofs __name__ to be '__main__' even though
          # sys.modules['__main__'] might be something else, like easy_install(1).
          caller_name = eval('__name__', frame.f_globals, frame.f_locals)
          __import__(caller_name)
          mod = sys.modules[caller_name]
          if hasattr(mod, '__file__'):
              d = os.path.dirname(os.path.abspath(mod.__file__))
          else:
              # we're probably running setup.py as execfile("setup.py")
              # (likely we're building an egg)
              d = os.path.abspath('.')
              # hmm, should we use sys.argv[0] like in __builtin__ case?
  
      if parent_path is not None:
          d = rel_path(d, parent_path)
  
      return d or '.'
function_tokens: def get_path_from_frame ( frame , parent_path = None ) : # First, try to find if the file name is in the frame. try : caller_file = eval ( '__file__' , frame . f_globals , frame . f_locals ) d = os . path . dirname ( os . path . abspath ( caller_file ) ) except NameError : # __file__ is not defined, so let's try __name__. We try this second # because setuptools spoofs __name__ to be '__main__' even though # sys.modules['__main__'] might be something else, like easy_install(1). caller_name = eval ( '__name__' , frame . f_globals , frame . f_locals ) __import__ ( caller_name ) mod = sys . modules [ caller_name ] if hasattr ( mod , '__file__' ) : d = os . path . dirname ( os . path . abspath ( mod . __file__ ) ) else : # we're probably running setup.py as execfile("setup.py") # (likely we're building an egg) d = os . path . abspath ( '.' ) # hmm, should we use sys.argv[0] like in __builtin__ case? if parent_path is not None : d = rel_path ( d , parent_path ) return d or '.'