Skip to content

Commit

Permalink
Merge pull request #25 from fitnr/v0.5.2
Browse files Browse the repository at this point in the history
v0.5.2
  • Loading branch information
fitnr authored Jan 22, 2022
2 parents 53401af + 83bbc5e commit 3299d23
Show file tree
Hide file tree
Showing 15 changed files with 177 additions and 186 deletions.
66 changes: 66 additions & 0 deletions .github/workflows/python.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# This file is part of censusgeocode.
# https://github.com/fitnr/censusgeocode

# Licensed under the General Public License (version 3)
# http://opensource.org/licenses/LGPL-3.0
# Copyright (c) 2015-7, Neil Freeman <[email protected]>

name: Test and deploy

on:
push:
pull_request:
branches: [master]

jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
python: ["3.7", "3.8", "3.9", "3.10"]

steps:
- uses: actions/checkout@v2

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python }}
cache: 'pip'
cache-dependency-path: setup.cfg

- name: Install package
run: |
python -m pip install -U pip
pip install '.[tests]'
- run: make test

deploy:
needs: test
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
environment: production
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: "3.10"
cache: 'pip'
cache-dependency-path: setup.cfg

- name: Install build requirements
run: |
python -m pip install -U pip
pip install build
- run: make build

- name: Publish package
if: startsWith(github.ref, 'refs/tags')
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
34 changes: 0 additions & 34 deletions .travis.yml

This file was deleted.

18 changes: 7 additions & 11 deletions HISTORY.rst → HISTORY
Original file line number Diff line number Diff line change
@@ -1,61 +1,57 @@
0.5.1
0.5.2
-----
* Accept either "zip" or "zipcode" as an argument in `CensusGeocode.address` (#24).
* Add warning to `CensusGeocode.batch()` when trying send more than 10,000 records
* Move packaging metadata to setup.cfg and pyproject.toml
* Use github actions for automated tests

0.5.1
-----
* Fix empty default values (#23)

0.5.0
-----

* Removed hard-coded benchmarks and vintages, which were out of date. Refer to Census Geocoder documentation for a list of active benchmarks and vintages.

0.4.4
-----

* Handle misformatted batch responses from the Census
* Add more options for command line tool
* Codify support for Python 3.7, 3.8. Drop support for Python 3.4

0.4.3
-----

* Fixed bug in parsing addressbatch results in some versions of Python (thanks @summonholmes)

0.4.2
-----

* Fix reversed coordinate order in batch addresses

0.4.1
-----

* Add static methods to module
* Update vintages and benchmarks.

0.4.0
-----

* Add support for address batch functionality, including to command line tool

0.3.0
-----

* Better error reporting when API is down.
* Use `requests[security]` to fix SSL 3 errors, bump required `requests` version.
* Combine Py 2 and Py 3 codebases.
* Add timeout parameter to `CensusGeocode.fetch` (thanks @mxr)

0.2.3
-----

* Always yield a `ValueError` when Census API is broken.
* Internal refactor to simplify keyword arguments.

0.2.2
-----

* Improve deployment and fix readme

0.2.1
-----

* Add command line tool
2 changes: 0 additions & 2 deletions MANIFEST.in

This file was deleted.

7 changes: 3 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,14 @@

.PHONY: install build upload clean deploy test

install: ; python setup.py install
install: ; pip install .

test: ; python setup.py test
test: ; python -m unittest tests/test_*.py

deploy: build
twine upload dist/*

build: | clean
python setup.py bdist_wheel --universal
python setup.py sdist
python -m build

clean:; rm -rf dist build
55 changes: 9 additions & 46 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
Census Geocode
--------------

Census Geocode is a light weight Python wrapper for the US Census [Geocoder API](http://geocoding.geo.census.gov/geocoder/), compatible with both Python 2 and 3. It comes packaged with a simple command line tool for geocoding an address to a longitude and latitude, or a batch file into a parsed address and coordinates.
Census Geocode is a light weight Python wrapper for the US Census [Geocoder API](http://geocoding.geo.census.gov/geocoder/), compatible with Python 3. It comes packaged with a simple command line tool for geocoding an address to a longitude and latitude, or a batch file into a parsed address and coordinates.

It's strongly recommended to review the [Census Geocoder docs](https://geocoding.geo.census.gov/geocoder/Geocoding_Services_API.pdf) before using this module.
It's strongly recommended to review the [Census Geocoder docs](https://www.census.gov/programs-surveys/geography/technical-documentation/complete-technical-documentation/census-geocoder.html) before using this module.

Basic example:

Expand All @@ -12,7 +12,7 @@ import censusgeocode as cg

cg.coordinates(x=-76, y=41)
cg.onelineaddress('1600 Pennsylvania Avenue, Washington, DC')
cg.address('1600 Pennsylvania Avenue', city='Washington', state='DC', zipcode='20006')
cg.address('1600 Pennsylvania Avenue', city='Washington', state='DC', zip='20006')
cg.addressbatch('data/addresses.csv')
```

Expand Down Expand Up @@ -70,60 +70,23 @@ Queries return a CensusResult object, which is basically a Python list with an e
'TRACT': '216600'
}],
'Census Tracts': [{
'AREALAND': 86404594,
'AREAWATER': 650526,
'BASENAME': '2166',
'CENTLAT': '+41.0361462',
'CENTLON': '-075.9801252',
'COUNTY': '079',
'FUNCSTAT': 'S',
'GEOID': '42079216600',
'INTPTLAT': '+41.0379841',
'INTPTLON': '-075.9743749',
'LSADC': 'CT',
'MTFCC': 'G5020',
# snip
'NAME': 'Census Tract 2166',
'OBJECTID': 61245,
'OID': 20790277158250,
'STATE': '42',
'TRACT': '216600'
}],
'Counties': [{
'AREALAND': 2305974186,
'AREAWATER': 41240020,
'BASENAME': 'Luzerne',
'CENTLAT': '+41.1768961',
'CENTLON': '-075.9890400',
'COUNTY': '079',
'COUNTYCC': 'H1',
'COUNTYNS': '01209183',
'FUNCSTAT': 'A',
'GEOID': '42079',
'INTPTLAT': '+41.1727868',
'INTPTLON': '-075.9760345',
'LSADC': '06',
'MTFCC': 'G4020',
# snip
'NAME': 'Luzerne County',
'OBJECTID': 866,
'OID': 27590277115518,
'STATE': '42'
}],
'States': [{
'AREALAND': 115884236236,
'AREAWATER': 3395797284,
'BASENAME': 'Pennsylvania',
'CENTLAT': '+40.9011252',
'CENTLON': '-077.8369164',
'DIVISION': '2',
'FUNCSTAT': 'A',
'GEOID': '42',
'INTPTLAT': '+40.9024957',
'INTPTLON': '-077.8334514',
'LSADC': '00',
'MTFCC': 'G4000',
# snip
'NAME': 'Pennsylvania',
'OBJECTID': 37,
'OID': 27490163788605,
'REGION': '1',
'STATE': '42',
'STATENS': '01779798',
Expand All @@ -136,8 +99,8 @@ Queries return a CensusResult object, which is basically a Python list with an e

By default, the geocoder uses the "Current" vintage and benchmarks. To use another vintage or benchmark, use the `CensusGeocode` class:
````python
import censusgeocode
cg = censusgeocode.CensusGeocode(benchmark='Public_AR_Current', vintage='Census2020_Current')
from censusgeocode import CensusGeocode
cg = CensusGeocode(benchmark='Public_AR_Current', vintage='Census2020_Current')
cg.onelineaddress(foobar)
````

Expand Down Expand Up @@ -175,7 +138,7 @@ censusgeocode --csv tests/fixtures/batch.csv

Or from stdin, using `-` as the filename:
````
cat tests/fixtures/batch.csv | censusgeocode --csv -
head tests/fixtures/batch.csv | censusgeocode --csv -
````

According to the Census docs, the batch geocoder is limited to 10,000 rows.
Expand Down
5 changes: 5 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# This file is part of censusgeocode.
# https://github.com/fitnr/censusgeocode
[build-system]
requires = ["setuptools>=60.5.0", "wheel"]
build-backend = 'setuptools.build_meta'
43 changes: 40 additions & 3 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,42 @@
[bdist_wheel]
universal = 1

# -*- coding: utf-8 -*-
[metadata]
license_files = LICENSE.txt
name = censusgeocode
version = attr: censusgeocode.__version__
description = Thin Python wrapper for the US Census Geocoder
long_description = file: README.md
long_description_content_type = text/markdown
keywords= census, geocode, api
author = Neil Freeman
author_email = [email protected]
url = https://github.com/fitnr/censusgeocode
license = GNU General Public License v3 (GPLv3)
classifiers =
Development Status :: 4 - Beta
Intended Audience :: Developers
License :: OSI Approved :: GNU General Public License v3 (GPLv3)
Natural Language :: English
Programming Language :: Python :: 3.7
Programming Language :: Python :: 3.8
Programming Language :: Python :: 3.9
Programming Language :: Python :: 3.10
Operating System :: OS Independent

[options]
package_dir =
=src
packages = find:
install_requires =
requests[security]>=2.27.0,<3
requests-toolbelt>=0.9.0,<1
python_requires = >= 3.6, <4

[options.extras_require]
tests = vcrpy>=4.1.1,<5

[options.packages.find]
where = src

[options.entry_points]
console_scripts =
censusgeocode = censusgeocode.__main__:main
45 changes: 1 addition & 44 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,47 +10,4 @@

from setuptools import setup

with open('censusgeocode/__init__.py') as i:
version = next(r for r in i.readlines() if '__version__' in r).split('=')[1].strip('"\' \n')

with open('README.md') as f:
readme = f.read()

setup(
name='censusgeocode',
version=version,
description='Thin Python wrapper for the US Census Geocoder',
long_description=readme,
long_description_content_type='text/markdown',
keywords='census geocode api',
author='Neil Freeman',
author_email='[email protected]',
url='https://github.com/fitnr/censusgeocode',
license='GNU General Public License v3 (GPLv3)',
classifiers=[
'Development Status :: 4 - Beta',
'Intended Audience :: Developers',
'License :: OSI Approved :: GNU General Public License v3 (GPLv3)',
'Natural Language :: English',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Operating System :: OS Independent',
],
install_requires=[
'requests[security]>=2.18,<3',
'requests-toolbelt >=0.8.0, <1',
'six'
],
tests_require=[
'vcrpy>=1.11.1, <1.12',
],
packages=['censusgeocode'],
test_suite='tests',
entry_points={
'console_scripts': [
'censusgeocode=censusgeocode.__main__:main',
],
},
)
setup()
Loading

0 comments on commit 3299d23

Please sign in to comment.