A pure Python parser for working with MapServer MapFiles, built using Lark
An online formatter demonstrating the libraries capabilities can be found at: http://mappyfile.geographika.net/
A presentation on mappyfile was given at FOSS4G Europe 2017 - slides are available for download here.
Requirements
Python 2.7 or Python 3.x
Installation
mappyfile is available on PyPI (Python Package Index), and can be installed using pip:
pip install mappyfile
This will also install its required dependences Lark (lark-parser), and jsonschema.
Documentation
Full documentation is available at http://mappyfile.readthedocs.io/en/latest/
Usage
From within Python scripts:
import mappyfile
mapfile = mappyfile.open("./docs/examples/raster.map")
# update the map name
mapfile["name"] = "MyNewMap"
new_layer_string = """
LAYER
NAME 'land'
TYPE POLYGON
DATA '../data/vector/naturalearth/ne_110m_land'
CLASS
STYLE
COLOR 107 208 107
OUTLINECOLOR 2 2 2
WIDTH 1
END
END
END
"""
layers = mapfile["layers"]
new_layer = mappyfile.loads(new_layer_string)
layers.insert(0, new_layer) # insert the new layer at any index in the Mapfile
for l in layers:
print("{} {}".format(l["name"], l["type"]))
print(mappyfile.dumps(mapfile, indent=1, spacer="\t"))
Three command line tools are available - format, validate, and schema:
mappyfile format raster.map formatted_raster.map
mappyfile validate D:\ms-ogc-workshop\ms4w\apps\ms-ogc-workshop\**\*.map
mappyfile schema mapfile-schema-7-6.json --version=7.6
Contributors
Julien Enselme @jenselme
Loïc Gasser @loicgasser
Ian Turton @ianturton
Metadata
Release files for mappyfile 0.9.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| mappyfile-0.9.0.tar.gz | 90.5 kB | Details |
Built distributions (wheels)
| File | Reset | |||
|---|---|---|---|---|
| mappyfile-0.9.0-py3.8.egg | Legacy Egg format | - | - | Details |
| mappyfile-0.9.0-py3.7.egg | Legacy Egg format | - | - | Details |
| mappyfile-0.9.0-py3.6.egg | Legacy Egg format | - | - | Details |
| mappyfile-0.9.0-py2.py3-none-any.whl | Python 3, Python 2 | none | any | Details |
| mappyfile-0.9.0-py2.7.egg | Legacy Egg format | - | - | Details |
Total release size: 479.3 kB
Release files / mappyfile-0.9.0.tar.gz
| Download URL | mappyfile-0.9.0.tar.gz |
|---|---|
| Size | 90.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4585036136722d80a43da5b548cda57886e1d3fefeb51ee98ee74bcc8c642055
|
|
BLAKE2b-256 checksum How to use checksums |
9b1187542f71bdd8037518e0c1b4422f8e703725d2b5238b66dd53c51d5426eb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.15.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/44.1.1 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/2.7.17
|
Release files / mappyfile-0.9.0-py3.8.egg
| Download URL | mappyfile-0.9.0-py3.8.egg |
|---|---|
| Size | 84.5 kB |
| Tags | Egg |
|
SHA-256 checksum How to use checksums |
09d45826786262a697c7495e71cef831f7129589a17b14d7ec73351b4b165fae
|
|
BLAKE2b-256 checksum How to use checksums |
e7d3ac483c9c448c5e526eef7b616a80d92a24cbb608d694d7c3bc7ea0e547f9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.8.0
|
Release files / mappyfile-0.9.0-py3.7.egg
| Download URL | mappyfile-0.9.0-py3.7.egg |
|---|---|
| Size | 84.4 kB |
| Tags | Egg |
|
SHA-256 checksum How to use checksums |
bb5def44c4eeafe7c3803f1cf051a7148fe4b24b9a8495bbb918092595551ad1
|
|
BLAKE2b-256 checksum How to use checksums |
919c01c6d70ab930796db6c7f0c177de410be7fb1af043ff86958303e96858b0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.7.5
|
Release files / mappyfile-0.9.0-py3.6.egg
| Download URL | mappyfile-0.9.0-py3.6.egg |
|---|---|
| Size | 84.3 kB |
| Tags | Egg |
|
SHA-256 checksum How to use checksums |
2b41c6399da69eae982e7f1e8de3882c2a3e72f80089e8ba515753053c4f1aa4
|
|
BLAKE2b-256 checksum How to use checksums |
89e139fcf10c8a8817fb2afb4b391ec35e295662d030bbe620ec7482ff89dde5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.6.8
|
Release files / mappyfile-0.9.0-py2.py3-none-any.whl
| Download URL | mappyfile-0.9.0-py2.py3-none-any.whl |
|---|---|
| Size | 52.2 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
b99c73efbed0907c31addfff934f00c43a79fb5a70dbd9230cd3b375ac6f9028
|
|
BLAKE2b-256 checksum How to use checksums |
bb05915388249800dff06b1ed214a282634186aba8d22e23c69d581359c69dda
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.15.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/44.1.1 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/2.7.17
|
Release files / mappyfile-0.9.0-py2.7.egg
| Download URL | mappyfile-0.9.0-py2.7.egg |
|---|---|
| Size | 83.4 kB |
| Tags | Egg |
|
SHA-256 checksum How to use checksums |
20420dd9b53144fd8276d77c9aa84b2c38b2cc59b8650cbdf734176dc671f2c3
|
|
BLAKE2b-256 checksum How to use checksums |
25cb7876b22c979e1bf3822e965c526ada292f9708e214261531af76e3a1b9b4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.15.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/44.1.1 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/2.7.17
|