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


import logging
import TileStache
	from json import load as json_load
	from simplejson import load as json_load
from TileStache.py3_compat import urlopen

class DynamicLayers:

	def __init__(self, config, url_root, cache_responses, dirpath):
		self.config = config
		self.url_root = url_root
		self.dirpath = dirpath
		self.cache_responses = cache_responses;
		self.seen_layers = {}
		self.lookup_failures = set()

	def keys(self):
		return self.seen_layers.keys()

	def items(self):
		return self.seen_layers.items()

	def parse_layer(self, layer_json):
		layer_dict = json_load(layer_json)
		return TileStache.Config._parseConfigLayer(layer_dict, self.config, self.dirpath)

	def __contains__(self, key):
		# If caching is enabled and we've seen a request for this layer before, return True unless
		# the prior lookup failed to find this layer.
		if self.cache_responses:
			if key in self.seen_layers:
				return True
			elif key in self.lookup_failures:
				return False


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


# Path: TileStache/Goodies/ExternalConfigServer.py
import logging
import TileStache
	from json import load as json_load
	from simplejson import load as json_load
from TileStache.py3_compat import urlopen


class DynamicLayers:

	def __init__(self, config, url_root, cache_responses, dirpath):
		self.config = config
		self.url_root = url_root
		self.dirpath = dirpath
		self.cache_responses = cache_responses;
		self.seen_layers = {}
		self.lookup_failures = set()

	def keys(self):
		return self.seen_layers.keys()

	def items(self):
		return self.seen_layers.items()

	def parse_layer(self, layer_json):
		layer_dict = json_load(layer_json)
		return TileStache.Config._parseConfigLayer(layer_dict, self.config, self.dirpath)

	def __contains__(self, key):
		# If caching is enabled and we've seen a request for this layer before, return True unless
		# the prior lookup failed to find this layer.
		if self.cache_responses:
			if key in self.seen_layers:
				return True
			elif key in self.lookup_failures:
				return False


		res = urlopen(self.url_root + "/layer/" + key)