<commit_before>from cStringIO import StringIO
from TileStache.Goodies.VecTiles.server import MultiResponse


class RenderJob(object):

    # This isn't ideal, because it will execute the query for each format
    # But, it's least invasive with most code re-use

    def __init__(self, coord, format, tilestache_config, layer_names):
        self.coord = coord
        self.format = format
        self.tilestache_config = tilestache_config
        self.layer_names = layer_names

    def __call__(self):
        out = StringIO()
        response = MultiResponse(
            self.tilestache_config, self.layer_names, self.coord)
        response.save(out, self.format.name)
        return out.getvalue()


class RenderJobCreator(object):

    def __init__(self, tilestache_config, formats):
        self.tilestache_config = tilestache_config
        self.formats = formats
        layers = tilestache_config.layers
        self.layer_names = [l for l in layers.keys()
                            if l not in (u'all', u'_healthcheck', u',')]

    def create(self, coord):
        return [RenderJob(coord, format,
                          self.tilestache_config, self.layer_names)
                for format in self.formats]
<commit_msg>Fetch layer names from "all" layer config<commit_after>from cStringIO import StringIO
from TileStache.Goodies.VecTiles.server import MultiResponse


class RenderJob(object):

    # This isn't ideal, because it will execute the query for each format
    # But, it's least invasive with most code re-use

    def __init__(self, coord, format, tilestache_config, layer_names):
        self.coord = coord
        self.format = format
        self.tilestache_config = tilestache_config
        self.layer_names = layer_names

    def __call__(self):
        out = StringIO()
        response = MultiResponse(
            self.tilestache_config, self.layer_names, self.coord)
        response.save(out, self.format.name)
        return out.getvalue()


class RenderJobCreator(object):

    def __init__(self, tilestache_config, formats):
        self.tilestache_config = tilestache_config
        self.formats = formats
        layers = tilestache_config.layers
        all_layer = layers['all']
        self.layer_names = all_layer.provider.names

    def create(self, coord):
        return [RenderJob(coord, format,
                          self.tilestache_config, self.layer_names)
                for format in self.formats]

{'fraction_non_alphanumeric': 0.07839155158407798, 'fraction_numerical': 0.0, 'mean_word_length': 2.643491124260355, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2599620', 'n_tokens_mistral': 708, 'n_tokens_neox': 689, 'n_words': 185}