<s> """<STR_LIT>""" <EOL> from pyrseas . augment import DbAugmentDict , DbAugment <EOL> from pyrseas . dbobject import split_schema_obj <EOL> from pyrseas . dbobject . trigger import Trigger <EOL> class CfgTrigger ( DbAugment ) : <EOL> "<STR_LIT>" <EOL> keylist = [ '<STR_LIT:name>' ] <EOL> def apply ( self , table ) : <EOL> """<STR_LIT>""" <EOL> newtrg = Trigger ( schema = table . schema , table = table . name , <EOL> ** self . __dict__ ) <EOL> if newtrg . name . startswith ( '<STR_LIT>' ) : <EOL> newtrg . name = newtrg . name . replace ( newtrg . name [ : <NUM_LIT> ] , table . name ) <EOL> newtrg . _table = table <EOL> if not hasattr ( table , '<STR_LIT>' ) : <EOL> table . triggers = { } <EOL> if hasattr ( newtrg , '<STR_LIT>' ) : <EOL> if newtrg . procedure . startswith ( '<STR_LIT>' ) : <EOL> newtrg . procedure = newtrg . procedure . replace ( <EOL> newtrg . procedure [ : <NUM_LIT> ] , table . name ) <EOL> ( sch , fnc ) = split_schema_obj ( newtrg . procedure ) <EOL> if sch != table . schema : <EOL> newtrg . procedure = "<STR_LIT>" % ( table . schema , fnc ) <EOL> table . triggers . update ( { newtrg . name : newtrg } ) <EOL> class CfgTriggerDict ( DbAugmentDict ) : <EOL> "<STR_LIT>" <EOL> cls = CfgTrigger <EOL> def __init__ ( self , config ) : <EOL> """<STR_LIT>""" <EOL> for trg in config : <EOL> self [ trg ] = CfgTrigger ( ** config [ trg ] ) <EOL> def from_map ( self , intrigs ) : <EOL> """<STR_LIT>""" <EOL> for trg in intrigs : <EOL> if trg in self : <EOL> ctrg = self [ trg ] <EOL> else : <EOL> self [ trg ] = ctrg = CfgTrigger ( name = trg ) <EOL> for attr , val in list ( intrigs [ trg ] . items ( ) ) : <EOL> setattr ( ctrg , attr , val ) </s>
