<s> import imp <EOL> import os <EOL> import sys <EOL> from dbconstants import * <EOL> sys . path . append ( os . path . join ( os . path . dirname ( __file__ ) , "<STR_LIT>" ) ) <EOL> import constants <EOL> DB_ERROR = "<STR_LIT>" <EOL> ERROR_CODES = [ DB_ERROR ] <EOL> DATASTORE_DIR = "<STR_LIT>" % constants . APPSCALE_HOME <EOL> class DatastoreFactory : <EOL> @ classmethod <EOL> def getDatastore ( cls , d_type ) : <EOL> datastore = None <EOL> d_name = "<STR_LIT>" + d_type <EOL> mod_path = DATASTORE_DIR + "<STR_LIT:/>" + d_type + "<STR_LIT:/>" + d_name + "<STR_LIT>" <EOL> if os . path . exists ( mod_path ) : <EOL> sys . path . append ( DATASTORE_DIR + "<STR_LIT:/>" + d_type ) <EOL> d_mod = imp . load_source ( d_name , mod_path ) <EOL> datastore = d_mod . DatastoreProxy ( ) <EOL> else : <EOL> raise Exception ( "<STR_LIT>" + "<STR_LIT>" % ( DATASTORE_DIR , d_type ) ) <EOL> return datastore <EOL> @ classmethod <EOL> def valid_datastores ( cls ) : <EOL> dblist = os . listdir ( DATASTORE_DIR ) <EOL> return dblist <EOL> @ classmethod <EOL> def error_codes ( cls ) : <EOL> return ERROR_CODES </s>
