def as_ctrait ( self ):
        """ Returns a CTrait corresponding to the trait defined by this class.
        """
        from .traits import CTrait

        metadata = getattr( self, '_metadata', {} )
        getter   = getattr( self, 'get', None )
        setter   = getattr( self, 'set', None )
        if (getter is not None) or (setter is not None):
            if getter is None:
                getter = _write_only
                metadata.setdefault( 'transient', True )
            elif setter is None:
                setter = _read_only
                metadata.setdefault( 'transient', True )
            trait    = CTrait( 4 )
            n        = 0
            validate = getattr( self, 'validate', None )
            if validate is not None:
                n = _arg_count( validate )
            trait.property( getter,   _arg_count( getter ),
                            setter,   _arg_count( setter ),
                            validate, n )
            metadata.setdefault( 'type', 'property' )
        else:
            type = getattr( self, 'ctrait_type', None )
            if type is None:
                type = trait_types.get( metadata.get( 'type' ), 0 )
            trait = CTrait( type )

            validate = getattr( self, 'fast_validate', None )
            if validate is None:
                validate = getattr( self, 'validate', None )
                if validate is None:
                    validate = getattr( self, 'is_valid_for', None )
                    if validate is not None:
                        validate = self._is_valid_for
                    else:
                        validate = getattr( self, 'value_for', None )
                        if validate is not None:
                            validate = self._value_for

            if validate is not None:
                trait.set_validate( validate )

            post_setattr = getattr( self, 'post_setattr', None )
            if post_setattr is not None:
                trait.post_setattr = post_setattr
                trait.is_mapped( self.is_mapped )

            # Note: The use of 'rich_compare' metadata is deprecated; use
            # 'comparison_mode' metadata instead:
            rich_compare = metadata.get( 'rich_compare' )
            if rich_compare is not None:
                trait.rich_comparison( rich_compare in True )

            comparison_mode = metadata.get( 'comparison_mode' )
            if comparison_mode is not None:
                trait.comparison_mode( comparison_mode )

            metadata.setdefault( 'type', 'trait' )

        trait.default_value( *self.get_default_value() )

        trait.value_allowed( metadata.get( 'trait_value', False ) is True )

        trait.handler = self

        trait.__dict__ = metadata.copy()

        return trait
dataset/ETHPy150Open enthought/traits/traits/trait_handlers.py/TraitType.as_ctrait/operator `is` -> `in`