"Fossies" - the Fresh Open Source Software Archive

Member "reportlab-3.5.23/src/rl_addons/rl_accel/tests/getrc.py" (14 Mar 2013, 669 Bytes) of package /linux/privat/reportlab-3.5.23.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Python source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file.

    1 def getrc(defns,depth=1):
    2     from sys import getrefcount, _getframe
    3     f = _getframe(depth)
    4     G0 = f.f_globals
    5     L = f.f_locals
    6     if L is not G0:
    7         LL = [L]
    8         while 1:
    9             f = f.f_back
   10             G = f.f_globals
   11             L = f.f_locals
   12             if G is not G0 or G is L: break
   13             LL.append(L)
   14         L = {}
   15         for l in reversed(LL):
   16             L.update(l)
   17     else:
   18         L = L.copy()
   19     G0 = G0.copy()
   20     return [getrefcount(eval(x,L,G0))-1 for x in defns.split()]
   21 
   22 def checkrc(defns,rcv0):
   23     rcv1 = getrc(defns,2)
   24     return ' '.join(["%s %d-->%d" % (x,v,w) for x,v,w in zip(defns.split(),rcv0,rcv1) if v!=w])