<s> """<STR_LIT>""" <EOL> from __future__ import absolute_import <EOL> from . . import util , log <EOL> from . . sql import expression <EOL> from . import attributes <EOL> from . util import _orm_full_deannotate <EOL> from . interfaces import PropComparator , StrategizedProperty <EOL> __all__ = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' ] <EOL> @ log . class_logger <EOL> class ColumnProperty ( StrategizedProperty ) : <EOL> """<STR_LIT>""" <EOL> strategy_wildcard_key = '<STR_LIT>' <EOL> def __init__ ( self , * columns , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> self . _orig_columns = [ expression . _labeled ( c ) for c in columns ] <EOL> self . columns = [ expression . _labeled ( _orm_full_deannotate ( c ) ) <EOL> for c in columns ] <EOL> self . group = kwargs . pop ( '<STR_LIT>' , None ) <EOL> self . deferred = kwargs . pop ( '<STR_LIT>' , False ) <EOL> self . instrument = kwargs . pop ( '<STR_LIT>' , True ) <EOL> self . comparator_factory = kwargs . pop ( '<STR_LIT>' , <EOL> self . __class__ . Comparator ) <EOL> self . descriptor = kwargs . pop ( '<STR_LIT>' , None ) <EOL> self . extension = kwargs . pop ( '<STR_LIT>' , None ) <EOL> self . active_history = kwargs . pop ( '<STR_LIT>' , False ) <EOL> self . expire_on_flush = kwargs . pop ( '<STR_LIT>' , True ) <EOL> if '<STR_LIT:info>' in kwargs : <EOL> self . info = kwargs . pop ( '<STR_LIT:info>' ) <EOL> if '<STR_LIT>' in kwargs : <EOL> self . doc = kwargs . pop ( '<STR_LIT>' ) <EOL> else : <EOL> for col in reversed ( self . columns ) : <EOL> doc = getattr ( col , '<STR_LIT>' , None ) <EOL> if doc is not None : <EOL> self . doc = doc <EOL> break <EOL> else : <EOL> self . doc = None <EOL> if kwargs : <EOL> raise TypeError ( <EOL> "<STR_LIT>" % ( <EOL> self . __class__ . __name__ , <EOL> '<STR_LIT:U+002CU+0020>' . join ( sorted ( kwargs . keys ( ) ) ) ) ) <EOL> util . set_creation_order ( self ) <EOL> self . strategy_class = self . _strategy_lookup ( <EOL> ( "<STR_LIT>" , self . deferred ) , <EOL> ( "<STR_LIT>" , self . instrument ) <EOL> ) <EOL> @ property <EOL> def expression ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . columns [ <NUM_LIT:0> ] <EOL> def instrument_class ( self , mapper ) : <EOL> if not self . instrument : <EOL> return <EOL> attributes . register_descriptor ( <EOL> mapper . class_ , <EOL> self . key , <EOL> comparator = self . comparator_factory ( self , mapper ) , <EOL> parententity = mapper , <EOL> doc = self . doc <EOL> ) <EOL> def do_init ( self ) : <EOL> super ( ColumnProperty , self ) . do_init ( ) <EOL> if len ( self . columns ) > <NUM_LIT:1> and set ( self . parent . primary_key ) . issuperset ( self . columns ) : <EOL> util . warn ( <EOL> ( "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) % ( self . parent , self . columns [ <NUM_LIT:1> ] , <EOL> self . columns [ <NUM_LIT:0> ] , self . key ) ) <EOL> def copy ( self ) : <EOL> return ColumnProperty ( <EOL> deferred = self . deferred , <EOL> group = self . group , <EOL> active_history = self . active_history , <EOL> * self . columns ) <EOL> def _getcommitted ( self , state , dict_ , column , <EOL> passive = attributes . PASSIVE_OFF ) : <EOL> return state . get_impl ( self . key ) . get_committed_value ( state , dict_ , passive = passive ) <EOL> def merge ( self , session , source_state , source_dict , dest_state , <EOL> dest_dict , load , _recursive ) : <EOL> if not self . instrument : <EOL> return <EOL> elif self . key in source_dict : <EOL> value = source_dict [ self . key ] <EOL> if not load : <EOL> dest_dict [ self . key ] = value <EOL> else : <EOL> impl = dest_state . get_impl ( self . key ) <EOL> impl . set ( dest_state , dest_dict , value , None ) <EOL> elif dest_state . has_identity and self . key not in dest_dict : <EOL> dest_state . _expire_attributes ( dest_dict , [ self . key ] ) <EOL> class Comparator ( PropComparator ) : <EOL> """<STR_LIT>""" <EOL> @ util . memoized_instancemethod <EOL> def __clause_element__ ( self ) : <EOL> if self . adapter : <EOL> return self . adapter ( self . prop . columns [ <NUM_LIT:0> ] ) <EOL> else : <EOL> return self . prop . columns [ <NUM_LIT:0> ] . _annotate ( { <EOL> "<STR_LIT>" : self . _parentmapper , <EOL> "<STR_LIT>" : self . _parentmapper } ) <EOL> @ util . memoized_property <EOL> def info ( self ) : <EOL> ce = self . __clause_element__ ( ) <EOL> try : <EOL> return ce . info <EOL> except AttributeError : <EOL> return self . prop . info <EOL> def __getattr__ ( self , key ) : <EOL> """<STR_LIT>""" <EOL> return getattr ( self . __clause_element__ ( ) , key ) <EOL> def operate ( self , op , * other , ** kwargs ) : <EOL> return op ( self . __clause_element__ ( ) , * other , ** kwargs ) <EOL> def reverse_operate ( self , op , other , ** kwargs ) : <EOL> col = self . __clause_element__ ( ) <EOL> return op ( col . _bind_param ( op , other ) , col , ** kwargs ) <EOL> def __str__ ( self ) : <EOL> return str ( self . parent . class_ . __name__ ) + "<STR_LIT:.>" + self . key </s>
