that's too much!
This commit is contained in:
@@ -0,0 +1 @@
|
||||
pip
|
||||
@@ -0,0 +1,27 @@
|
||||
Copyright (c) 2014, Mapbox
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
* Neither the name of cligj nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
@@ -0,0 +1,170 @@
|
||||
Metadata-Version: 2.1
|
||||
Name: cligj
|
||||
Version: 0.7.2
|
||||
Summary: Click params for commmand line interfaces to GeoJSON
|
||||
Home-page: https://github.com/mapbox/cligj
|
||||
Author: Sean Gillies
|
||||
Author-email: sean@mapbox.com
|
||||
License: BSD
|
||||
Platform: UNKNOWN
|
||||
Requires-Python: >=2.7, !=3.0.*, !=3.1.*, !=3.2.*, <4
|
||||
License-File: LICENSE
|
||||
Requires-Dist: click (>=4.0)
|
||||
Provides-Extra: test
|
||||
Requires-Dist: pytest-cov ; extra == 'test'
|
||||
|
||||
cligj
|
||||
======
|
||||
|
||||
.. image:: https://travis-ci.com/mapbox/cligj.svg
|
||||
:target: https://travis-ci.com/mapbox/cligj
|
||||
|
||||
.. image:: https://coveralls.io/repos/mapbox/cligj/badge.png?branch=master
|
||||
:target: https://coveralls.io/r/mapbox/cligj?branch=master
|
||||
|
||||
Common arguments and options for GeoJSON processing commands, using Click.
|
||||
|
||||
`cligj` is for Python developers who create command line interfaces for geospatial data.
|
||||
`cligj` allows you to quickly build consistent, well-tested and interoperable CLIs for handling GeoJSON.
|
||||
|
||||
|
||||
Arguments
|
||||
---------
|
||||
|
||||
``files_in_arg``
|
||||
Multiple files
|
||||
|
||||
``files_inout_arg``
|
||||
Multiple files, last of which is an output file.
|
||||
|
||||
``features_in_arg``
|
||||
GeoJSON Features input which accepts multiple representations of GeoJSON features
|
||||
and returns the input data as an iterable of GeoJSON Feature-like dictionaries
|
||||
|
||||
Options
|
||||
--------
|
||||
|
||||
``verbose_opt``
|
||||
|
||||
``quiet_opt``
|
||||
|
||||
``format_opt``
|
||||
|
||||
JSON formatting options
|
||||
~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
``indent_opt``
|
||||
|
||||
``compact_opt``
|
||||
|
||||
Coordinate precision option
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
``precision_opt``
|
||||
|
||||
Geographic (default), projected, or Mercator switch
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
``projection_geographic_opt``
|
||||
|
||||
``projection_projected_opt``
|
||||
|
||||
``projection_mercator_opt``
|
||||
|
||||
Feature collection or feature sequence switch
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
``sequence_opt``
|
||||
|
||||
``use_rs_opt``
|
||||
|
||||
GeoJSON output mode option
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
``geojson_type_collection_opt``
|
||||
|
||||
``geojson_type_feature_opt``
|
||||
|
||||
``def geojson_type_bbox_opt``
|
||||
|
||||
Example
|
||||
-------
|
||||
|
||||
Here's an example of a command that writes out GeoJSON features as a collection
|
||||
or, optionally, a sequence of individual features. Since most software that
|
||||
reads and writes GeoJSON expects a text containing a single feature collection,
|
||||
that's the default, and a LF-delimited sequence of texts containing one GeoJSON
|
||||
feature each is a feature that is turned on using the ``--sequence`` option.
|
||||
To write sequences of feature texts that conform to the `GeoJSON Text Sequences
|
||||
standard <https://tools.ietf.org/html/rfc8142>`__ (and might contain
|
||||
pretty-printed JSON) with the ASCII Record Separator (0x1e) as a delimiter, use
|
||||
the ``--rs`` option
|
||||
|
||||
.. warning:: Future change warning
|
||||
GeoJSON sequences (`--sequence`), not collections (`--no-sequence`), will be
|
||||
the default in version 1.0.0.
|
||||
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
import click
|
||||
import cligj
|
||||
import json
|
||||
|
||||
def process_features(features):
|
||||
for feature in features:
|
||||
# TODO process feature here
|
||||
yield feature
|
||||
|
||||
@click.command()
|
||||
@cligj.features_in_arg
|
||||
@cligj.sequence_opt
|
||||
@cligj.use_rs_opt
|
||||
def pass_features(features, sequence, use_rs):
|
||||
if sequence:
|
||||
for feature in process_features(features):
|
||||
if use_rs:
|
||||
click.echo(u'\x1e', nl=False)
|
||||
click.echo(json.dumps(feature))
|
||||
else:
|
||||
click.echo(json.dumps(
|
||||
{'type': 'FeatureCollection',
|
||||
'features': list(process_features(features))}))
|
||||
|
||||
On the command line, the generated help text explains the usage
|
||||
|
||||
.. code-block:: console
|
||||
|
||||
Usage: pass_features [OPTIONS] FEATURES...
|
||||
|
||||
Options:
|
||||
--sequence / --no-sequence Write a LF-delimited sequence of texts
|
||||
containing individual objects or write a single
|
||||
JSON text containing a feature collection object
|
||||
(the default).
|
||||
--rs / --no-rs Use RS (0x1E) as a prefix for individual texts
|
||||
in a sequence as per http://tools.ietf.org/html
|
||||
/draft-ietf-json-text-sequence-13 (default is
|
||||
False).
|
||||
--help Show this message and exit.
|
||||
|
||||
And can be used like this
|
||||
|
||||
.. code-block:: console
|
||||
|
||||
$ cat data.geojson
|
||||
{'type': 'FeatureCollection', 'features': [{'type': 'Feature', 'id': '1'}, {'type': 'Feature', 'id': '2'}]}
|
||||
|
||||
$ pass_features data.geojson
|
||||
{'type': 'FeatureCollection', 'features': [{'type': 'Feature', 'id': '1'}, {'type': 'Feature', 'id': '2'}]}
|
||||
|
||||
$ cat data.geojson | pass_features
|
||||
{'type': 'FeatureCollection', 'features': [{'type': 'Feature', 'id': '1'}, {'type': 'Feature', 'id': '2'}]}
|
||||
|
||||
$ cat data.geojson | pass_features --sequence
|
||||
{'type': 'Feature', 'id': '1'}
|
||||
{'type': 'Feature', 'id': '2'}
|
||||
|
||||
$ cat data.geojson | pass_features --sequence --rs
|
||||
^^{'type': 'Feature', 'id': '1'}
|
||||
^^{'type': 'Feature', 'id': '2'}
|
||||
|
||||
In this example, ``^^`` represents 0x1e.
|
||||
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
cligj-0.7.2.dist-info/INSTALLER,sha256=zuuue4knoyJ-UwPPXg8fezS7VCrXJQrAP7zeNuwvFQg,4
|
||||
cligj-0.7.2.dist-info/LICENSE,sha256=WQLXFlRN35o0hJs0XDkauvfCHKFu0icG1qwvVQNxJZQ,1469
|
||||
cligj-0.7.2.dist-info/METADATA,sha256=0M7veLSbCNJVF57jt5ah44S43avjjTu9wuDC5qr91tQ,5002
|
||||
cligj-0.7.2.dist-info/RECORD,,
|
||||
cligj-0.7.2.dist-info/WHEEL,sha256=OqRkF0eY5GHssMorFjlbTIq072vpHpF60fIQA6lS9xA,92
|
||||
cligj-0.7.2.dist-info/top_level.txt,sha256=Hvy1tviiMzKbB1D3AYXJVeozEJV6SgCs-EHFnhGlwMA,6
|
||||
cligj/__init__.py,sha256=zvD8Kc5PcY-AopHqGIY-Iekjv53BUhRCD6FHiF0k8uM,3876
|
||||
cligj/__pycache__/__init__.cpython-312.pyc,,
|
||||
cligj/__pycache__/features.cpython-312.pyc,,
|
||||
cligj/features.py,sha256=FwVHj0iAdqtOOy0uCFllC6H0EVNqsf3Djj99VEBYqCU,6905
|
||||
@@ -0,0 +1,5 @@
|
||||
Wheel-Version: 1.0
|
||||
Generator: bdist_wheel (0.36.2)
|
||||
Root-Is-Purelib: true
|
||||
Tag: py3-none-any
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
cligj
|
||||
Reference in New Issue
Block a user