Skip to main content
Version Docs Build Status Coveralls Appveyor Build Status Downloads

A pure Python parser for working with MapServer MapFiles, built using Lark. mappyfile is an official OSGeo Community Project.

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

mappyfile is used for formatting and validation in https://app.mapserverstudio.net/, and can be tested for free on any of your Mapfiles. If you find mappyfile useful please consider signing up for a professional account at https://mapserverstudio.net/. This will help to fund maintenance and further development of both mappyfile and MapServer.

Requirements

  • Python 3.8 or higher

Installation

mappyfile is available on PyPI (the Python Package Index), and can be installed using pip:

pip install mappyfile

This will also install its required dependencies - Lark, and jsonschema.

To install the optional lark-cython library for better performance on CPython you can run the following command:

pip install mappyfile[lark_cython]

mappyfile is also available on conda. Install as follows:

conda install -c conda-forge mappyfile

Documentation

Full documentation is available at http://mappyfile.readthedocs.io/en/latest/

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

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-8-0.json --version=8.0

Authors

Contributors

Metadata

Release files for mappyfile 1.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mappyfile 1.0.1
File Size Uploaded
mappyfile-1.0.1.tar.gz 108.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for mappyfile 1.0.1
File Interpreter ABI Platform
mappyfile-1.0.1-py2.py3-none-any.whl Python 3, Python 2 none any Details

Total release size: 167.6 kB

Release files / mappyfile-1.0.1.tar.gz

Download URL mappyfile-1.0.1.tar.gz
Size 108.1 kB
Tags Source
SHA-256 checksum
How to use checksums
9a846d04ded66a792138767a6a1f7bbf0807396a61550d18d1977a40aba6519c
BLAKE2b-256 checksum
How to use checksums
e7662ef1b8e44f029b7fbecb771ecb8371a9ae4e0197af783ad758b0e01e6fba
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.10.11

Release files / mappyfile-1.0.1-py2.py3-none-any.whl

Download URL mappyfile-1.0.1-py2.py3-none-any.whl
Size 59.4 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
fcb97bc1b32050cce217d113fffe72f817f0bdbfbc3cd7d11cf67e487a5be649
BLAKE2b-256 checksum
How to use checksums
df8a5aa4636bc344541d278fc999fe5dc1437f3c8ef7b601ed0c67fc05c74fe6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.10.11

Release history Release notifications | RSS feed

1.2.0

2 release files

1.1.1

2 release files

1.1.0

2 release files

1.0.2

2 release files

This release

1.0.1 This release

2 release files

1.0.0

2 release files

0.9.7

2 release files

0.9.6

2 release files

0.9.5

2 release files

0.9.4

2 release files

0.9.3

6 release files

0.9.2

6 release files

0.9.1

6 release files

0.9.0

6 release files

0.8.4

5 release files

0.8.3

5 release files

0.8.2

2 release files

0.8.1

2 release files

0.8.0

2 release files

0.7.6

2 release files

0.7.5

2 release files

0.7.4

2 release files

0.7.3

2 release files

0.7.2

2 release files

0.7.1

2 release files

0.7.0

2 release files

0.6.2

2 release files

0.6.1

2 release files

0.6.0

2 release files

0.5.1

2 release files

0.5.0

2 release files

0.4.3

2 release files

0.4.2

2 release files

0.4.1

2 release files

0.3.2

1 release file

0.3.1

1 release file

0.3.0

1 release file

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.3

1 release file

0.1.2

1 release file

0.1.1

1 release file

0.1.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page