# -*- coding: utf-8 -*-
#
# Copyright 2016 SUSE LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import datetime


class CsvDBEntity(object):
    '''
    Serializable object for the table.
    '''
    def bind_table(self, table):
        self.__table = table

    def serialize(self):
        '''
        Serialize the object to a row for CSV.

        :return:
        '''


class CsvDB(object):
    '''
    File-based CSV database.
    This database is in-memory operating plain text csv files.
    '''
    def __init__(self, path):
        '''
        Constructor to store the database files.

        :param path:
        '''

    def _label(self):
        '''
        Create label of the database, based on the date-time.

        :return:
        '''

    def new(self):
        '''
        Create a new database.

        :return:
        '''

    def purge(self, dbid):
        '''
        Purge the database.

        :param dbid:
        :return:
        '''

    def list(self):
        '''
        List all the databases.

        :return:
        '''

    def open(self):
        '''
        Open database.

        :return:
        '''

    def close(self):
        '''
        Close the database.

        :return:
        '''

    def is_closed(self):
        '''
        Return if the database is closed.

        :return:
        '''
@@ -1301,32 +1301,45 @@
 e a new database
+ and opens it
 .%0A%0A        :retu
@@ -1347,32 +1347,272 @@
 n:%0A        '''%0A%0A
+    def get_tables(self):%0A        '''%0A        Get a list of existin tables in this database.%0A%0A        :return:%0A        '''%0A%0A    def add_table(self, table):%0A        '''%0A        Add table.%0A%0A        :param table:%0A        :return:%0A        '''%0A%0A
     def purge(se
@@ -1776,16 +1776,34 @@
 atabases
+ on the given path
 .%0A%0A     
@@ -1840,24 +1840,32 @@
 ef open(self
+, dbname
 ):%0A        '
@@ -1880,32 +1880,60 @@
    Open database
+ from the path with the name
 .%0A%0A        :retu
@@ -2129,28 +2129,638 @@
         :return:%0A        '''
+%0A%0A    def table_from_object(self, obj):%0A        '''%0A        Create a table from the object.%0A%0A        :param obj:%0A        :return:%0A        '''%0A%0A    def store(self, obj):%0A        '''%0A        Store an object in the table.%0A%0A        :param obj:%0A        :return:%0A        '''%0A%0A    def get(self, table_name, matches=None, mt=None, lt=None, eq=None):%0A        '''%0A        Get objects from the table.%0A%0A        :param table_name:%0A        :param matches: Regexp.%0A        :param mt: More than.%0A        :param lt: Less than.%0A        :param eq: Equals.%0A        :return:%0A        '''%0A        objects = %5B%5D%0A        return objects%0A

Update DB interface