AlkantarClanX12
Current Path : /usr/lib64/python2.7/Demo/newmetaclasses/ |
Current File : //usr/lib64/python2.7/Demo/newmetaclasses/Enum.pyc |
� ��^c @ s� d Z d e f d � � YZ d e f d � � YZ d e f d � � YZ d d d � � YZ d d d � � YZ d � Z d � Z e d k r� e � e � n d S( s Enumeration metaclass.t EnumMetaclassc B s) e Z d Z d � Z d � Z d � Z RS( sg Metaclass for enumeration. To define your own enumeration, do something like class Color(Enum): red = 1 green = 2 blue = 3 Now, Color.red, Color.green and Color.blue behave totally different: they are enumerated values, not integers. Enumerations cannot be instantiated; however they can be subclassed. c C s� t t | � j | | | � g | _ xk | j � D]] } | j d � oS | j d � s2 t | | | | � } t | | | � | j j | � q2 q2 Wd S( Nt __( t superR t __init__t _memberst keyst startswitht endswitht EnumInstancet setattrt append( t clst namet basest dictt attrt enumval( ( s0 /usr/lib64/python2.7/Demo/newmetaclasses/Enum.pyR s c C s | d k r | j St | � d S( Nt __members__( R t AttributeError( R R ( ( s0 /usr/lib64/python2.7/Demo/newmetaclasses/Enum.pyt __getattr__ s c C s� d } } g | j D]* } t | t � r | t k r | j ^ q } | r` d d j | � } n g | j D] } d | t | | � f ^ qj } | r� d d j | � } n d | j | | f S( Nt s (%s)s , s %s: %ds : {%s}s %s%s%s( t __bases__t isinstanceR t Enumt __name__t joinR t getattr( R t s1t s2t baset enumbasest valt enumvalues( ( s0 /usr/lib64/python2.7/Demo/newmetaclasses/Enum.pyt __repr__"