# Path: pymorphy/py3k.py
# PY3 = sys.version_info[0] == 3


from shelve import DbfilenameShelf
from struct import pack, unpack
from pymorphy.py3k import text_type, binary_type
import marshal
    import simplejson as json
    import json
try:
except ImportError:


def _to_utf8(s):
    if isinstance(s, binary_type):
        return s
    return s.encode('utf8')


def json_dumps(value):
    return json.dumps(value, ensure_ascii=False).encode('utf8')

class ShelfWithHooks(DbfilenameShelf):
    ''' Shelf class with key and value transform hooks. '''

    DUMP_METHODS = {
        'marshal': {
           'loads': marshal.loads,
           'dumps': marshal.dumps
        },
        'json':  {
           'loads': json.loads,
           'dumps': json_dumps
        },
    }

    KEY_TRANSFORM_METHODS = {
        'unicode': {
             'encode': lambda key: text_type(key),#.encode('utf8'),

# Path: pymorphy/py3k.py
# PY3 = sys.version_info[0] == 3


# Path: pymorphy/backends/shelve_source/shelf_with_hooks.py
from shelve import DbfilenameShelf
from struct import pack, unpack
from pymorphy.py3k import text_type, binary_type
import marshal
    import simplejson as json
    import json

try:
except ImportError:


def _to_utf8(s):
    if isinstance(s, binary_type):
        return s
    return s.encode('utf8')


def json_dumps(value):
    return json.dumps(value, ensure_ascii=False).encode('utf8')

class ShelfWithHooks(DbfilenameShelf):
    ''' Shelf class with key and value transform hooks. '''

    DUMP_METHODS = {
        'marshal': {
           'loads': marshal.loads,
           'dumps': marshal.dumps
        },
        'json':  {
           'loads': json.loads,
           'dumps': json_dumps
        },
    }

    KEY_TRANSFORM_METHODS = {
        'unicode': {
             'encode': lambda key: text_type(key),#.encode('utf8'),

             'decode': lambda key: text_type(key),#, 'utf8'),