Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ This library supports only the v2 api.

pyPostcode consists of a single file (pyPostcode.py) that you can put in your python search path or in site-packages (or dist-packages depending on the platform)
You can also simply run it by putting it in the same directory as you main script file or start a python interpreter in the same directory.
pyPostcode works with Python 2.7.x (you're welcome to test other versions)
pyPostcode works with Python 2.7.x and 3.5.x (you're welcome to test other versions)

### API-key

Expand Down
11 changes: 8 additions & 3 deletions pyPostcode/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,16 @@
pyPostcode is an api wrapper for http://postcodeapi.nu
'''

try:
from urllib.request import urlopen, Request # for Python 3
except ImportError:
from urllib2 import urlopen, Request # for Python 2

import urllib2
import json
import logging


__version__ = '0.4'
__version__ = '0.5'


class pyPostcodeException(Exception):
Expand Down Expand Up @@ -61,7 +64,7 @@ def request(self, path=None):
"X-Api-Key": self.api_key,
}

result = urllib2.urlopen(urllib2.Request(
result = urlopen(Request(
self.url + path, headers=headers,
))

Expand All @@ -70,6 +73,8 @@ def request(self, path=None):

resultdata = result.read()

if isinstance(resultdata, bytes):
resultdata = resultdata.decode("utf-8") # for Python 3
jsondata = json.loads(resultdata)

if self.api_version >= (2, 0, 0):
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
setup(
name = 'pyPostcode',
packages = ['pyPostcode'],
version = '0.3',
version = '0.5',
description = 'Request information about Dutch addresses from the PostcodeApi.nu API',
author = 'Stefan Jansen',
author_email = 'stefan@steffex.net',
Expand Down