How to use the mappyfile.open function in mappyfile

To help you get started, we’ve selected a few mappyfile examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github geographika / mappyfile / tests / test_utils.py View on Github external
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"
github geographika / mappyfile / tests / mapfiles / profiler.py View on Github external
def parse(mf):
    m = mappyfile.open(mf, expand_includes=False)
    s = mappyfile.dumps(m)
    return s
github geographika / mappyfile / tests / test_utils.py View on Github external
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"
github geographika / mappyfile / tests / test_utils.py View on Github external
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"
github geographika / mappyfile / mappyfile / cli.py View on Github external
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)
github geographika / mappyfile / docs / examples / geometry / geometry.py View on Github external
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)
github geographika / mappyfile / docs / examples / sample_json.py View on Github external
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)