Skip to main content

A pure Python MapFile parser for working with MapServer

Project description

Version Docs Build Status Coveralls Appveyor Build Status Downloads

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.

https://raw.githubusercontent.com/geographika/mappyfile/master/docs/images/class_parsed_small.png

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"))

Two command line tools are available - format and validate:

mappyfile format raster.map formatted_raster.map
mappyfile validate D:\ms-ogc-workshop\ms4w\apps\ms-ogc-workshop\**\*.map

Authors

Contributors

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mappyfile-0.7.5.tar.gz (83.1 kB view details)

Uploaded Source

Built Distribution

mappyfile-0.7.5-py2.py3-none-any.whl (45.7 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file mappyfile-0.7.5.tar.gz.

File metadata

  • Download URL: mappyfile-0.7.5.tar.gz
  • Upload date:
  • Size: 83.1 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

Hashes for mappyfile-0.7.5.tar.gz
Algorithm Hash digest
SHA256 efe98da938d1bcf57aa0a39b18cbbe3ecd1e767452ff8e9ddd4eb9307f76ef14
MD5 12b846d2c37a3a63a8b587c6cb274603
BLAKE2b-256 1059ba05d0b73431d138f3e40640fcd0f2b151bb51a85df2702baeefcc7fa129

See more details on using hashes here.

Provenance

File details

Details for the file mappyfile-0.7.5-py2.py3-none-any.whl.

File metadata

  • Download URL: mappyfile-0.7.5-py2.py3-none-any.whl
  • Upload date:
  • Size: 45.7 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

Hashes for mappyfile-0.7.5-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 78f1c330c8526b89631e4e99d1bd2ecac065dd339276345b1f23c8a19962dfd2
MD5 7100acf7e26f217bdb6b5ca4f041eb7f
BLAKE2b-256 31bfcf4d08de75da00540954fc86eaad3544b6ea18a871413420a0e4ce1c2d79

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page