# Path: elevator/constants.py
# OS_ERROR = 5
# 
# DATABASE_ERROR = 6
# 
# Path: elevator/utils/patterns.py
# def enum(*sequential, **named):
#     enums = dict(zip(sequential, range(len(sequential))), **named)
#     return type('Enum', (), enums)
# 
# Path: elevator/helpers/internals.py
# def failure(err_code, err_msg):
#     """Returns a formatted error status and content"""
#     return (FAILURE_STATUS, [err_code, err_msg])
# 
# def success(content=None):
#     """Returns a formatted success status and content"""
#     return (SUCCESS_STATUS, content)


import os
import uuid
import logging
import plyvel
import ujson as json
from shutil import rmtree
from plyvel import CorruptionError
from .constants import OS_ERROR, DATABASE_ERROR
from .utils.patterns import enum
from .helpers.internals import failure, success
        database = Database(db_name,
                            path,
                            db_options,
                            status=Database.STATUS.MOUNTED,
                            init_connector=True)

        # Adding db to store, and updating handler
        uid = str(uuid.uuid4())
        self.index['name_to_uid'].update({db_name: uid})
        self.store_update(db_name, {
            'path': path,
            'uid': uid,
            'options': db_options,
        })
        self.update({uid: database})

        return success()

    def drop(self, db_name):
        """Drops a db from the DatabasesHandler, and sync it
        to store file"""
        db_uid = self.index['name_to_uid'].pop(db_name)
        db_path = self[db_uid].path

        self.pop(db_uid)
        self.store_remove(db_name)

        try:
            rmtree(db_path)
        except OSError:

# Path: elevator/constants.py
# OS_ERROR = 5
# 
# DATABASE_ERROR = 6
# 
# Path: elevator/utils/patterns.py
# def enum(*sequential, **named):
#     enums = dict(zip(sequential, range(len(sequential))), **named)
#     return type('Enum', (), enums)
# 
# Path: elevator/helpers/internals.py
# def failure(err_code, err_msg):
#     """Returns a formatted error status and content"""
#     return (FAILURE_STATUS, [err_code, err_msg])
# 
# def success(content=None):
#     """Returns a formatted success status and content"""
#     return (SUCCESS_STATUS, content)


# Path: elevator/db.py
import os
import uuid
import logging
import plyvel
import ujson as json
from shutil import rmtree
from plyvel import CorruptionError
from .constants import OS_ERROR, DATABASE_ERROR
from .utils.patterns import enum
from .helpers.internals import failure, success

        database = Database(db_name,
                            path,
                            db_options,
                            status=Database.STATUS.MOUNTED,
                            init_connector=True)

        # Adding db to store, and updating handler
        uid = str(uuid.uuid4())
        self.index['name_to_uid'].update({db_name: uid})
        self.store_update(db_name, {
            'path': path,
            'uid': uid,
            'options': db_options,
        })
        self.update({uid: database})

        return success()

    def drop(self, db_name):
        """Drops a db from the DatabasesHandler, and sync it
        to store file"""
        db_uid = self.index['name_to_uid'].pop(db_name)
        db_path = self[db_uid].path

        self.pop(db_uid)
        self.store_remove(db_name)

        try:
            rmtree(db_path)
        except OSError:

            return failure(DATABASE_ERROR, "Cannot drop db : %s, files not found")