Skip to content

Commit

Permalink
new database type, new script for keeping database up to date; VERSIO…
Browse files Browse the repository at this point in the history
…N 3 baby - check that changelog and the new README
  • Loading branch information
buckmaxwell committed Jun 18, 2018
1 parent 4c4926e commit b5a0ddd
Show file tree
Hide file tree
Showing 24 changed files with 42,940 additions and 326 deletions.
Binary file removed .DS_Store
Binary file not shown.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
dist
build
*.pyc
*.egg-info
.DS_Store
22 changes: 21 additions & 1 deletion Changelog
Original file line number Diff line number Diff line change
@@ -1,7 +1,27 @@

Version 3.0.0 2018-06-17
* upgraded database to use data from unitedstateszipcodes.org
+ this means that to use this package commercially you must purchase a license
here -> https://www.unitedstateszipcodes.org/zip-code-database/
* removes yaxis and xaxis
* removes country
* removes tax returns filed
* removes wages
* changes meaning of location to the previous location text
* removes location text
* adds area codes
* adds acceptable cities
* adds county
* adds hascity function
* adds hasareacode function
* add instructions to refresh database intermittently
* removes to_dict -> use dict(obj) instead.
* changed lon to more standard lng

Version 2.0.0 2015-09-14
* removed support for certain non useful parameters

Version 1.7.0 2015-09-14
* added isinradius() for fetching all zip codes within a number of miles
* added new dependency -- haversine
* added __repr__ support for zip code objects
* added __repr__ support for zip code objects
4 changes: 2 additions & 2 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
include README.rst
recursive-include zipcode *.db
include README.md
recursive-include zipcode *.db
79 changes: 79 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# Zipcode
### A simple python package for dealing with zip codes


**IMPORTANT.** This package uses up-to-date data from unitedstateszipcodes.org.
If you wish to use this package for non-commercial purposes, please do! If you
are using this as part of a commercial purpose, that is fine too, but before you
do, you must buy a license to use this data from unitedstateszipcodes.org,
[here](https://www.unitedstateszipcodes.org/zip-code-database/) - the license
will be 40-200 dollars depending on the size of your business.


## Getting started

Simple package for dealing with zip codes in python.
Full documentation at https://pythonhosted.org/zipcode

>>> import zipcode
>>>
>>> myzip = zipcode.isequal('44102')
>>> myzip.state #=> 'OH'
>>> myzip.city #=> 'Cleveland'
>>>
>>> dict(myzip) #=> {'zip_type': u'STANDARD', 'city': u'Cleveland', 'decommissioned': 0, 'zip': u'44102', 'state': u'OH', 'secondary_cities': [u''], 'location': 'Cleveland, OH', 'area_codes': [u'216'], 'lat': 41.48, 'timezone': u'America/New_York', 'lng': -81.74, 'population': 31930}
>>>
>>> #all keys in the dictionary can be fetched with dot notation.
>>>
>>> zipcode.islike('00') #=> list of Zip objects that begin with given prefix.
>>>
>>> cbus = (39.98, -82.98)
>>> zipcode.isinradius(cbus, 20) #=> list of all zip code objects within 20 miles of 'cbus'
>>>
>>>
>>> zipcode.hascity('Cleveland', 'OH') #=> list of zip codes in Cleveland, OH
>>> zipcode.hascity('', 'OH') #=> list of zip codes in OH
>>>
>>>
>>> zipcode.hasareacode(216) #=> list of zip codes associated with 216

## Keeping the database up-to-date

Zip codes don't change very often, but the borders do change, and new zip codes
are added, and others are removed. To keep your zipcode package ever up-to-date
we suggest that you set up a job to keep the sqlite3 database current.

You'll pull the latest version of the database from our server once a month, and
copy it to the install location of your current sqlite3 database.

```bash
$ pip show zipcode
Name: zipcode
Version: 3.0.0
Summary: A simple python package for dealing with zip codes in python.
Home-page: https://github.com/buckmaxwell/zipcode
Author: Max Buck
Author-email: maxbuckdeveloper@gmail.com
License: MIT
Location: /<YOUR/<PATH>
Requires: haversine
```
Note the location line. This is the top level of your version of the zipcode
package. If the whole thing were set to a variable, the database would live at
$LOCATION/zipcode.db - and look something like
/<YOURPATH>/site-packages/zipcode/zipcode.db. For the next part imagine the
whole path to the database is set to $DB_PATH.
Now, take the following and modify the user agent to a value of your choice. The
user agent must begin with robot. We ask that you limit your download requests
to monthly - the database will not change more often than that. You can copy the
script and put it in your crontab or a script that is run by your crontab.
```bash
wget -d --header="User-Agent: robot/<SOME UNIQUE NAME>" https://maxwellbuck.com/downloads/zipcode.db.gz
gunzip zipcode.db.gz
cp zipcode.db $DB_PATH
```
Your all set. Get to it!
22 changes: 0 additions & 22 deletions README.rst

This file was deleted.

174 changes: 0 additions & 174 deletions build/lib/zipcode/__init__.py

This file was deleted.

Binary file removed build/lib/zipcode/zipcode.db
Binary file not shown.
Binary file removed dist/zipcode-2.0.0-py2.py3-none-any.whl
Binary file not shown.
Binary file removed dist/zipcode-2.0.0.tar.gz
Binary file not shown.
38 changes: 38 additions & 0 deletions publish_version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@

# confirm user updated version number
echo 'PyPi asks that we not push versions too frequently; is this an import
verson, or can it be tested locally? y/N'
read answer
if [ "$answer" != "y" ];
then
exit 1
fi

# confirm user updated version number
echo 'did you updated the version number in setup.py? y/N'
read answer
if [ "$answer" != "y" ];
then
exit 1
fi


# confirm necessary files are included
echo 'does your MANIFEST.in have all the necessary files in it? y/N'
read answer
if [ "$answer" != "y" ];
then
exit 1
fi

# move old dist(s) into old_dist folder
mv dist/* old_dist/

# delete old egg
rm -r *.egg-info

# create new dist
python setup.py bdist_wheel --universal

# upload dist to pypi
twine upload dist/*
5 changes: 2 additions & 3 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
[bdist_wheel]
# This flag says that the code is written to work on both Python 2 and Python
# 3. If at all possible, it is good practice to do this. If you cannot, you
# will need to generate wheels for each Python version that you support.
universal=1
# 3.
universal=1
8 changes: 4 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
# Versions should comply with PEP440. For a discussion on single-sourcing
# the version across setup.py and the project code, see
# https://packaging.python.org/en/latest/single_source_version.html
version='2.0.0',
version='3.0.0',

description='A simple python package for dealing with zip codes in python.',
description='A simple python package for dealing with zip codes in python. Free for non commerial use, for commercial use, you need a license. Check out the README on GitHub for details.',

# The project's main homepage.
url='https://github.com/buckmaxwell/zipcode',
Expand Down Expand Up @@ -49,7 +49,7 @@
],

# What does your project relate to?
keywords='zip codes',
keywords='zip code zipcode',

# You can just specify the packages manually here if your project is
# simple. Or you can use find_packages().
Expand All @@ -69,4 +69,4 @@
#},
include_package_data=True

)
)
Loading

0 comments on commit b5a0ddd

Please sign in to comment.