# Path: pydal/_compat.py
# PY2 = sys.version_info[0] == 2
#     def implements_bool(cls):
#     def implements_iterator(cls):
#     def to_bytes(obj, charset="utf-8", errors="strict"):
#     def to_native(obj, charset="utf8", errors="strict"):
#     def to_bytes(obj, charset="utf-8", errors="strict"):
#     def to_native(obj, charset="utf8", errors="strict"):
# def with_metaclass(meta, *bases):
#         def __new__(cls, name, this_bases, d):
# def to_unicode(obj, charset="utf-8", errors="strict"):
#     class metaclass(meta):
# 
# Path: pydal/helpers/serializers.py
# class Serializers(object):
#     def _json_parse(self, o):
#     def __getattr__(self, name):
#     def json(self, value):
#     def yaml(self, value):


import copy
import marshal
import struct
import threading
import time
import traceback
            import types
from .._compat import (
    PY2,
    exists,
    copyreg,
    implements_bool,
    iterkeys,
    itervalues,
    iteritems,
    to_bytes,
    long,
)
from .._globals import THREAD_LOCAL
from .serializers import serializers
            elif mode in ("r", "rw", "rb"):
                raise RuntimeError("File %s does not exist" % filename)

    def read(self, bytes=None):
        if bytes is None:
            bytes = len(self.data)
        data = self.data[self.p : self.p + bytes]
        self.p += len(data)
        return data

    def readinto(self, bytes):
        return self.read(bytes)

    def readline(self):
        i = self.data.find(b"\n", self.p) + 1
        if i > 0:
            data, self.p = self.data[self.p : i], i
        else:
            data, self.p = self.data[self.p :], len(self.data)
        return data

    def write(self, data):
        self.data += data

    def close_connection(self):
        if self.db is not None:
            self.db.executesql(
                "DELETE FROM web2py_filesystem WHERE path='%s'" % self.filename
            )
            query = "INSERT INTO web2py_filesystem(path,content) VALUES (%s, %s)"

# Path: pydal/_compat.py
# PY2 = sys.version_info[0] == 2
#     def implements_bool(cls):
#     def implements_iterator(cls):
#     def to_bytes(obj, charset="utf-8", errors="strict"):
#     def to_native(obj, charset="utf8", errors="strict"):
#     def to_bytes(obj, charset="utf-8", errors="strict"):
#     def to_native(obj, charset="utf8", errors="strict"):
# def with_metaclass(meta, *bases):
#         def __new__(cls, name, this_bases, d):
# def to_unicode(obj, charset="utf-8", errors="strict"):
#     class metaclass(meta):
# 
# Path: pydal/helpers/serializers.py
# class Serializers(object):
#     def _json_parse(self, o):
#     def __getattr__(self, name):
#     def json(self, value):
#     def yaml(self, value):


# Path: pydal/helpers/classes.py
import copy
import marshal
import struct
import threading
import time
import traceback
            import types
from .._compat import (
    PY2,
    exists,
    copyreg,
    implements_bool,
    iterkeys,
    itervalues,
    iteritems,
    to_bytes,
    long,
)
from .._globals import THREAD_LOCAL
from .serializers import serializers

            elif mode in ("r", "rw", "rb"):
                raise RuntimeError("File %s does not exist" % filename)

    def read(self, bytes=None):
        if bytes is None:
            bytes = len(self.data)
        data = self.data[self.p : self.p + bytes]
        self.p += len(data)
        return data

    def readinto(self, bytes):
        return self.read(bytes)

    def readline(self):
        i = self.data.find(b"\n", self.p) + 1
        if i > 0:
            data, self.p = self.data[self.p : i], i
        else:
            data, self.p = self.data[self.p :], len(self.data)
        return data

    def write(self, data):
        self.data += data

    def close_connection(self):
        if self.db is not None:
            self.db.executesql(
                "DELETE FROM web2py_filesystem WHERE path='%s'" % self.filename
            )
            query = "INSERT INTO web2py_filesystem(path,content) VALUES (%s, %s)"

            args = (to_bytes(self.filename), self.data)