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

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

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.9.1.tar.gz (90.8 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

mappyfile-0.9.1-py3.8.egg (84.6 kB view details)

Uploaded Egg

mappyfile-0.9.1-py3.7.egg (84.5 kB view details)

Uploaded Egg

mappyfile-0.9.1-py3.6.egg (84.4 kB view details)

Uploaded Egg

mappyfile-0.9.1-py2.py3-none-any.whl (52.3 kB view details)

Uploaded Python 2Python 3

mappyfile-0.9.1-py2.7.egg (83.6 kB view details)

Uploaded Egg

File details

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

File metadata

  • Download URL: mappyfile-0.9.1.tar.gz
  • Upload date:
  • Size: 90.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.15.0 pkginfo/1.6.1 requests/2.25.1 setuptools/44.1.1 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/2.7.17

File hashes

Hashes for mappyfile-0.9.1.tar.gz
Algorithm Hash digest
SHA256 0f8d1204fe6b3ab78ac3f12074801ee322c2003cf21bcc192ef0ab83ca366ff1
MD5 d3ef03245995a8380e55231a548988d4
BLAKE2b-256 a27e13d3583277a82e86c897f21104c2d3609f97802158e19ed09a24f81b23ee

See more details on using hashes here.

File details

Details for the file mappyfile-0.9.1-py3.8.egg.

File metadata

  • Download URL: mappyfile-0.9.1-py3.8.egg
  • Upload date:
  • Size: 84.6 kB
  • Tags: Egg
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.1 setuptools/51.1.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.8.0

File hashes

Hashes for mappyfile-0.9.1-py3.8.egg
Algorithm Hash digest
SHA256 9983f71ec0781e75f3d2bf28fb2e6ef46f26c056ff9e5a25d8b12dd01c796a4b
MD5 0698e13f16b7f7aebddc2c306abf06e0
BLAKE2b-256 3c13a3f8d37fa635198982274a7de25cbabc1231f6c2ae6903e01e84fd03e7dc

See more details on using hashes here.

File details

Details for the file mappyfile-0.9.1-py3.7.egg.

File metadata

  • Download URL: mappyfile-0.9.1-py3.7.egg
  • Upload date:
  • Size: 84.5 kB
  • Tags: Egg
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.1 setuptools/51.1.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.7.5

File hashes

Hashes for mappyfile-0.9.1-py3.7.egg
Algorithm Hash digest
SHA256 0425ea21370a6840507e54d6618421f0b4bf42be20d5ddc8f4ec6602c2bc8c8c
MD5 66d0a39f33e478a71892dcf9a034ac5c
BLAKE2b-256 c44370486752d97affcecc0f8bfc1dc3e74732d432a491fc87912e5609450eac

See more details on using hashes here.

File details

Details for the file mappyfile-0.9.1-py3.6.egg.

File metadata

  • Download URL: mappyfile-0.9.1-py3.6.egg
  • Upload date:
  • Size: 84.4 kB
  • Tags: Egg
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.1 setuptools/51.1.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.6.8

File hashes

Hashes for mappyfile-0.9.1-py3.6.egg
Algorithm Hash digest
SHA256 6cab58c50bc55e3a97314ec9a88f3c9bb40e44136f71d60ee5c7ae31c1677c9d
MD5 80da8f7abeba3b811dc963b87ebd8346
BLAKE2b-256 657231af53e6b35b29a8e126574779d3b3b1c5a5e33f605e4a74360a008a2b69

See more details on using hashes here.

File details

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

File metadata

  • Download URL: mappyfile-0.9.1-py2.py3-none-any.whl
  • Upload date:
  • Size: 52.3 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.15.0 pkginfo/1.6.1 requests/2.25.1 setuptools/44.1.1 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/2.7.17

File hashes

Hashes for mappyfile-0.9.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 41b1c3e573857ac70e8133010aa46f10f1fb20d2d7a1128899c85ba8ea0c271a
MD5 d9974b87177a004818b3a7390eb313b0
BLAKE2b-256 b670605cf2970f7e0d2d2550d297d8912a3f72e3071dc23aa275f5949062f9fe

See more details on using hashes here.

File details

Details for the file mappyfile-0.9.1-py2.7.egg.

File metadata

  • Download URL: mappyfile-0.9.1-py2.7.egg
  • Upload date:
  • Size: 83.6 kB
  • Tags: Egg
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.15.0 pkginfo/1.6.1 requests/2.25.1 setuptools/44.1.1 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/2.7.17

File hashes

Hashes for mappyfile-0.9.1-py2.7.egg
Algorithm Hash digest
SHA256 b05023a201bf5424ae3f8926ad384aecb046b68f1225c6041e0b72bb270b8895
MD5 024e4b63fc03cb858b3e8fc76e067566
BLAKE2b-256 a979298fe5b3ef843942de529cbf6397c74babab2eb94d32a1e1aeca5ec37248

See more details on using hashes here.

Supported by

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