code: def get_path_executed_script() -> pathlib.Path:
      """
      getting the full path of the program from which a Python module is running
  
      >>> ### TEST get it via __main__.__file__
      >>> # Setup
      >>> # force __main__.__file__ valid
      >>> save_main_file = str(__main__.__file__)
      >>> __main__.__file__ = __file__
  
      >>> # Test via __main__.__file__
      >>> assert get_path_executed_script() == pathlib.Path(__file__).resolve()
  
  
      >>> ### TEST get it via sys.argv
      >>> # Setup
      >>> # force __main__.__file__ invalid
      >>> __main__.__file__ = str((pathlib.Path(__file__).parent / 'invalid_file.py'))  # .resolve() seems not to work on a non existing file in python 3.5
  
      >>> # force sys.argv valid
      >>> save_sys_argv = list(sys.argv)
      >>> valid_path = str((pathlib.Path(__file__).resolve()))
      >>> sys.argv = [valid_path]
  
      >>> # Test via sys.argv
      >>> assert get_path_executed_script() == pathlib.Path(__file__).resolve()
  
  
      >>> ### TEST get it via stack
      >>> # Setup
      >>> # force sys.argv invalid
      >>> invalid_path = str((pathlib.Path(__file__).parent / 'invalid_file.py'))  # .resolve() seems not to work on a non existing file in python 3.5
      >>> sys.argv = [invalid_path]
  
  
      >>> assert get_path_executed_script()
  
      >>> # teardown
      >>> __main__.__file__ = save_main_file
      >>> sys.argv = list(save_sys_argv)
  
      """
  
      # try to get it from __main__.__file__ - does not work under pytest, doctest
      path_candidate = get_fullpath_from_main_file()
      if path_candidate != empty_path:
          return path_candidate
  
      # try to get it from sys_argv - does not work when loaded from uwsgi, works in eclipse and pydev
      path_candidate = get_fullpath_from_sys_argv()
      if path_candidate != empty_path:
          return path_candidate
  
      return empty_path
  
file_path: neptune-client/src/neptune/vendor/lib_programname.py
imports: import pathlib
  import sys
  import __main__
label_desc: Use image node_id 1 for calling a global function with example usage: get_path_executed_script() and returns: empty_path, path_candidate, path_candidate