pyjack
======

pyjack is a debug/test/monkey-patching toolset that allows you to reversibly
replace *all* references to a function or object in memory with a 
proxy function or object. pyjack's has two major functions: 

* function "connect" can connect a 'proxy' function to almost 
  any python function/method.  This proxy function is called instead of the 
  original function.  However, the original function is passed to the proxy 
  function along with all args, kwargs so you can do things like:
  
  - Modify the args, kwargs first, print a debug message, then call the original
    function
  - Not call the function, rather just log it and print a debug message
   
  etc. etc. -- it's all up to you. 
  
* function "replace_all_refs" can be used to replace all 
  references to a object with references to another object. This replaces all 
  references in the _entire_ memory space. 

A quick example::

    >>> import pyjack
    >>> 
    >>> def fakeimport(orgopen, *args, **kwargs):
    ...     
    ...     print 'Trying to import %s' % args[0]
    ...     
    ...     return 'MODULE_%s' % args[0]
    ... 
    >>>
    >>>
    >>> pyjack.connect(__import__, proxyfn=fakeimport)
    <..._PyjackFuncBuiltin object at 0x...>
    >>> 
    >>>
    >>> import time
    Trying to import time
    >>>
    >>>
    >>> print time
    MODULE_time
    >>> 
    >>>
    >>> __import__.restore()
    >>> 
    >>> import time
    >>> print time
    <module 'time' (built-in)>

    
For full documentation and several examples please visit: 

* http://packages.python.org/pyjack/

The git repo is here: 

* https://github.com/cart0113/pyjack 
 
 
