# 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

    def set_connector(self, path, *args, **kwargs):
        kwargs.update({'create_if_missing': True})

        try:
            self._connector = plyvel.DB(path, *args, **kwargs)
        except CorruptionError as e:
            errors_logger.exception(e.message)

    def mount(self):
        if self.status is self.STATUS.UNMOUNTED:
            self.set_connector(self.path)

            if self.connector is None:
                return failure(DATABASE_ERROR, "Database %s could not be mounted" % self.path)

            self.status = self.STATUS.MOUNTED
        else:
            return failure(DATABASE_ERROR, "Database %r already mounted" % self.path)

        return success()

    def umount(self):
        if self.status is self.STATUS.MOUNTED:
            self.status = self.STATUS.UNMOUNTED
            del self._connector
            self._connector = None
        else:
            return failure(DATABASE_ERROR, "Database %r already unmounted" % self.name)


# 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


    def set_connector(self, path, *args, **kwargs):
        kwargs.update({'create_if_missing': True})

        try:
            self._connector = plyvel.DB(path, *args, **kwargs)
        except CorruptionError as e:
            errors_logger.exception(e.message)

    def mount(self):
        if self.status is self.STATUS.UNMOUNTED:
            self.set_connector(self.path)

            if self.connector is None:
                return failure(DATABASE_ERROR, "Database %s could not be mounted" % self.path)

            self.status = self.STATUS.MOUNTED
        else:
            return failure(DATABASE_ERROR, "Database %r already mounted" % self.path)

        return success()

    def umount(self):
        if self.status is self.STATUS.MOUNTED:
            self.status = self.STATUS.UNMOUNTED
            del self._connector
            self._connector = None
        else:
            return failure(DATABASE_ERROR, "Database %r already unmounted" % self.name)


        return success()