<s> __author__ = """<STR_LIT>""" <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> from os import getcwd <EOL> from os import sys <EOL> sys . path . append ( getcwd ( ) ) <EOL> from MOAL . helpers . display import Section <EOL> from MOAL . helpers . display import divider <EOL> DEBUG = True if __name__ == '<STR_LIT:__main__>' else False <EOL> """<STR_LIT>""" <EOL> class PostgresSQLAdapter : <EOL> def conn ( self ) : <EOL> print ( '<STR_LIT>' ) <EOL> return self <EOL> def cursor ( self ) : <EOL> print ( '<STR_LIT>' ) <EOL> return self <EOL> def execute ( self , sql ) : <EOL> print ( '<STR_LIT>' . format ( sql ) ) <EOL> return self <EOL> def commit ( self ) : <EOL> pass <EOL> class MongoAdapter : <EOL> def collections ( self ) : <EOL> def get ( pk ) : <EOL> print ( '<STR_LIT>' . format ( pk ) ) <EOL> return { '<STR_LIT>' : get } <EOL> class ConnectionMixin : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self ) : <EOL> self . db = { '<STR_LIT:name>' : None , '<STR_LIT>' : None } <EOL> def set_adapter ( self , name ) : <EOL> self . db [ '<STR_LIT:name>' ] = name <EOL> if self . db [ '<STR_LIT:name>' ] == '<STR_LIT>' : <EOL> self . db [ '<STR_LIT>' ] = MongoAdapter ( ) <EOL> elif self . db [ '<STR_LIT:name>' ] == '<STR_LIT>' : <EOL> self . db [ '<STR_LIT>' ] = PostgresSQLAdapter ( ) <EOL> def get ( self , pk ) : <EOL> if self . db [ '<STR_LIT:name>' ] == '<STR_LIT>' : <EOL> collections = self . db [ '<STR_LIT>' ] . collections ( ) <EOL> return collections [ '<STR_LIT>' ] ( pk ) <EOL> elif self . db [ '<STR_LIT:name>' ] == '<STR_LIT>' : <EOL> sql = """<STR_LIT>""" . format ( pk ) <EOL> self . db [ '<STR_LIT>' ] . conn ( ) . cursor ( ) . execute ( sql ) . commit ( ) <EOL> class Document ( ConnectionMixin ) : <EOL> pass <EOL> if DEBUG : <EOL> with Section ( '<STR_LIT>' ) : <EOL> doc = Document ( ) <EOL> doc . set_adapter ( '<STR_LIT>' ) <EOL> doc . get ( <NUM_LIT> ) <EOL> divider ( newline = False ) <EOL> doc . set_adapter ( '<STR_LIT>' ) <EOL> doc . get ( <NUM_LIT> ) </s>
