PKwþH^¶i[ [ zipfreeinfo/zipfreeinfo.py# -*- coding: utf-8 -*- import requests import json import collections api_return_codes = {401: "Unauthorized", 402: "Payment Required", 413: "Request Entity Too Large", 400: "Bad Request (Malformed Payload)", 429: "Too Many Requests", 200: "OK"} #credentials for smartystreets.com API AUTH_ID = '' AUTH_TOKEN = '' ZIP_LOOKUP_URL = 'https://us-zipcode.api.smartystreets.com/lookup?auth-id={}&auth-token={}&zipcode={}' zipdata = collections.defaultdict(str) def set_auth_credentials(auth_id=None, auth_token=None): """sets the auth_id and auth_token globally""" if auth_id is not None and auth_token is not None: global AUTH_ID global AUTH_TOKEN AUTH_ID = auth_id AUTH_TOKEN = auth_token return 0 print("Function takes two arguments, auth_id and auth_token as strings") return None def set_zip_info(zip_code=None): """given a zip code, it returns a json dictionary object with nested data""" if zip_code is None: print("Function takes zip_code as a string") return None if AUTH_ID is None or AUTH_TOKEN is None: return -1 resp = requests.get(ZIP_LOOKUP_URL.format(AUTH_ID, AUTH_TOKEN, zip_code)) if resp.status_code is not 200: return api_return_codes[resp.status_code] zipinfo = resp.json() zipdata['zip_code'] = zip_code zipdata['city'] = zipinfo[0]['city_states'][0]['city'] zipdata['state_abbreviation'] = zipinfo[0]['city_states'][0]['state_abbreviation'] zipdata['county_fips'] = zipinfo[0]['zipcodes'][0]['county_fips'] zipdata['county_name'] = zipinfo[0]['zipcodes'][0]['county_name'] zipdata['longitude'] = zipinfo[0]['zipcodes'][0]['longitude'] zipdata['latitude'] = zipinfo[0]['zipcodes'][0]['latitude'] zipdata['state'] = zipinfo[0]['city_states'][0]['state'] return zipdata def get_zipcode(): """returns the zip code as a string""" return zipdata['zip_code'] def get_city(): """returns the city""" return zipdata['city'] def get_state(): """returns the state""" return zipdata['state'] def get_state_abbreviation(): """returns the abbreviated state""" return zipdata['state_abbreviation'] def get_county_fips(): """returns the five-digit Federal Information Processing Standard (FIPS) code""" return zipdata['county_fips'] def get_county_name(): """returns the county name""" return zipdata['county_name'] def get_longitude(): """returns the longitude as a float""" return zipdata['longitude'] def get_latitude(): """returns the latitude as a float""" return zipdata['latitude'] PKfþHÎDºÓÓzipfreeinfo/exampleapp.pyimport zipfreeinfo zipfreeinfo.set_auth_credentials('your auth id','your auth token') # Returns a dictionary with nested data structures containing zip code data # Also sets internal zipdata structure with zip code data, which can be returned with function calls print(zipfreeinfo.get_zip_info("30141")) print(zipfreeinfo.get_zipcode()) # returns string print(zipfreeinfo.get_city()) # returns string print(zipfreeinfo.get_state()) # returns string print(zipfreeinfo.get_state_abbreviation()) # returns string print(zipfreeinfo.get_county_fips()) # returns string print(zipfreeinfo.get_county_name()) # returns string print(zipfreeinfo.get_latitude()) # returns float print(zipfreeinfo.get_longitude()) # returns float PKfþH|+xxzipfreeinfo/__init__.py# -*- coding: utf-8 -*- __author__ = 'Marcellus Easley' __email__ = 'marcellus.easley@gmail.com' __version__ = '0.1.0' PKš"þH1 ,»+zipfreeinfo-1.0.0.dist-info/DESCRIPTION.rst=============================== zipfreeinfo =============================== .. image:: https://img.shields.io/pypi/v/zipfreeinfo.svg :target: https://pypi.python.org/pypi/zipfreeinfo .. image:: https://img.shields.io/travis/marcelluseasley/zipfreeinfo.svg :target: https://travis-ci.org/marcelluseasley/zipfreeinfo .. image:: https://readthedocs.org/projects/zipfreeinfo/badge/?version=latest :target: https://zipfreeinfo.readthedocs.io/en/latest/?badge=latest :alt: Documentation Status .. image:: https://pyup.io/repos/github/marcelluseasley/zipfreeinfo/shield.svg :target: https://pyup.io/repos/github/marcelluseasley/zipfreeinfo/ :alt: Updates Provided a zip code, you are given information about that location. * Free software: MIT license * Documentation: https://zipfreeinfo.readthedocs.io. Features -------- * Provides city, state, latitude/longitude data for a given zip code Credits --------- This package was created with Cookiecutter_ and the `audreyr/cookiecutter-pypackage`_ project template. .. _Cookiecutter: https://github.com/audreyr/cookiecutter .. _`audreyr/cookiecutter-pypackage`: https://github.com/audreyr/cookiecutter-pypackage ======= History ======= 0.1.0 (2016-07-19) ------------------ * First release on PyPI. PKš"þHÃ]ãã)zipfreeinfo-1.0.0.dist-info/metadata.json{"classifiers": ["Development Status :: 2 - Pre-Alpha", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Natural Language :: English", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.6", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5"], "extensions": {"python.details": {"contacts": [{"email": "marcellus.easley@gmail.com", "name": "Marcellus Easley", "role": "author"}], "document_names": {"description": "DESCRIPTION.rst"}, "project_urls": {"Home": "https://github.com/marcelluseasley/zipfreeinfo"}}}, "generator": "bdist_wheel (0.26.0)", "keywords": ["zipfreeinfo"], "license": "MIT license", "metadata_version": "2.0", "name": "zipfreeinfo", "summary": "Provided a zip code, you are given information about that location.", "test_requires": [{"requires": []}], "version": "1.0.0"}PKš"þH_­ò) )zipfreeinfo-1.0.0.dist-info/top_level.txtzipfreeinfo PKš"þHìndªnn!zipfreeinfo-1.0.0.dist-info/WHEELWheel-Version: 1.0 Generator: bdist_wheel (0.26.0) Root-Is-Purelib: true Tag: py2-none-any Tag: py3-none-any PKš"þHȳ]gg$zipfreeinfo-1.0.0.dist-info/METADATAMetadata-Version: 2.0 Name: zipfreeinfo Version: 1.0.0 Summary: Provided a zip code, you are given information about that location. Home-page: https://github.com/marcelluseasley/zipfreeinfo Author: Marcellus Easley Author-email: marcellus.easley@gmail.com License: MIT license Keywords: zipfreeinfo Platform: UNKNOWN Classifier: Development Status :: 2 - Pre-Alpha Classifier: Intended Audience :: Developers Classifier: License :: OSI Approved :: MIT License Classifier: Natural Language :: English Classifier: Programming Language :: Python :: 2 Classifier: Programming Language :: Python :: 2.6 Classifier: Programming Language :: Python :: 2.7 Classifier: Programming Language :: Python :: 3 Classifier: Programming Language :: Python :: 3.3 Classifier: Programming Language :: Python :: 3.4 Classifier: Programming Language :: Python :: 3.5 =============================== zipfreeinfo =============================== .. image:: https://img.shields.io/pypi/v/zipfreeinfo.svg :target: https://pypi.python.org/pypi/zipfreeinfo .. image:: https://img.shields.io/travis/marcelluseasley/zipfreeinfo.svg :target: https://travis-ci.org/marcelluseasley/zipfreeinfo .. image:: https://readthedocs.org/projects/zipfreeinfo/badge/?version=latest :target: https://zipfreeinfo.readthedocs.io/en/latest/?badge=latest :alt: Documentation Status .. image:: https://pyup.io/repos/github/marcelluseasley/zipfreeinfo/shield.svg :target: https://pyup.io/repos/github/marcelluseasley/zipfreeinfo/ :alt: Updates Provided a zip code, you are given information about that location. * Free software: MIT license * Documentation: https://zipfreeinfo.readthedocs.io. Features -------- * Provides city, state, latitude/longitude data for a given zip code Credits --------- This package was created with Cookiecutter_ and the `audreyr/cookiecutter-pypackage`_ project template. .. _Cookiecutter: https://github.com/audreyr/cookiecutter .. _`audreyr/cookiecutter-pypackage`: https://github.com/audreyr/cookiecutter-pypackage ======= History ======= 0.1.0 (2016-07-19) ------------------ * First release on PyPI. PKš"þH<ò¹üü"zipfreeinfo-1.0.0.dist-info/RECORDzipfreeinfo/__init__.py,sha256=iHi8ZVGor8eh3JXHBUvaYo88nn4PkMpvC4ERbjhwa9c,120 zipfreeinfo/exampleapp.py,sha256=XZDcQUS-sJuJpwA7gWKDsof3DbsGdCH6g5bu0mTZnwg,723 zipfreeinfo/zipfreeinfo.py,sha256=YzWHr4r3Z79tFGpdglIDKtyv_zMb3UmO50WSOLNPtwc,2651 zipfreeinfo-1.0.0.dist-info/DESCRIPTION.rst,sha256=WBBQFSQ9Lz9ic5_QWGd-HfnupQ6NHAw6270plen8RfI,1304 zipfreeinfo-1.0.0.dist-info/METADATA,sha256=C3SNcb9Re1_uYJWxjBbgDT4e1jg1N9jIr25TIak9MYk,2151 zipfreeinfo-1.0.0.dist-info/RECORD,, zipfreeinfo-1.0.0.dist-info/WHEEL,sha256=GrqQvamwgBV4nLoJe0vhYRSWzWsx7xjlt74FT0SWYfE,110 zipfreeinfo-1.0.0.dist-info/metadata.json,sha256=jv8vcf63nbHZk-3RnH_uARHydAbOa-FbkBY6UUc3ReU,995 zipfreeinfo-1.0.0.dist-info/top_level.txt,sha256=iStVpMh-GfmhU6l3dzOt7v17Pe5mMS994qQZamZ7ZyQ,12 PKwþH^¶i[ [ zipfreeinfo/zipfreeinfo.pyPKfþHÎDºÓÓ“ zipfreeinfo/exampleapp.pyPKfþH|+xx zipfreeinfo/__init__.pyPKš"þH1 ,»+Jzipfreeinfo-1.0.0.dist-info/DESCRIPTION.rstPKš"þHÃ]ãã)«zipfreeinfo-1.0.0.dist-info/metadata.jsonPKš"þH_­ò) )Õzipfreeinfo-1.0.0.dist-info/top_level.txtPKš"þHìndªnn!(zipfreeinfo-1.0.0.dist-info/WHEELPKš"þHȳ]gg$Õzipfreeinfo-1.0.0.dist-info/METADATAPKš"þH<ò¹üü"~!zipfreeinfo-1.0.0.dist-info/RECORDPK ̺$