3. Blueprint

The package PySourceInfo provides the display of code-location for callable Python syntax elements including the involved class and containment hierarchy. The name-binding as defined by the package PySourceInfo targets the accurate location of static code components. This is based on the dynamic runtime information as provided by the Python interpreter. The PySourceInfo and the related PyStackInfo avoid static data preparation [PEP3155] and AST based approaches e.g. by [qualname]. In distinction pure dynamic data gathering is proceeded, which inherently provides also for generic code created during runtime execution.

_images/layers-with-pystackinfo-blueprint.png

Figure: Callstack Information zoom more…

The PySourceInfo focuses on basic information on files, modules, and packages, including line numbers with moderate use of the inspect API. The PyStackInfo package focuses on advanced control flow and runtime object location, including decorators, nested classes, and metaclasses.

_images/layers-blueprint.png

Figure: Components zoom more…

  • bininfo - information about the location of compiled runtime files

  • fileinfo - information about the source location of callables

  • infolists - lists and enumerations of source information

  • helper - support functions for the PYTHONPATH and the stack access

  • objectinfo - information about the runtime location of Python syntax elements

The package PyStackInfo makes extended use of the stack and type information. This provides advanced debugging and analysis in particular for typical routines handling large data sets where the pure debugger based analysis may encounter some limits. Both packages require the support of inspect, which is guaranteed in the standard CPython, and seems to be reliably present in PyPy.

The provided runtime structure information on Python sources is covered with basically one single type of interface[Name-Binding]

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
 def getCaller<Interface>(spos=1):
    """ Stack position:
       spos==0 => caller(0==CallInterface)
       spos==1 => caller(1)
       spos==N => caller(N==level N)
    """
    pass

 def getModule<Interface>(spos=1):
    pass

 def getpythonpath<Interface>(spos=1):
    pass

The interface gathers the information on the defined ‘<Interface>’ from the call stack, loaded modules, or search path PATH/PYTHONPATH/sys.path.