<s> """<STR_LIT>""" <EOL> from pyrseas . database import Database <EOL> from pyrseas . dbobject . language import Language <EOL> from pyrseas . augment . schema import AugSchemaDict <EOL> from pyrseas . augment . table import AugClassDict <EOL> from pyrseas . augment . column import CfgColumnDict <EOL> from pyrseas . augment . function import CfgFunctionDict , CfgFunctionSourceDict <EOL> from pyrseas . augment . trigger import CfgTriggerDict <EOL> from pyrseas . augment . audit import CfgAuditColumnDict <EOL> def cfg_section ( config , section ) : <EOL> "<STR_LIT>" <EOL> return config [ section ] if section in config else { } <EOL> class AugmentDatabase ( Database ) : <EOL> """<STR_LIT>""" <EOL> class AugDicts ( object ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , config ) : <EOL> """<STR_LIT>""" <EOL> self . schemas = AugSchemaDict ( ) <EOL> self . tables = AugClassDict ( ) <EOL> self . columns = CfgColumnDict ( cfg_section ( config , '<STR_LIT>' ) ) <EOL> self . funcsrcs = CfgFunctionSourceDict ( <EOL> cfg_section ( config , '<STR_LIT>' ) ) <EOL> self . functions = CfgFunctionDict ( cfg_section ( config , '<STR_LIT>' ) ) <EOL> self . triggers = CfgTriggerDict ( cfg_section ( config , '<STR_LIT>' ) ) <EOL> self . auditcols = CfgAuditColumnDict ( <EOL> cfg_section ( config , '<STR_LIT>' ) ) <EOL> def _link_refs ( self ) : <EOL> """<STR_LIT>""" <EOL> self . schemas . link_refs ( self . tables ) <EOL> def _link_current ( self , db ) : <EOL> """<STR_LIT>""" <EOL> self . current = db <EOL> self . schemas . link_current ( db . schemas ) <EOL> self . tables . link_current ( db . tables ) <EOL> def add_func ( self , schema , function ) : <EOL> """<STR_LIT>""" <EOL> if schema in self . schemas : <EOL> self . schemas [ schema ] . add_func ( function ) <EOL> elif schema in self . current . schemas : <EOL> sch = self . current . schemas [ schema ] <EOL> if not hasattr ( sch , '<STR_LIT>' ) : <EOL> sch . functions = { } <EOL> if function . name not in sch . functions : <EOL> sch . functions . update ( { function . name : function } ) <EOL> def add_lang ( self , lang ) : <EOL> """<STR_LIT>""" <EOL> if lang not in self . current . languages : <EOL> self . current . languages [ lang ] = Language ( name = lang ) <EOL> def from_augmap ( self , aug_map ) : <EOL> """<STR_LIT>""" <EOL> self . adb = self . AugDicts ( cfg_section ( self . config , '<STR_LIT>' ) ) <EOL> aug_schemas = { } <EOL> for key in aug_map : <EOL> if key == '<STR_LIT>' : <EOL> self . _from_cfgmap ( aug_map [ key ] ) <EOL> elif key . startswith ( '<STR_LIT>' ) : <EOL> aug_schemas . update ( { key : aug_map [ key ] } ) <EOL> else : <EOL> raise KeyError ( "<STR_LIT>" % key ) <EOL> self . adb . schemas . from_map ( aug_schemas , self . adb ) <EOL> self . adb . _link_refs ( ) <EOL> self . adb . _link_current ( self . db ) <EOL> def _from_cfgmap ( self , cfg_map ) : <EOL> """<STR_LIT>""" <EOL> for key in cfg_map : <EOL> if key == '<STR_LIT>' : <EOL> self . adb . columns . from_map ( cfg_map [ key ] ) <EOL> elif key in [ '<STR_LIT>' , '<STR_LIT>' ] : <EOL> self . adb . funcsrcs . from_map ( cfg_map [ key ] ) <EOL> elif key == '<STR_LIT>' : <EOL> self . adb . functions . from_map ( cfg_map [ key ] ) <EOL> elif key == '<STR_LIT>' : <EOL> self . adb . triggers . from_map ( cfg_map [ key ] ) <EOL> elif key == '<STR_LIT>' : <EOL> self . adb . auditcols . from_map ( cfg_map [ key ] ) <EOL> else : <EOL> raise KeyError ( "<STR_LIT>" % key ) <EOL> def apply ( self , aug_map ) : <EOL> """<STR_LIT>""" <EOL> if not self . db : <EOL> self . from_catalog ( ) <EOL> self . from_augmap ( aug_map ) <EOL> for sch in self . adb . schemas : <EOL> self . adb . schemas [ sch ] . apply ( self . adb ) <EOL> return self . to_map ( ) </s>
