Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_save():
s = """MAP NAME "TEST" END"""
d = mappyfile.loads(s)
output_file = os.path.join(tempfile.mkdtemp(), 'test_mapfile.map')
mappyfile.save(d, output_file)
with open(output_file) as fp:
d = mappyfile.load(fp)
assert d["name"] == "TEST"
Example of formatting a single Mapfile with single quotes and tabs for indentation:
mappyfile format C:/Temp/valid.map C:/Temp/valid_formatted.map --quote=\\' --indent=1 --spacer=\t
Example of formatting a single Mapfile without expanding includes, but including comments:
mappyfile format C:/Temp/valid.map C:/Temp/valid_formatted.map --no-expand --comments
"""
quote = codecs.decode(quote, 'unicode_escape') # ensure \t is handled as a tab
spacer = codecs.decode(spacer, 'unicode_escape') # ensure \t is handled as a tab
newlinechar = codecs.decode(newlinechar, 'unicode_escape') # ensure \n is handled as a newline
d = mappyfile.open(input_mapfile, expand_includes=expand, include_comments=comments, include_position=True)
mappyfile.save(d, output_mapfile, indent=indent, spacer=spacer, quote=quote, newlinechar=newlinechar)
sys.exit(0)
def create_image(name, mapfile, output_folder, format="png"):
out_map = os.path.join(output_folder, "%s.map" % name)
mappyfile.save(mapfile, out_map)
out_img = os.path.join(output_folder, name)
return _create_image_from_map(out_map, out_img, format=format)