# Path: TileStache/py3_compat.py
# def is_string_type(val):


from .py3_compat import urlparse, urljoin
from os.path import exists
from sqlite3 import connect as _connect
from ModestMaps.Core import Coordinate
    """
    db = _connect(filename)
    db.text_factory = bytes

    tile_row = (2**coord.zoom - 1) - coord.row # Hello, Paul Ramsey.
    q = 'DELETE FROM tiles WHERE zoom_level=? AND tile_column=? AND tile_row=?'
    db.execute(q, (coord.zoom, coord.column, tile_row))

def put_tile(filename, coord, content):
    """
    """
    db = _connect(filename)
    db.text_factory = bytes

    tile_row = (2**coord.zoom - 1) - coord.row # Hello, Paul Ramsey.
    q = 'REPLACE INTO tiles (zoom_level, tile_column, tile_row, tile_data) VALUES (?, ?, ?, ?)'
    db.execute(q, (coord.zoom, coord.column, tile_row, buffer(content)))

    db.commit()
    db.close()

class Provider:
    """ MBTiles provider.

        See module documentation for explanation of constructor arguments.
    """
    def __init__(self, layer, tileset):
        """
        """
        sethref = urljoin(layer.config.dirpath, tileset)

# Path: TileStache/py3_compat.py
# def is_string_type(val):


# Path: TileStache/MBTiles.py
from .py3_compat import urlparse, urljoin
from os.path import exists
from sqlite3 import connect as _connect
from ModestMaps.Core import Coordinate

    """
    db = _connect(filename)
    db.text_factory = bytes

    tile_row = (2**coord.zoom - 1) - coord.row # Hello, Paul Ramsey.
    q = 'DELETE FROM tiles WHERE zoom_level=? AND tile_column=? AND tile_row=?'
    db.execute(q, (coord.zoom, coord.column, tile_row))

def put_tile(filename, coord, content):
    """
    """
    db = _connect(filename)
    db.text_factory = bytes

    tile_row = (2**coord.zoom - 1) - coord.row # Hello, Paul Ramsey.
    q = 'REPLACE INTO tiles (zoom_level, tile_column, tile_row, tile_data) VALUES (?, ?, ?, ?)'
    db.execute(q, (coord.zoom, coord.column, tile_row, buffer(content)))

    db.commit()
    db.close()

class Provider:
    """ MBTiles provider.

        See module documentation for explanation of constructor arguments.
    """
    def __init__(self, layer, tileset):
        """
        """
        sethref = urljoin(layer.config.dirpath, tileset)

        scheme, h, path, q, p, f = urlparse(sethref)