A pure Python MapFile parser for working with MapServer
Project description
A pure Python MapFile parser for working with MapServer, 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
Documentation at http://mappyfile.readthedocs.io/en/latest/
Usage
import mappyfile
mapfile = mappyfile.load("./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
"""
new_layer = mappyfile.loads(new_layer_string)
layers.insert(0, new_layer) # can insert the new layer at any index
print(mappyfile.dumps(mapfile))
Contributors
Julien Enselme @jenselme
Loïc Gasser @loicgasser
Ian Turton @ianturton
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file mappyfile-0.7.3.tar.gz
.
File metadata
- Download URL: mappyfile-0.7.3.tar.gz
- Upload date:
- Size: 82.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.2.0 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/2.7.14
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 328f3570b10f4e4d51075d766b98d8e05cd7a1fc8efb485ba4ede44b120d60be |
|
MD5 | 58c161157e6f12f99bccc18b8b8c841c |
|
BLAKE2b-256 | fbea6a7697adbe36eb414e0992bbb8dac00cb14c14c3616e369c5924875ed145 |
Provenance
File details
Details for the file mappyfile-0.7.3-py2.py3-none-any.whl
.
File metadata
- Download URL: mappyfile-0.7.3-py2.py3-none-any.whl
- Upload date:
- Size: 45.3 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.2.0 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/2.7.14
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2356c4aaa5f06d31e111f9376ecb3a69c55784dc2eca75c0c53c02dea01b04f6 |
|
MD5 | 4e26fc299393486d5599e94cb5531565 |
|
BLAKE2b-256 | bdb53fa6f9e8c6a1ebef87a3d2af2b3fbd4078cd965e387b62cda4fcb5797d17 |