<commit_before>import os
import urllib2
import math
import re
import requests
from xml.dom import minidom
from PIL import Image, ImageDraw
from cStringIO import StringIO

LOADINPROGRESS = [0, 0]  # [_todo_, _done_]


def getAlarmMap(alarm, tilepath):
    """
    Build map for alarm as png image stream

    :param alarm: :py:class:`emonitor.modules.alarms.alarm.Alarm`
    :param tilepath: path to tile images
    :return: image as stream
    """
    dimx = 5  # tiles in x dimension
    dimy = 3  # tiles in y dimension
    zoom = int(alarm.get('zoom', 18))
    img_map = Image.new('RGBA', (dimx * 256, dimy * 256), (255, 255, 255, 255))
    try:
        t = deg2num(float(alarm.get('lat')), float(alarm.get('lng')), zoom)
    except ValueError:
        t = deg2num(float(alarm.objct.lat), float(alarm.object.lng), zoom)

    cat = alarm.key.category
    items = []
    for itemtype in alarm.getMap().getMapItemDefinitions():
        for r in itemtype['key']:
            regex = re.compile(r)
            if regex.search(cat):
                items.append(itemtype)

    points = []
    if alarm.housenumber:
        def t2pixel(pt):
            deltax = pt[0] - t[0]  # tiles delta x
            deltay = pt[1] - t[1]  # tiles delta y

            x = dimx / 2 * 256 + (deltax * 256) + pt[2]
            y = dimy / 2 * 256 + (deltay * 256) + pt[3]
            return x, y

        for p in alarm.housenumber.points:
            points.append(t2pixel(deg2num(p[0], p[1], 18)))
<commit_msg>allow parameter 'large' in map creation<commit_after>import os
import urllib2
import math
import re
import requests
from xml.dom import minidom
from PIL import Image, ImageDraw
from cStringIO import StringIO

LOADINPROGRESS = [0, 0]  # [_todo_, _done_]


def getAlarmMap(alarm, tilepath, **params):
    """
    Build map for alarm as png image stream

    :param alarm: :py:class:`emonitor.modules.alarms.alarm.Alarm`
    :param tilepath: path to tile images
    :param params: dict with extra parameters
        - large = boolean, use large map (height =
    :return: image as stream
    """
    dimx = 5  # tiles in x dimension
    dimy = 3  # tiles in y dimension

    if 'style' in params and params['style'] == 'large':  # add height
        dimy += 1

    zoom = int(alarm.get('zoom', 18))
    img_map = Image.new('RGBA', (dimx * 256, dimy * 256), (255, 255, 255, 255))
    try:
        t = deg2num(float(alarm.get('lat')), float(alarm.get('lng')), zoom)
    except ValueError:
        t = deg2num(float(alarm.objct.lat), float(alarm.object.lng), zoom)

    cat = alarm.key.category
    items = []
    for itemtype in alarm.getMap().getMapItemDefinitions():
        for r in itemtype['key']:
            regex = re.compile(r)
            if regex.search(cat):
                items.append(itemtype)

    points = []
    if alarm.housenumber:
        def t2pixel(pt):
            deltax = pt[0] - t[0]  # tiles delta x
            deltay = pt[1] - t[1]  # tiles delta y

            x = dimx / 2 * 256 + (deltax * 256) + pt[2]
            y = dimy / 2 * 256 + (deltay * 256) + pt[3]
            return x, y

        for p in alarm.housenumber.points:
            points.append(t2pixel(deg2num(p[0], p[1], 18)))

{'fraction_non_alphanumeric': 0.12718204488778054, 'fraction_numerical': 0.033977556109725686, 'mean_word_length': 2.370798319327731, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, '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': '953697', 'n_tokens_mistral': 1186, 'n_tokens_neox': 1086, 'n_words': 319}