示例#1
0
def create_image(name, mapfile, output_folder, format="png"):

    out_map = os.path.join(output_folder, "%s.map" % name)
    mappyfile.write(mapfile, out_map)

    out_img = os.path.join(output_folder, name)

    return _create_image_from_map(out_map, out_img, format=format)
示例#2
0
def create_image(name, mapfile, output_folder, format="png"):

    out_map = os.path.join(output_folder, "%s.map" % name)
    mappyfile.write(mapfile, out_map)

    out_img = os.path.join(output_folder, name)

    return _create_image_from_map(out_map, out_img, format=format)
示例#3
0
def test_write():

    s = """MAP NAME "TEST" END"""
    fn = tempfile.mktemp()
    d = mappyfile.loads(s)
    mappyfile.write(d, fn)
    d = mappyfile.open(fn)
    assert d["name"] == "TEST"

    mappyfile.write(d, fn, indent=2, spacer="\t", quote="'", newlinechar="")
    d = mappyfile.open(fn)
    assert d["name"] == "TEST"
示例#4
0
def test_write():

    s = """MAP NAME "TEST" END"""
    fn = tempfile.mktemp()
    d = mappyfile.loads(s)
    mappyfile.write(d, fn)
    d = mappyfile.open(fn)
    assert d["name"] == "TEST"

    mappyfile.write(d, fn, indent=2, spacer="\t", quote="'", newlinechar="")
    d = mappyfile.open(fn)
    assert d["name"] == "TEST"
示例#5
0
def read_mapfile(fn, output_folder):

    mf = mappyfile.load(fn)
    quoter = Quoter()
    includes = []

    for l in (mf["layers"]):
        layer_file = quoter.remove_quotes(l["name"]) + ".txt"
        ofn = os.path.join(output_folder, layer_file)
        mappyfile.write(l, ofn)
        includes.append(quoter.add_quotes(layer_file))

    # now write the mapfile with includes
    ofn = os.path.join(output_folder, "_" + os.path.basename(fn))
    del mf["layers"]

    existing_includes = mf["include"]

    if (len(existing_includes)) > 0:
        mf["include"] += includes
    else:
        mf["include"] = includes

    mappyfile.write(mf, ofn)
import mappyfile
mf = mappyfile.load("./docs/examples/before.map")
mappyfile.write(mf, "./docs/examples/after.map")