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_open():
fn = './tests/sample_maps/256_overlay_res.map'
d = mappyfile.open(fn)
assert d["name"] == "TEST"
d = mappyfile.open(fn, expand_includes=False)
assert d["name"] == "TEST"
d = mappyfile.open(fn, include_position=True)
assert d["name"] == "TEST"
d = mappyfile.open(fn, include_comments=True)
assert d["name"] == "TEST"
def parse(mf):
m = mappyfile.open(mf, expand_includes=False)
s = mappyfile.dumps(m)
return s
def test_open():
fn = './tests/sample_maps/256_overlay_res.map'
d = mappyfile.open(fn)
assert d["name"] == "TEST"
d = mappyfile.open(fn, expand_includes=False)
assert d["name"] == "TEST"
d = mappyfile.open(fn, include_position=True)
assert d["name"] == "TEST"
d = mappyfile.open(fn, include_comments=True)
assert d["name"] == "TEST"
def test_open():
fn = './tests/sample_maps/256_overlay_res.map'
d = mappyfile.open(fn)
assert d["name"] == "TEST"
d = mappyfile.open(fn, expand_includes=False)
assert d["name"] == "TEST"
d = mappyfile.open(fn, include_position=True)
assert d["name"] == "TEST"
d = mappyfile.open(fn, include_comments=True)
assert d["name"] == "TEST"
mappyfile format C:/Temp/valid.map C:/Temp/valid_formatted.map
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 main():
mf = "./docs/examples/geometry/geometry.map"
mapfile = mappyfile.open(mf)
mapfile["size"] = [600, 600]
output_folder = os.path.join(os.getcwd(), "docs/images")
dilated = dilation(mapfile)
create_image("dilated", mapfile, output_folder=output_folder)
erosion(mapfile, dilated)
create_image("erosion", mapfile, output_folder=output_folder)
import mappyfile
import json
mf = mappyfile.open("./docs/examples/after.map")
with open("./docs/examples/sample.json", "w") as f:
json.dump(mf, f, indent=4)