File: invoke.py

package info (click to toggle)
codespeak-lib 0.9.1-3
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 3,212 kB
  • ctags: 5,409
  • sloc: python: 33,390; ansic: 961; xml: 582; makefile: 90
file content (24 lines) | stat: -rw-r--r-- 815 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import py 
import __builtin__ as cpy_builtin

def invoke(assertion=False, compile=False):
    """ invoke magic, currently you can specify:

        assertion  patches the builtin AssertionError to try to give
                   more meaningful AssertionErrors, which by means
                   of deploying a mini-interpreter constructs
                   a useful error message.
    """
    if assertion:
        from py.__.magic import assertion
        assertion.invoke()
    if compile: 
        py.magic.patch(cpy_builtin, 'compile', py.code.compile )

def revoke(assertion=False, compile=False):
    """ revoke previously invoked magic (see invoke())."""
    if assertion:
        from py.__.magic import assertion
        assertion.revoke()
    if compile: 
        py.magic.revert(cpy_builtin, 'compile')