예제 #1
0
    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 = {}
예제 #2
0
 def record_model(self, model):
     """Record the given model."""
     DataConnector.record_model(self, model)
     name = DataConnector.record_model(self, model)
     self.collections[name] = self.datas[name]
     self.inc_collections[name] = self.increments[name]
     self.object_ids[name] = {}
예제 #3
0
파일: __init__.py 프로젝트: Erwyn/pa-poc1
 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 = {}
예제 #4
0
 def clear(self):
     """Clear the stored datas."""
     for name in self.models.keys():
         self.datas[name].remove()
         self.datas.drop_collection(name)
         self.increments[name].remove({})
         self.increments.drop_collection(name)
     DataConnector.clear(self)
예제 #5
0
파일: __init__.py 프로젝트: Erwyn/pa-poc1
 def record_tables(self, classes):
     """Record the tables."""
     cursor = self.connection.cursor()
     cursor.execute("SELECT name FROM sqlite_master WHERE type='table'")
     tables = [row[0] for row in cursor.fetchall()]
     self.created_tables = tuple(tables)
     DataConnector.record_tables(self, classes)
     self.connection.commit()
예제 #6
0
파일: __init__.py 프로젝트: Erwyn/pa-poc1
 def record_tables(self, classes):
     """Record the tables."""
     cursor = self.connection.cursor()
     cursor.execute("SELECT name FROM sqlite_master WHERE type='table'")
     tables = [row[0] for row in cursor.fetchall()]
     self.created_tables = tuple(tables)
     DataConnector.record_tables(self, classes)
     self.connection.commit()
예제 #7
0
    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"
예제 #8
0
파일: __init__.py 프로젝트: Erwyn/pa-poc1
 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)
예제 #9
0
파일: __init__.py 프로젝트: Erwyn/pa-poc1
    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)
예제 #10
0
    def record_model(self, model):
        """Record the given model."""
        name = DataConnector.record_model(self, model)
        filename = self.location + "/" + name + ".yml"
        if os.path.exists(filename):
            with open(filename, "r") as file:
                self.read_table(name, file)

        self.files[name] = filename
예제 #11
0
파일: __init__.py 프로젝트: Erwyn/pa-poc1
 def record_model(self, model):
     """Record the given model."""
     name = DataConnector.record_model(self, model)
     filename = self.location + "/" + name + ".yml"
     if os.path.exists(filename):
         with open(filename, "r") as file:
             self.read_table(name, file)
     
     self.files[name] = filename
예제 #12
0
파일: __init__.py 프로젝트: Erwyn/pa-poc1
 def record_model(self, model):
     """Record a single model."""
     DataConnector.record_model(self, model)
     name = get_plural_name(model)
     if name not in self.created_tables:
         self.create_table(name, model)
예제 #13
0
파일: __init__.py 프로젝트: Erwyn/pa-poc1
 def record_model(self, model):
     """Record a single model."""
     DataConnector.record_model(self, model)
     name = get_plural_name(model)
     if name not in self.created_tables:
         self.create_table(name, model)