# 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
# -*- coding: utf-8 -*-

# Copyright (c) 2012 theo crevon
#
# See the file LICENSE for copying permission.





activity_logger = logging.getLogger("activity_logger")
errors_logger = logging.getLogger("errors_logger")


class DatabaseOptions(dict):
    def __init__(self, *args, **kwargs):
        self['create_if_missing'] = True
        self['error_if_exists'] = False
        self['bloom_filter_bits'] = 10  # Value recommended by leveldb doc
        self['paranoid_checks'] = False
        self['lru_cache_size'] = 512 * (1 << 20)  # 512 Mo
        self['write_buffer_size'] = 4 * (1 << 20)  # 4 Mo

# 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

# -*- coding: utf-8 -*-

# Copyright (c) 2012 theo crevon
#
# See the file LICENSE for copying permission.





activity_logger = logging.getLogger("activity_logger")
errors_logger = logging.getLogger("errors_logger")


class DatabaseOptions(dict):
    def __init__(self, *args, **kwargs):
        self['create_if_missing'] = True
        self['error_if_exists'] = False
        self['bloom_filter_bits'] = 10  # Value recommended by leveldb doc
        self['paranoid_checks'] = False
        self['lru_cache_size'] = 512 * (1 << 20)  # 512 Mo
        self['write_buffer_size'] = 4 * (1 << 20)  # 4 Mo

        self['block_size'] = 4096