def setup(self, location=None): """Setup the data connector.""" if location is None: raise exceptions.InsufficientConfiguration( "the location for storing datas was not specified for " \ "the YAML data connector") location = location.replace("\\", "/") if location.startswith("~"): location = os.path.expanduser("~") + location[1:] if location.endswith("/"): location = location[:-1] if not os.path.exists(location): # Try to create it os.makedirs(location) if not os.access(location, os.R_OK): raise exceptions.DriverInitializationError( "cannot read in {}".format(location)) if not os.access(location, os.W_OK): raise exceptions.DriverInitializationError( "cannot write in {}".format(location)) DataConnector.__init__(self) self.location = location self.files = {}
def __init__(self): """Check the driver presence. If not found, raise a DriverNotFound exception. """ if not driver: raise exceptions.DriverNotFound( "the pymongo library can not be found") DataConnector.__init__(self) self.db_name = "datas" self.inc_name = "increments"
def setup(self, location=None): """Setup the data connector.""" if location is None: raise exceptions.InsufficientConfiguration( "the location for storing datas was not specified for " \ "the sqlite3 data connector") location = location.replace("\\", "/") if location.startswith("~"): location = os.path.expanduser("~") + location[1:] DataConnector.__init__(self) self.location = location self.connection = sqlite3.connect(self.location)