[Git][debian-gis-team/python-cligj][upstream] New upstream version 0.6.0
Bas Couwenberg
gitlab at salsa.debian.org
Tue Oct 20 05:20:53 BST 2020
Bas Couwenberg pushed to branch upstream at Debian GIS Project / python-cligj
Commits:
f85bac66 by Bas Couwenberg at 2020-10-20T06:06:57+02:00
New upstream version 0.6.0
- - - - -
10 changed files:
- .travis.yml
- CHANGES.txt
- LICENSE
- + MANIFEST.in
- README.rst
- cligj/__init__.py
- cligj/features.py
- + setup.cfg
- setup.py
- tests/twopoints.geojson
Changes:
=====================================
.travis.yml
=====================================
@@ -2,9 +2,9 @@ sudo: false
language: python
python:
- "2.7"
- - "3.3"
- "3.4"
- "3.5"
+ - "3.6"
install:
- "pip install coveralls"
- "pip install -e .[test]"
=====================================
CHANGES.txt
=====================================
@@ -1,6 +1,24 @@
Changes
=======
+0.6.0 (2020-10-19)
+------------------
+
+No changes since 0.6b1.
+
+0.6b1 (2020-10-14)
+------------------
+
+Future changes:
+
+- Feature sequences, not collections, will be the default form of output in
+ version 1.0 (#20).
+
+Bug fixes:
+
+- Always use `encoding='utf-8'` when opening input GeoJSON (#27).
+- Improve docstrings (#22).
+
0.5.0 (2018-09-26)
------------------
@@ -20,7 +38,7 @@ Changes
0.3.0 (2015-08-12)
------------------
-- Deprecation of the cligj.plugins module (#6). Please switch to the
+- Deprecation of the cligj.plugins module (#6). Please switch to the
click-plugins module: https://github.com/click-contrib/click-plugins. The
cligj.plugins module will be removed from cligj at version 1.0.
=====================================
LICENSE
=====================================
=====================================
MANIFEST.in
=====================================
@@ -0,0 +1,4 @@
+include CHANGES.txt
+include LICENSE
+
+graft tests
=====================================
README.rst
=====================================
@@ -10,7 +10,7 @@ cligj
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.
+`cligj` allows you to quickly build consistent, well-tested and interoperable CLIs for handling GeoJSON.
Arguments
@@ -76,11 +76,15 @@ 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 `JSON Text Sequences
-proposed standard
-<http://tools.ietf.org/html/draft-ietf-json-text-sequence-13>`__ (and might
-contain pretty-printed JSON) with the ASCII Record Separator (0x1e) as
-a delimiter, use the ``--rs`` 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
@@ -125,7 +129,6 @@ On the command line, the generated help text explains the usage
False).
--help Show this message and exit.
-
And can be used like this
.. code-block:: console
=====================================
cligj/__init__.py
=====================================
@@ -1,6 +1,8 @@
-# cligj
+"""cligj
-# Shared arguments and options.
+A package of arguments, options, and parsers for the Python GeoJSON
+ecosystem.
+"""
import click
@@ -109,8 +111,8 @@ use_rs_opt = click.option(
"(default is False).")
-# GeoJSON output mode option.
def geojson_type_collection_opt(default=False):
+ """GeoJSON FeatureCollection output mode"""
return click.option(
'--collection',
'geojson_type',
@@ -120,6 +122,7 @@ def geojson_type_collection_opt(default=False):
def geojson_type_feature_opt(default=False):
+ """GeoJSON Feature or Feature sequence output mode"""
return click.option(
'--feature',
'geojson_type',
@@ -129,6 +132,7 @@ def geojson_type_feature_opt(default=False):
def geojson_type_bbox_opt(default=False):
+ """GeoJSON bbox output mode"""
return click.option(
'--bbox',
'geojson_type',
=====================================
cligj/features.py
=====================================
@@ -1,3 +1,5 @@
+"""Feature parsing and normalization"""
+
from itertools import chain
import json
import re
@@ -23,10 +25,16 @@ def normalize_feature_inputs(ctx, param, value):
"[lng, lat]", or "lng, lat", or "lng lat".
If no value is provided, features will be read from stdin.
+
+ Yields
+ ------
+ Mapping
+ A GeoJSON Feature represented by a Python mapping
+
"""
for feature_like in value or ('-',):
try:
- with click.open_file(feature_like) as src:
+ with click.open_file(feature_like, encoding="utf-8") as src:
for feature in iter_features(iter(src)):
yield feature
except IOError:
@@ -55,6 +63,12 @@ def iter_features(geojsonfile, func=None):
A function that will be applied to each extracted feature. It
takes a feature object and may return a replacement feature or
None -- in which case iter_features does not yield.
+
+ Yields
+ ------
+ Mapping
+ A GeoJSON Feature represented by a Python mapping
+
"""
func = func or (lambda x: x)
first_line = next(geojsonfile)
@@ -136,9 +150,20 @@ def iter_features(geojsonfile, func=None):
def to_feature(obj):
- """Takes a feature or a geometry
- returns feature verbatim or
- wraps geom in a feature with empty properties
+ """Converts an object to a GeoJSON Feature
+
+ Returns feature verbatim or wraps geom in a feature with empty
+ properties.
+
+ Raises
+ ------
+ ValueError
+
+ Returns
+ -------
+ Mapping
+ A GeoJSON Feature represented by a Python mapping
+
"""
if obj['type'] == 'Feature':
return obj
@@ -177,13 +202,13 @@ def normalize_feature_objects(feature_objs):
an iterable of objects with a geo interface and
normalizes it to the former."""
for obj in feature_objs:
- if hasattr(obj, "__geo_interface__") and \
- 'type' in obj.__geo_interface__.keys() and \
- obj.__geo_interface__['type'] == 'Feature':
+ if (
+ hasattr(obj, "__geo_interface__")
+ and "type" in obj.__geo_interface__.keys()
+ and obj.__geo_interface__["type"] == "Feature"
+ ):
yield obj.__geo_interface__
- elif isinstance(obj, dict) and 'type' in obj and \
- obj['type'] == 'Feature':
+ elif isinstance(obj, dict) and "type" in obj and obj["type"] == "Feature":
yield obj
else:
- raise ValueError("Did not recognize object {0}"
- "as GeoJSON Feature".format(obj))
+ raise ValueError("Did not recognize object as GeoJSON Feature")
=====================================
setup.cfg
=====================================
@@ -0,0 +1,2 @@
+[metadata]
+license_file = LICENSE
=====================================
setup.py
=====================================
@@ -1,28 +1,26 @@
from codecs import open as codecs_open
-from setuptools import setup, find_packages
+from setuptools import setup, find_packages
# Get the long description from the relevant file
with codecs_open('README.rst', encoding='utf-8') as f:
long_description = f.read()
-setup(name='cligj',
- version='0.5.0',
- description=u"Click params for commmand line interfaces to GeoJSON",
- long_description=long_description,
- classifiers=[],
- keywords='',
- author=u"Sean Gillies",
- author_email='sean at mapbox.com',
- url='https://github.com/mapbox/cligj',
- license='BSD',
- packages=find_packages(exclude=['ez_setup', 'examples', 'tests']),
- include_package_data=True,
- zip_safe=False,
- install_requires=[
- 'click >= 4.0, < 8'
- ],
- extras_require={
- 'test': ['pytest-cov'],
- })
+setup(
+ name="cligj",
+ version="0.6.0",
+ description=u"Click params for commmand line interfaces to GeoJSON",
+ long_description=long_description,
+ classifiers=[],
+ keywords="",
+ author=u"Sean Gillies",
+ author_email="sean at mapbox.com",
+ url="https://github.com/mapbox/cligj",
+ license="BSD",
+ packages=find_packages(exclude=["ez_setup", "examples", "tests"]),
+ include_package_data=True,
+ zip_safe=False,
+ install_requires=["click >= 4.0, < 8"],
+ extras_require={"test": ["pytest-cov"],},
+)
=====================================
tests/twopoints.geojson
=====================================
@@ -1 +1 @@
-{"features": [{"bbox": [-122.9292140099711, 45.37948199034149, -122.44106199104115, 45.858097009742835], "center": [-122.7282, 45.5801], "context": [{"id": "postcode.2503633822", "text": "97203"}, {"id": "region.3470299826", "text": "Oregon"}, {"id": "country.4150104525", "short_code": "us", "text": "United States"}], "geometry": {"coordinates": [-122.7282, 45.5801], "type": "Point"}, "id": "place.42767", "place_name": "Portland, Oregon, United States", "properties": {}, "relevance": 0.999, "text": "Portland", "type": "Feature"}, {"bbox": [-121.9779540096568, 43.74737999114854, -120.74788099000016, 44.32812500969035], "center": [-121.3153, 44.0582], "context": [{"id": "postcode.3332732485", "text": "97701"}, {"id": "region.3470299826", "text": "Oregon"}, {"id": "country.4150104525", "short_code": "us", "text": "United States"}], "geometry": {"coordinates": [-121.3153, 44.0582], "type": "Point"}, "id": "place.3965", "place_name": "Bend, Oregon, United States", "properties": {}, "relevance": 0.999, "text": "Bend", "type": "Feature"}], "type": "FeatureCollection"}
+{"features": [{"bbox": [-122.9292140099711, 45.37948199034149, -122.44106199104115, 45.858097009742835], "center": [-122.7282, 45.5801], "context": [{"id": "postcode.2503633822", "text": "97203"}, {"id": "region.3470299826", "text": "Oregon"}, {"id": "country.4150104525", "short_code": "us", "text": "United States"}], "geometry": {"coordinates": [-122.7282, 45.5801], "type": "Point"}, "id": "place.42767", "place_name": "Portland, Oregon, United States", "properties": {}, "relevance": 0.999, "text": "Portland", "type": "Feature"}, {"bbox": [-121.9779540096568, 43.74737999114854, -120.74788099000016, 44.32812500969035], "center": [-121.3153, 44.0582], "context": [{"id": "postcode.3332732485", "text": "97701"}, {"id": "region.3470299826", "text": "Oregon"}, {"id": "country.4150104525", "short_code": "us", "text": "United States"}], "geometry": {"coordinates": [-121.3153, 44.0582], "type": "Point"}, "id": "place.3965", "place_name": "Bend, 😀regon, United States", "properties": {}, "relevance": 0.999, "text": "Bend", "type": "Feature"}], "type": "FeatureCollection"}
View it on GitLab: https://salsa.debian.org/debian-gis-team/python-cligj/-/commit/f85bac664804e21930d9abb0ef34dae190200263
--
View it on GitLab: https://salsa.debian.org/debian-gis-team/python-cligj/-/commit/f85bac664804e21930d9abb0ef34dae190200263
You're receiving this email because of your account on salsa.debian.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/pkg-grass-devel/attachments/20201020/fd22cec3/attachment-0001.html>
More information about the Pkg-grass-devel
mailing list