Skip to content

Commit

Permalink
Document separate_complex_types
Browse files Browse the repository at this point in the history
  • Loading branch information
geographika committed Feb 26, 2022
1 parent 72dc346 commit 7009889
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions docs/pretty_printing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ The formatting of the Mapfile output can be configured with several options:
+ **newlinechar** - the character used to insert newlines in the Mapfile
+ **end_comment** - add a comment with the block type at each closing END statement e.g. END # MAP
+ **align_values** - aligns the values in the same column for better readability. The column is multiple of indent and determined by the longest key
+ **separate_complex_types** - groups composites (complex mapserver definitions with "END") together at the end. Keeps the given order except
that all simple key-value pairs appear before composites.

.. warning::

Expand Down Expand Up @@ -117,6 +119,54 @@ Output:
END
END
This example moves all the simple key/value pairs of an object to the start of a declaration,
and the complex types to the end:

.. code-block:: python
s = '''MAP
WEB
METADATA
"wms_enable_request" "*"
"wms_feature_info_mime_type" "text/html"
END
END
EXTENT -180 -90 180 90
OUTPUTFORMAT
NAME "png"
DRIVER "AGG/PNG"
MIMETYPE "image/png"
IMAGEMODE RGB
EXTENSION "png"
END
NAME "MyMap"
END'''
d = mappyfile.loads(s)
output = mappyfile.dumps(d, separate_complex_types=True)
print(output)
Output:

.. code-block:: mapfile
MAP
EXTENT -180 -90 180 90
NAME "MyMap"
WEB
METADATA
"wms_enable_request" "*"
"wms_feature_info_mime_type" "text/html"
END
END
OUTPUTFORMAT
NAME "png"
DRIVER "AGG/PNG"
MIMETYPE "image/png"
IMAGEMODE RGB
EXTENSION "png"
END
END
This example writes a Mapfile to an open file object using the ``dump`` function:

.. code-block:: python
Expand Down

0 comments on commit 7009889

Please sign in to comment.