<s> import pymongo <EOL> from . . utils import current_time <EOL> class PanMongo ( object ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , host = '<STR_LIT:localhost>' , port = <NUM_LIT> ) : <EOL> self . _client = pymongo . MongoClient ( host , port ) <EOL> collections = [ <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT:state>' , <EOL> '<STR_LIT:target>' , <EOL> '<STR_LIT>' , <EOL> ] <EOL> for collection in collections : <EOL> setattr ( self , collection , getattr ( self . _client . panoptes , '<STR_LIT>' . format ( collection ) ) ) <EOL> def insert_current ( self , collection , obj ) : <EOL> col = getattr ( self , collection ) <EOL> current_obj = { <EOL> '<STR_LIT:type>' : collection , <EOL> '<STR_LIT:data>' : obj , <EOL> '<STR_LIT:date>' : current_time ( utcnow = True ) , <EOL> } <EOL> self . current . replace_one ( { '<STR_LIT:type>' : collection } , current_obj , True ) <EOL> col . insert_one ( current_obj ) <EOL> def get_param ( self , key = None ) : <EOL> """<STR_LIT>""" <EOL> val = None <EOL> if key is not None : <EOL> param = self . _db . param_server . find_one ( { key : { '<STR_LIT>' : True } } ) <EOL> val = param . get ( key ) <EOL> return val </s>
