-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
new database type, new script for keeping database up to date; VERSIO…
…N 3 baby - check that changelog and the new README
- Loading branch information
1 parent
4c4926e
commit b5a0ddd
Showing
24 changed files
with
42,940 additions
and
326 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
dist | ||
build | ||
*.pyc | ||
*.egg-info | ||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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! |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.