# Path: TileStache/py3_compat.py
# def is_string_type(val):
# 
# Path: TileStache/py3_compat.py
# def is_string_type(val):
# 
# Path: TileStache/Core.py
# class KnownUnknown(Exception):
#     """ There are known unknowns. That is to say, there are things that we now know we don't know.
# 
#         This exception gets thrown in a couple places where common mistakes are made.
#     """
#     pass


from time import time
from os.path import exists
from itertools import count
from glob import glob
from tempfile import mkstemp
from .py3_compat import reduce, urlopen, urljoin, urlparse, allocate_lock
from .py3_compat import unichr
from TileStache.Core import KnownUnknown
from TileStache.Geography import getProjectionByName
    from PIL import Image
import os
import logging
import json
    import mapnik
    import Image
        This provider is identified by the name "mapnik" in the TileStache config.

        Arguments:

        - mapfile (required)
            Local file path to Mapnik XML file.

        - fonts (optional)
            Local directory path to *.ttf font files.

        - "scale factor" (optional)
            Scale multiplier used for Mapnik rendering pipeline. Used for
            supporting retina resolution.

            For more information about the scale factor, see:
            https://github.com/mapnik/mapnik/wiki/Scale-factor

        More information on Mapnik and Mapnik XML:
        - http://mapnik.org
        - http://trac.mapnik.org/wiki/XMLGettingStarted
        - http://trac.mapnik.org/wiki/XMLConfigReference
    """

    def __init__(self, layer, mapfile, fonts=None, scale_factor=None):
        """ Initialize Mapnik provider with layer and mapfile.

            XML mapfile keyword arg comes from TileStache config,
            and is an absolute path by the time it gets here.
        """
        maphref = urljoin(layer.config.dirpath, mapfile)

# Path: TileStache/py3_compat.py
# def is_string_type(val):
# 
# Path: TileStache/py3_compat.py
# def is_string_type(val):
# 
# Path: TileStache/Core.py
# class KnownUnknown(Exception):
#     """ There are known unknowns. That is to say, there are things that we now know we don't know.
# 
#         This exception gets thrown in a couple places where common mistakes are made.
#     """
#     pass


# Path: TileStache/Mapnik.py
from time import time
from os.path import exists
from itertools import count
from glob import glob
from tempfile import mkstemp
from .py3_compat import reduce, urlopen, urljoin, urlparse, allocate_lock
from .py3_compat import unichr
from TileStache.Core import KnownUnknown
from TileStache.Geography import getProjectionByName
    from PIL import Image
import os
import logging
import json
    import mapnik
    import Image

        This provider is identified by the name "mapnik" in the TileStache config.

        Arguments:

        - mapfile (required)
            Local file path to Mapnik XML file.

        - fonts (optional)
            Local directory path to *.ttf font files.

        - "scale factor" (optional)
            Scale multiplier used for Mapnik rendering pipeline. Used for
            supporting retina resolution.

            For more information about the scale factor, see:
            https://github.com/mapnik/mapnik/wiki/Scale-factor

        More information on Mapnik and Mapnik XML:
        - http://mapnik.org
        - http://trac.mapnik.org/wiki/XMLGettingStarted
        - http://trac.mapnik.org/wiki/XMLConfigReference
    """

    def __init__(self, layer, mapfile, fonts=None, scale_factor=None):
        """ Initialize Mapnik provider with layer and mapfile.

            XML mapfile keyword arg comes from TileStache config,
            and is an absolute path by the time it gets here.
        """
        maphref = urljoin(layer.config.dirpath, mapfile)

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