skidl.scriptinfo module

Routines for getting information about a running script.

This module provides functions to determine information about the currently executing Python script, such as its name, directory, and call stack. These functions are useful for generating file names based on the script name and for debugging purposes.

skidl.scriptinfo.get_script_dir()[source]

Return the directory of the top-level script.

This function retrieves the directory where the top-level script is located.

Returns:

The directory of the top-level script.

Return type:

str

skidl.scriptinfo.get_script_name()[source]

Return the name of the top-level script without the file extension.

This function gets the name of the top-level script that is currently running and removes any file extension.

Returns:

The name of the top-level script without file extension.

Return type:

str

skidl.scriptinfo.get_skidl_trace()[source]

Get a trace of function calls excluding internal SKiDL functions.

This function examines the current call stack and creates a trace that excludes calls to internal SKiDL library functions. The resulting trace is useful for debugging and for identifying where SKiDL objects were created in user code.

Returns:

A list of tuples containing (file_path, line_number) for each relevant

call in the stack, ordered from the oldest call to the most recent.

Return type:

list

skidl.scriptinfo.scriptinfo()[source]

Get information about the running top-level Python script.

This function identifies the top-level script that is currently running, whether it’s an interpreted Python script or a compiled executable.

Returns:

A dictionary with the following keys:
  • ’dir’: Directory containing the script or compiled executable

  • ’name’: Name of script or executable

  • ’source’: Name of source code file

Return type:

dict

Notes

‘name’ and ‘source’ are identical if and only if running interpreted code. When running code compiled by py2exe or cx_freeze, source contains the name of the originating Python script. If compiled by PyInstaller, source contains no meaningful information.