import inspect
import os

MASKS_PATH = os.path.join(os.path.dirname(__file__), '../masks')


def load_template(mask_name):
    with open(os.path.join(MASKS_PATH, '{}.xml'.format(mask_name)), 'r') as f:
        return f.read()


def fill_template(mask_str, **kwargs):
    return mask_str.format(**kwargs)


# Starting of the XML Map definition
MAP_PREFIX = '''<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE Map[]>
<Map srs="+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0.0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs +over" background-color="#ffffff00" maximum-extent="-20037508.34,-20037508.34,20037508.34,20037508.34" buffer-size="50">
    <Parameters>
        <Parameter name="bounds">-180,-85.05112877980659,180,85.05112877980659</Parameter>
        <Parameter name="center">0,0,2</Parameter>
        <Parameter name="format">png</Parameter>
        <Parameter name="minzoom">0</Parameter>
        <Parameter name="maxzoom">22</Parameter>
        <Parameter name="description">TILEGEO/GEOLAYER display system</Parameter>
    </Parameters>
'''

# Final part of the XML Map definition
MAP_END = '</Map>'
