
    W                     p    S SK r S SKrS SKJrJrJr  S SKJr  Sr\" S\S9r	S\	S\	4S	 jr
S
 rS rS rS rg)    N)ListTupleTypeVar)FunctionTypez3.1.0_WrappedMethod)boundmethodreturnc                    [        U SS5        [        [        R                  " S5      U R                  5       H  n[        XR                  5      (       d  M  [        XR                  5      n[        US5      (       a+  [        US5      nU(       a  [        SU R                  -  5      eU R                  (       d  UR                  U l	        U s  $    [        SU R                  -  5      e)a  Decorator to indicate that the decorated method overrides a method in
superclass.
The decorator code is executed while loading class. Using this method
should have minimal runtime performance implications.

This is based on my idea about how to do this and fwc:s highly improved
algorithm for the implementation fwc:s
algorithm : http://stackoverflow.com/a/14631397/308189
my answer : http://stackoverflow.com/a/8313042/308189

How to use:
from overrides import overrides

class SuperClass(object):
    def method(self):
      return 2

class SubClass(SuperClass):

    @overrides
    def method(self):
        return 1

:raises  AssertionError if no match in super classes for the method name
:return  method with possibly added (if the method doesn't have one)
    docstring from super class
__override__T   __finalized__zMethod "%s" is finalizedz$No super class method found for "%s")
setattr_get_base_classessys	_getframe__globals__hasattr__name__getattrAssertionError__doc__)r	   super_classsuper_method	finalizeds       &lib/third_party/overrides/overrides.py	overridesr      s    8 FND)(q)96;M;MN;00";@L|_55#L/B	()Cfoo)UVV>>!-!5!5M O ?&//Q
RR    c                 V    [        U 5       Vs/ s H  n[        X!5      PM     sn$ s  snf )N)_get_base_class_names_get_base_class)frame	namespaceclass_name_componentss      r   r   r   F   s5     &;5%A%A! 	-9%A  s   &c              #      ^ ^#    S/mU U4S jnSnTS   U::  aB  U" 5       U" 5       pTU[         R                  :X  a  X5-  nUS-  nM5  XEU-   4v   SnTS   U::  a  MA  gg7f)zUGenerator function: convert Python bytecode into a sequence of
opcode-argument pairs.r   c                  2   > TTS      n TS==   S-  ss'   U $ )Nr       )valcodeis    r   nextop_stream.<locals>.nextR   s"    1Q4j	!	
r      N)disEXTENDED_ARG)r*   maxr,   ext_argopargr+   s   `     @r   	op_streamr5   M   sq      
A
 G
A$#+&$&C!!!NGMGW}%%G A$#+s   AAAc                    U R                   U R                  p!UR                  n/ nSn[        X25       H  u  pgU[        R
                  ;   d  M  U(       d  / n[        R                  U   S:X  a$  UR                  SUR                  U   45        SnM_  [        R                  U   S:X  a$  UR                  SUR                  U   45        SnM  [        R                  U   S:X  a$  UR                  SUR                  U   45        SnM  SnM     / n/ n	U H-  u  pU
S:X  a  U	(       a  UR                  U	5        U/n	M(  X/-  n	M/     U	(       a  UR                  U	5        U$ )z)Get baseclass names from the code object F	LOAD_NAMEnameT	LOAD_ATTRattrLOAD_GLOBAL)	f_codef_lastico_coder5   r/   hasnameopnameappendco_names)r"   colastir*   extendsadd_last_stepr3   opargitemsprevious_itemtss               r   r    r    c   s0   emm::DGM - zz"~,E(:;< $B;.E(:;< $B=0E(:;< $ % .  EM;]+CMS M  ]#Lr   c                      XS      nU SS   H   n[	        X#5      (       d  M  [        X#5      nM"     U$ ! [          a:    [        US   [        5      (       a  US   U S      n NZ[        US   U S   5      n Nnf = f)Nr   __builtins__r'   )KeyError
isinstancedictr   r   )
componentsr#   obj	components       r   r!   r!      s    D1&  ^	3""#)C $ J  Di/66N+JqM:C)N3Z]CC	Ds   4 -A8#A87A8)r   r/   typingr   r   r   typesr   __VERSION__r   r   r   r5   r    r!   r(   r   r   <module>rW      sV   "  
 ' '  )>'Sn 'S 'ST,"Jr   