Abstract

The ‘pysourceinfo’ package provides basic runtime information on executed sourcefiles based on ‘inspect’ and additional sources [shortcuts].

  • Runtime Type Information on Python source components: Packages, Modules, and Calls

    A basic coverage of the ‘inspect’ package is provided for the simplified gathering of information on packages, modules, and files based on the call stack [details]

    .

The main target of the project is the completion and simplification of the call interface for the most common calls related to RTTI provided by ‘inspect’.

Blueprint

The features provided by the package ‘pysourceinfo’ are based on the standard package ‘inspect’ with dynamic evaluation of additional sources where rewuired. A flat call interface is provided for simplified application in OO as well as simple scripting.

The provided runtime structure information on Python sources is covered with basically one single type of interface

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’.

The covered structural dynamic elements based on the call stackk are:

  • package
  • module
  • function
  • class/method
  • namespaces - global/local

With additional functions covering mostly static information:

  • loaded module
  • sys.path - actual OID and load path

For code and application examples refer to the souce code of ‘pysourceinfo.UseCases’ [UseCases] and ‘pysourceinfo.tests’ [tests].

Install - HowTo - FAQ - Help

  • Requires:

    • Runtime:

      Python >2.6.6, or Python 2.7. Python 3.x not yet supported.

    • SDK:

      Python 2.7. Python 3.x not yet supported. Sphinx the standard version >=1.4, which includes ‘sphinx-apidoc’. Epydoc version >=3.

      When missing the creation of a virtual environment has to be considered.

  • Platforms:

    Linux, Mac-OS/OS-X, MS-Windows

  • Install:

    • Runtime:

      Standard procedure online local install e.g. into virtual environment:

      pip install pysourceinfo
      

      or:

      python setup.py install
      

      Standard procedure online local install into user home:

      python setup.py install --user
      

      Custom procedure offline by:

      python setup.py install --user --offline
      
    • SDK:

      Required for document creation, add ‘–sdk’ option, checks build tools:

      python setup.py install --sdk
      

      Creation of documents, requires Sphinx including ‘sphinx-apidoc’, and Epydoc:

      python setup.py build_doc project_doc install_doc
      
  • Help:

    Remark: On Windows platforms it seems to be required the inspect module has to be initialized, so for now please include befor the import of ‘pysourceinfo’:

    # For now a dummy call for initialization, will be cleared soon...
    import inspect
    _dummyInit = inspect.stack()
    
    # For example...
    from pysourceinfo.PySourceInfo import getCallerModule,getCallerName
    

    that’s it. Going to investigate this soon.

Shortcuts

Common Interfaces:

Complete technical API:

  • Interface in javadoc-style [API]

Indices and tables

Resources

For available downloads refer to:

For Licenses refer to enclosed documents:

Project data summary: