Welcome to CRABpy’s documentation!¶
This library provides access to the CRAB and CAPAKEY webservices operated by the AGIV. Because connecting to these SOAP services from python can be somewhat complicated, this library makes it easier to use the service.
We also plan to offer a somewhat more opionated wrapper around the services to straighten out some rough edges in the API and as an integration point for some caching.
Using CRABpy¶
Using the CRAB webservice¶
Recently, the CRAB service has become public. The need to authenticate has been
removed, making it a whole lot easier to connect. A utility function
crabpy.client.crab_request()
has been provided, similar to
crabpy.client.capakey_request()
. This allows for a slightly different way
of calling methods on the service.
"""
This script demonstrates using the crab client directly or through the
:func:`crabpy.client.crab_request` function.
"""
from crabpy.client import crab_factory, crab_request
crab = crab_factory()
res = crab.service.ListGemeentenByGewestId(1)
print(res)
res = crab.service.ListPostkantonsByGemeenteId(71)
print(res)
res = crab_request(crab, "ListGemeentenByGewestId", 1)
print(res)
res = crab_request(crab, "ListHuisnummersWithStatusByStraatnaamId", 18618)
print(res)
res = crab_request(crab, "GetStraatnaamWithStatusByStraatnaamId", 18618)
print(res)
Using the CAPAKEY webservice¶
This service does still require authentication. This requires a valid account
from agiv. Because the authentication also requires some extra WS-Addressing
headers, a utility function crabpy.client.capakey_request()
has been
provided to make life easier.
"""
This script demonstrates using the capakey client through the
:func:`crabpy.client.capakey_request` function.
"""
from crabpy.client import capakey_factory, capakey_request
capakey = capakey_factory(user="USER", password="PASSWORD")
res = capakey_request(capakey, "ListAdmGemeenten", 1)
print(res)
res = capakey_request(capakey, "ListKadAfdelingenByNiscode", 44021, 1)
print(res)
res = capakey_request(capakey, "ListKadSectiesByKadAfdelingcode", 44021)
print(res)
res = capakey_request(capakey, "ListKadPerceelsnummersByKadSectiecode", 44021, "A", 1)
print(res)
res = capakey_request(capakey, "GetKadPerceelsnummerByCaPaKey", "44021A3675/00A000")
print(res)
Be careful: the CAPAKEY SOAP gateway is deprecated. We advise you the use the CAPAKEY REST gateway instead.
Using a client behind a proxy¶
If you need to connect to CRAB or CAPAKEY through a proxy, you can do so
by passing the proxy parameter to the crabpy.client.crab_factory()
or
crabpy.client.capakey_factory()
.
"""
This script show how to connect to the WS-WRAB service through a proxy.
"""
from crabpy.client import crab_factory
crab = crab_factory(
proxy={
"http": "http://proxy.example.com:3128",
"https": "https://httpsproxy.example.com:3128",
}
)
print(crab.service.ListGemeentenByGewestId(1))
Using the CRAB gateway¶
To make life easier and crab more pythonic, we’ve also implemented a gateway that abstracts some more of the service and provides richer objects as responses.
"""
This script demonstrates using the crab gateway to walk the entire
address tree (street and number) of a `gemeente`.
"""
from crabpy.client import crab_factory
from crabpy.gateway.crab import CrabGateway
g = CrabGateway(crab_factory())
gemeente = g.get_gemeente_by_id(1)
print(str(gemeente))
for s in gemeente.straten:
print("* %s" % s)
for h in s.huisnummers:
print("\t* %s" % h)
for sa in h.subadressen:
print("\t\t* %s" % sa)
The CRAB gateway supports caching through the dogpile caching library. Caching can
be added by passing a configuration dictionary to the CrabGateway
.
Three caching regions will be configured:
- permanent: For requests that can be cached for a very long time, eg. list_gewesten or list_gemeenten.
- long: For requests that can be cached for a fairly long time, eg. list_straten.
- short: For requests that will only be cached for a little while, eg. get_huisnummer_by_id.
"""
This script demonstrates querying the crab gateway while maintaining a cache.
"""
import os
from crabpy.client import crab_factory
from crabpy.gateway.crab import CrabGateway
root = "./dogpile_data/"
if not os.path.exists(root):
os.makedirs(root)
g = CrabGateway(
crab_factory(),
cache_config={
"permanent.backend": "dogpile.cache.dbm",
"permanent.expiration_time": 604800,
"permanent.arguments.filename": os.path.join(root, "crab_permanent.dbm"),
"long.backend": "dogpile.cache.dbm",
"long.expiration_time": 86400,
"long.arguments.filename": os.path.join(root, "crab_long.dbm"),
},
)
aartselaar = g.get_gemeente_by_id(1)
print("Straten in AARTSELAAR")
print("---------------------")
print([str(s) for s in g.list_straten(aartselaar)])
print("Huisnummers in AARTSELAAR Straat1")
print("---------------------------------")
# print([str(h) for h in g.list_huisnummers_by_straat(s)])
p = g.get_gemeente_by_niscode(33021)
print("gemeente: %s" % p.id)
print("naam: %s" % p.naam)
print("niscode: %s" % p.niscode)
print("gewest: %s" % p.gewest)
print("provincie: %s" % p.provincie)
print("taal: %s" % p.taal)
print("centroid: %s" % str(p.centroid))
print("bounding_box: %s" % str(p.bounding_box))
Using the CAPAKEY gateway¶
To make life easier and capakey more pythonic, we’ve also implemented a gateway that abstracts some more of the service and provides richer objects as responses.
"""
This script demonstrates using the capakey gateway to walk the entire
cadastral tree of a `gemeente`.
WARNING: The CapakeyGateway (SOAP) is deprecated, use CapakeyRestGateway (REST) instead.
"""
from crabpy.client import capakey_factory
from crabpy.gateway.capakey import CapakeyGateway
capakey = capakey_factory(user="USER", password="PASSWORD")
g = CapakeyGateway(capakey)
gemeente = g.get_gemeente_by_id(45062)
print(str(gemeente))
for a in gemeente.afdelingen:
print("* %s" % a)
for s in a.secties:
print("\t* %s" % s)
for p in s.percelen:
print("\t\t* %s" % p)
The CAPAKEY gateway supports caching through the dogpile caching library. Caching can
be added by passing a configuration dictionary to the CapakeyGateway
.
Three caching regions will be configured:
- permanent: For requests that can be cached for a very long time, eg. list_gemeenten.
- long: For requests that can be cached for a fairly long time, eg. list_secties_by_afdeling.
- short: For requests that will only be cached for a little while, eg. get_perceel_by_capakey.
Please bear in mind that in this case short can probably be fairly long. We suspect that the database underlying the capakey service is not updated that regularly, so a short caching duration could easily be one hour or even a day.
"""
This script demonstrates querying the capakey gateway while maintaining a cache.
WARNING: The CapakeyGateway (SOAP) is deprecated, use CapakeyRestGateway (REST) instead.
"""
import os
from crabpy.client import capakey_factory
from crabpy.gateway.capakey import CapakeyGateway
capakey = capakey_factory(user="USER", password="PASSWORD")
root = "./dogpile_data/"
if not os.path.exists(root):
os.makedirs(root)
g = CapakeyGateway(
capakey,
cache_config={
"permanent.backend": "dogpile.cache.dbm",
"permanent.expiration_time": 604800,
"permanent.arguments.filename": os.path.join(root, "capakey_permanent.dbm"),
"long.backend": "dogpile.cache.dbm",
"long.expiration_time": 86400,
"long.arguments.filename": os.path.join(root, "capakey_long.dbm"),
"short.backend": "dogpile.cache.dbm",
"short.expiration_time": 3600,
"short.arguments.filename": os.path.join(root, "capakey_short.dbm"),
},
)
gent = g.get_gemeente_by_id(44021)
print("Afdelingen in Gent")
print("------------------")
print([str(a) for a in g.list_kadastrale_afdelingen_by_gemeente(gent)])
print("Secties in GENT AFD 1")
print("---------------------")
print([str(s) for s in g.list_secties_by_afdeling(44021)])
print("Percelen in GENT AFD 1, Sectie A")
print("--------------------------------")
s = g.get_sectie_by_id(44021, "A")
print([str(p) for p in g.list_percelen_by_sectie(s)])
print("Perceel 44021A3675/00A000")
print("-------------------------")
p = g.get_perceel_by_capakey("44021A3675/00A000")
print("perceel: %s" % p.id)
print("capakey: %s" % p.capakey)
print("percid: %s" % p.percid)
print("grondnummer: %s" % p.grondnummer)
print("bisnummer: %s" % p.bisnummer)
print("exponent: %s" % p.exponent)
print("macht: %s" % p.macht)
print("sectie: %s" % p.sectie)
print("afdeling: %s" % p.sectie.afdeling)
See the examples folder for some more sample code.
Warning
Be careful: the CAPAKEY SOAP gateway is deprecated. We advise you the use the CAPAKEY REST gateway instead.
Using the CAPAKEY REST gateway¶
To make life easier and capakey more pythonic, we’ve also implemented a rest gateway that abstracts some more of the service and provides richer objects as responses.
The CAPAKEY REST gateway supports caching through the dogpile caching library. Caching can
be added by passing a configuration dictionary to the CapakeyRestGateway
.
Three caching regions will be configured:
- permanent: For requests that can be cached for a very long time, eg. list_gemeenten.
- long: For requests that can be cached for a fairly long time, eg. list_secties_by_afdeling.
- short: For requests that will only be cached for a little while, eg. get_perceel_by_capakey.
Please bear in mind that in this case short can probably be fairly long. We suspect that the database underlying the capakey service is not updated that regularly, so a short caching duration could easily be one hour or even a day.
"""
This script demonstrates querying the capakey gateway while maintaining a cache.
"""
import os
from crabpy.gateway.capakey import CapakeyRestGateway
root = "./dogpile_data/"
if not os.path.exists(root):
os.makedirs(root)
g = CapakeyRestGateway(
cache_config={
"permanent.backend": "dogpile.cache.dbm",
"permanent.expiration_time": 604800,
"permanent.arguments.filename": os.path.join(root, "capakey_permanent.dbm"),
"long.backend": "dogpile.cache.dbm",
"long.expiration_time": 86400,
"long.arguments.filename": os.path.join(root, "capakey_long.dbm"),
"short.backend": "dogpile.cache.dbm",
"short.expiration_time": 3600,
"short.arguments.filename": os.path.join(root, "capakey_short.dbm"),
}
)
gent = g.get_gemeente_by_id(44021)
print("Afdelingen in Gent")
print("------------------")
print([str(a) for a in g.list_kadastrale_afdelingen_by_gemeente(gent)])
print("Secties in GENT AFD 1")
print("---------------------")
print([str(s) for s in g.list_secties_by_afdeling(44021)])
print("Percelen in GENT AFD 1, Sectie A")
print("--------------------------------")
# print([str(p) for p in g.list_percelen_by_sectie(s)])
print("Perceel 44021A3675/00A000")
print("-------------------------")
p = g.get_perceel_by_capakey("44021A3675/00A000")
print("perceel: %s" % p.id)
print("capakey: %s" % p.capakey)
print("percid: %s" % p.percid)
print("grondnummer: %s" % p.grondnummer)
print("bisnummer: %s" % p.bisnummer)
print("exponent: %s" % p.exponent)
print("macht: %s" % p.macht)
print("sectie: %s" % p.sectie)
print("afdeling: %s" % p.sectie.afdeling)
See the examples folder for some more sample code.
Development¶
Crabpy is still in development, but the general API is stable and we are already using it in production. Generally we’re also just happy to have gotten a SOAP service working in python.
We try to cover as much code as we can with unit tests. You can run them using tox or directly through py.test.
$ tox
# No coverage
$ py.test
# Coverage
$ py.test --cov crabpy --cov-report term-missing tests/
If you have access to the capakey service, you can enter your credentials in the pytest_dist.ini file and use that as a test config. It’s actually best to copy this file and edit the copy instead of the original.
[pytest]
addopts = --crab-integration --capakey-integration --capakey-soap-integration --capakey-soap-user=<username> --capakey-soap-password=<password>
# Integration tests but no coverage
$ py.test -c pytest_<user>.ini
# Integration tests with coverage
$ py.test -c pytest_<user>.ini --cov crabpy --cov-report term-missing tests/
# Running just the CRAB integration tests without using a config file
$ py.test --crab-integration --cov crabpy --cov-report term-missing tests/
API Documentation¶
Client module¶
This module contains utility functions for interacting with AGIV SOAP services.
New in version 0.1.0.
-
crabpy.client.
crab_factory
(**kwargs)[source]¶ Factory that generates a CRAB client.
A few parameters will be handled by the factory, other parameters will be passed on to the client.
Parameters: - wsdl – Optional. Allows overriding the default CRAB wsdl url.
- proxy – Optional. A dictionary of proxy information that is passed
to the underlying
suds.client.Client
Return type: suds.client.Client
Crab gateway module¶
This module contains an opionated gateway for the crab webservice.
New in version 0.3.0.
-
class
crabpy.gateway.crab.
Aardadres
(id, naam, definitie, **kwargs)[source]¶ The nature of an address.
-
class
crabpy.gateway.crab.
Aardgebouw
(id, naam, definitie, **kwargs)[source]¶ The nature of a building.
-
class
crabpy.gateway.crab.
Aardsubadres
(id, naam, definitie, **kwargs)[source]¶ The nature of a subaddress.
-
class
crabpy.gateway.crab.
Aardterreinobject
(id, naam, definitie, **kwargs)[source]¶ The nature of a terreinobject.
-
class
crabpy.gateway.crab.
Aardwegobject
(id, naam, definitie, **kwargs)[source]¶ The nature of a wegobject.
-
class
crabpy.gateway.crab.
Adrespositie
(id, herkomst, geometrie=None, aard=None, metadata=None, **kwargs)[source]¶ The position of an Adres.
This can be used for the position of both
Huisnummer
andSubadres
.A Huisnummer or Subadres, can have more than one Adrespositie, each offering a different interpretation of the position of the Adres. See the herkomst and aard of each Adrespositie to know which one to pick.
-
class
crabpy.gateway.crab.
CrabGateway
(client, **kwargs)[source]¶ A gateway to the CRAB webservice.
-
get_adrespositie_by_id
(id)[source]¶ Retrieve a Adrespositie by the Id.
Parameters: id (integer) – the Id of the Adrespositie Return type: Adrespositie
-
get_deelgemeente_by_id
(id)[source]¶ Retrieve a deelgemeente by the id.
Parameters: id (string) – The id of the deelgemeente. Return type: Deelgemeente
-
get_gebouw_by_id
(id)[source]¶ Retrieve a Gebouw by the Id.
Parameters: id (integer) – the Id of the Gebouw Return type: Gebouw
-
get_gemeente_by_id
(id)[source]¶ Retrieve a gemeente by the crab id.
Parameters: id (integer) – The CRAB id of the gemeente. Return type: Gemeente
-
get_gemeente_by_niscode
(niscode)[source]¶ Retrieve a gemeente by the NIScode.
Parameters: niscode (integer) – The NIScode of the gemeente. Return type: Gemeente
-
get_gewest_by_id
(id)[source]¶ Get a gewest by id.
Parameters: id (integer) – The id of a gewest. Return type: A Gewest
.
-
get_huisnummer_by_id
(id)[source]¶ Retrieve a huisnummer by the Id.
Parameters: id (integer) – the Id of the huisnummer Return type: Huisnummer
-
get_huisnummer_by_nummer_and_straat
(nummer, straat)[source]¶ Retrieve a huisnummer by the nummer and straat
Parameters: - nummer (integer) – The huisnummer of the ‘huisnummer`
- straat – The
Straat
in which the huisnummer is situated.
Return type:
-
get_perceel_by_id
(id)[source]¶ Retrieve a Perceel by the Id.
Parameters: id (string) – the Id of the Perceel Return type: Perceel
-
get_postadres_by_huisnummer
(huisnummer)[source]¶ Get the postadres for a
Huisnummer
.Parameters: huisnummer – The Huisnummer
for which the postadres is wanted. OR A huisnummer id.Return type: A str
.
-
get_postadres_by_subadres
(subadres)[source]¶ Get the postadres for a
Subadres
.Parameters: subadres – The Subadres
for which the postadres is wanted. OR A subadres id.Return type: A str
.
-
get_postkanton_by_huisnummer
(huisnummer)[source]¶ Retrieve a postkanton by the Huisnummer.
Parameters: huisnummer – The Huisnummer
for which the postkanton is wanted.Return type: Postkanton
-
get_provincie_by_id
(niscode)[source]¶ Retrieve a provincie by the niscode.
Parameters: niscode (integer) – The niscode of the provincie. Return type: Provincie
-
get_straat_by_id
(id)[source]¶ Retrieve a straat by the Id.
Parameters: id (integer) – The id of the straat. Return type: Straat
-
get_subadres_by_id
(id)[source]¶ Retrieve a Subadres by the Id.
Parameters: id (integer) – the Id of the Subadres Return type: Subadres
-
get_terreinobject_by_id
(id)[source]¶ Retrieve a Terreinobject by the Id.
Parameters: id (integer) – the Id of the Terreinobject Return type: Terreinobject
-
get_wegobject_by_id
(id)[source]¶ Retrieve a Wegobject by the Id.
Parameters: id (integer) – the Id of the Wegobject Return type: Wegobject
-
get_wegsegment_by_id
(id)[source]¶ Retrieve a wegsegment by the Id.
Parameters: id (integer) – the Id of the wegsegment Return type: Wegsegment
-
list_aardgebouwen
(sort=1)[source]¶ List all aardgebouwen.
Return type: A list
ofAardgebouw
-
list_aardsubadressen
(sort=1)[source]¶ List all aardsubadressen.
Return type: A list
ofAardsubadres
-
list_aardterreinobjecten
(sort=1)[source]¶ List all aardterreinobjecten.
Return type: A list
ofAardterreinobject
-
list_aardwegobjecten
(sort=1)[source]¶ List all aardwegobjecten.
Return type: A list
ofAardwegobject
-
list_adresposities_by_huisnummer
(huisnummer)[source]¶ List all adresposities for a
Huisnummer
.Parameters: huisnummer – The Huisnummer
for which the adresposities are wanted. OR A huisnummer id.Return type: A list
ofAdrespositie
-
list_adresposities_by_nummer_and_straat
(nummer, straat)[source]¶ List all adresposities for a huisnummer and a
Straat
.Parameters: - nummer – A string representing a certain huisnummer.
- straat – The
Straat
for which the adresposities are wanted. OR A straat id.
Return type: A
list
ofAdrespositie
-
list_adresposities_by_subadres
(subadres)[source]¶ List all adresposities for a
Subadres
.Parameters: subadres – The Subadres
for which the adresposities are wanted. OR A subadres id.Return type: A list
ofAdrespositie
-
list_adresposities_by_subadres_and_huisnummer
(subadres, huisnummer)[source]¶ List all adresposities for a subadres and a
Huisnummer
.Parameters: - subadres – A string representing a certain subadres.
- huisnummer – The
Huisnummer
for which the adresposities are wanted. OR A huisnummer id.
Return type: A
list
ofAdrespositie
-
list_deelgemeenten
(gewest=2)[source]¶ List all deelgemeenten in a gewest.
Parameters: gewest – The Gewest
for which the deelgemeenten are wanted. Currently only Flanders is supported.Return type: A list
ofDeelgemeente
.
-
list_deelgemeenten_by_gemeente
(gemeente)[source]¶ List all deelgemeenten in a gemeente.
Parameters: gemeente – The Gemeente
for which the deelgemeenten are wanted. Currently only Flanders is supported.Return type: A list
ofDeelgemeente
.
-
list_gebouwen_by_huisnummer
(huisnummer)[source]¶ List all gebouwen for a
Huisnummer
.Parameters: huisnummer – The Huisnummer
for which the gebouwen are wanted.Return type: A list
ofGebouw
-
list_gemeenten
(gewest=2, sort=1)[source]¶ List all gemeenten in a gewest.
Parameters: - gewest – The
Gewest
for which the gemeenten are wanted. - sort (integer) – What field to sort on.
Return type: - gewest – The
-
list_gemeenten_by_provincie
(provincie)[source]¶ List all gemeenten in a provincie.
Parameters: provincie – The Provincie
for which the gemeenten are wanted.Return type: A list
ofGemeente
.
-
list_geometriemethodegebouwen
(sort=1)[source]¶ List all geometriegebouwen.
Return type: A list
ofGeometriegebouw
-
list_geometriemethodewegsegmenten
(sort=1)[source]¶ List all geometriemethodewegsegmenten.
Return type: A list
ofGeometriemethodewegsegment
-
list_gewesten
(sort=1)[source]¶ List all gewesten in Belgium.
Parameters: sort (integer) – What field to sort on. Return type: A :class`list` of class: Gewest.
-
list_herkomstadresposities
(sort=1)[source]¶ List all herkomstadresposities.
Return type: A list
ofHerkomstadrespositie
-
list_huisnummers_by_perceel
(perceel, sort=1)[source]¶ List all huisnummers on a Pereel.
Generally there will only be one, but multiples are possible.
Parameters: perceel – The Perceel
for which the huisnummers are wanted.Return type: A :class: list of Huisnummer
-
list_huisnummers_by_straat
(straat, sort=1)[source]¶ List all huisnummers in a Straat.
Parameters: straat – The Straat
for which the huisnummers are wanted.Return type: A :class: list of Huisnummer
-
list_organisaties
(sort=1)[source]¶ List all organisaties.
Return type: A list
ofOrganisatie
-
list_percelen_by_huisnummer
(huisnummer)[source]¶ List all percelen for a
Huisnummer
Parameters: huisnummer – The Huisnummer
for which the percelen are wanted.Return type: A list
ofPerceel
-
list_postkantons_by_gemeente
(gemeente)[source]¶ List all postkantons in a
Gemeente
Parameters: gemeente – The Gemeente
for which the potkantons are wanted.Return type: A list
ofPostkanton
-
list_provincies
(gewest=2)[source]¶ List all provincies in a gewest.
Parameters: - gewest – The
Gewest
for which the provincies are wanted. - sort (integer) – What field to sort on.
Return type: - gewest – The
-
list_statushuisnummers
(sort=1)[source]¶ List all statushuisnummers.
Return type: A list
ofStatushuisnummer
-
list_statusstraatnamen
(sort=1)[source]¶ List all statusstraatnamen.
Return type: A list
ofStatusstraatnaam
-
list_statussubadressen
(sort=1)[source]¶ List all statussubadressen.
Return type: A list
ofStatussubadres
-
list_statuswegsegmenten
(sort=1)[source]¶ List all statuswegsegmenten.
Return type: A list
ofStatuswegsegment
-
list_straten
(gemeente, sort=1)[source]¶ List all straten in a Gemeente.
Parameters: gemeente – The Gemeente
for which the straten are wanted.Return type: A list
ofStraat
-
list_subadressen_by_huisnummer
(huisnummer)[source]¶ List all subadressen for a
Huisnummer
.Parameters: huisnummer – The Huisnummer
for which the subadressen are wanted. OR A huisnummer id.Return type: A list
ofGebouw
-
list_terreinobjecten_by_huisnummer
(huisnummer)[source]¶ List all terreinobjecten for a
Huisnummer
Parameters: huisnummer – The Huisnummer
for which the terreinobjecten are wanted.Return type: A list
ofTerreinobject
-
-
class
crabpy.gateway.crab.
Deelgemeente
(id, naam, gemeente_niscode, **kwargs)[source]¶ A subdivision of a
Gemeente
.New in version 0.7.0.
-
set_gateway
(gateway)[source]¶ Parameters: gateway (crabpy.gateway.crab.CrabGateway) – Gateway to use.
-
-
class
crabpy.gateway.crab.
GatewayObject
(**kwargs)[source]¶ Abstract class for objects that are able to use a
crabpy.Gateway.CrabGateway
to find further information.-
gateway
= None¶ The
crabpy.gateway.crab.CrabGateway
to use when making further calls to the CRAB service.
-
set_gateway
(gateway)[source]¶ Parameters: gateway (crabpy.gateway.crab.CrabGateway) – Gateway to use.
-
-
class
crabpy.gateway.crab.
Gebouw
(id, aard, status, methode=None, geometrie=None, metadata=None, **kwargs)[source]¶ A building.
-
class
crabpy.gateway.crab.
Gemeente
(id, naam, niscode, gewest, taal=None, centroid=None, bounding_box=None, metadata=None, **kwargs)[source]¶ The smallest administrative unit in Belgium.
-
set_gateway
(gateway)[source]¶ Parameters: gateway (crabpy.gateway.crab.CrabGateway) – Gateway to use.
-
-
class
crabpy.gateway.crab.
Geometriemethodegebouw
(id, naam, definitie, **kwargs)[source]¶ The geometry method of a
Gebouw
.
-
class
crabpy.gateway.crab.
Geometriemethodewegsegment
(id, naam, definitie, **kwargs)[source]¶ The geometry method of a
Wegsegment
.
-
class
crabpy.gateway.crab.
Gewest
(id, namen=None, centroid=None, bounding_box=None, **kwargs)[source]¶ A large administrative unit in Belgium.
Belgium consists of 3 gewesten. Together they form the entire territory of the country.
-
class
crabpy.gateway.crab.
Herkomstadrespositie
(id, naam, definitie, **kwargs)[source]¶ The origin of an Adressposition.
-
class
crabpy.gateway.crab.
Huisnummer
(id, status, huisnummer, straat_id, metadata=None, **kwargs)[source]¶ A house number.
This is mainly a combination of a street and a house number.
-
class
crabpy.gateway.crab.
Metadata
(begin_datum, begin_tijd, begin_bewerking, begin_organisatie, **kwargs)[source]¶ Metadata about a straat, huisnummer, …
Some of the metadata available is the datum the object was created, the organisation that created it and the type of creation.
-
class
crabpy.gateway.crab.
Organisatie
(id, naam, definitie, **kwargs)[source]¶ An organisation that played a role in the genessis of an object.
-
class
crabpy.gateway.crab.
Perceel
(id, centroid=None, metadata=None, **kwargs)[source]¶ A cadastral Parcel.
A
Terreinobject
is somewhat different from aPerceel
in the source of the data and the information provided. eg. A terreinobject has a centroid and a bounding box, while a perceel also has the centroid, but not the bounding box.
-
class
crabpy.gateway.crab.
Postkanton
(id, **kwargs)[source]¶ A postal code.
Eg. postal code 9000 for the city of Ghent.
-
class
crabpy.gateway.crab.
Provincie
(niscode, naam, gewest, **kwargs)[source]¶ The largest administrative unit within a
Gewest
.New in version 0.4.0.
-
set_gateway
(gateway)[source]¶ Parameters: gateway (crabpy.gateway.crab.CrabGateway) – Gateway to use.
-
-
class
crabpy.gateway.crab.
Statusgebouw
(id, naam, definitie, **kwargs)[source]¶ The current state of a
Gebouw
.
-
class
crabpy.gateway.crab.
Statushuisnummer
(id, naam, definitie, **kwargs)[source]¶ The current state of a huisnummer.
-
class
crabpy.gateway.crab.
Statusstraatnaam
(id, naam, definitie, **kwargs)[source]¶ The current state of a straatnaam.
-
class
crabpy.gateway.crab.
Statussubadres
(id, naam, definitie, **kwargs)[source]¶ The current state of a subadres.
-
class
crabpy.gateway.crab.
Statuswegsegment
(id, naam, definitie, **kwargs)[source]¶ The current state of a wegsegment.
-
class
crabpy.gateway.crab.
Straat
(id, label, gemeente_id, status, straatnaam, taalcode, straatnaam2, taalcode2, metadata=None, **kwargs)[source]¶ A street.
A street object is always located in one and exactly one
Gemeente
.
-
class
crabpy.gateway.crab.
Subadres
(id, subadres, status, huisnummer_id=None, aard=None, metadata=None, **kwargs)[source]¶ An address within a certain
Huisnummer
.These can eg. be postboxes within an appartment complex.
-
class
crabpy.gateway.crab.
Terreinobject
(id, aard, centroid=None, bounding_box=None, metadata=None, **kwargs)[source]¶ A cadastral parcel.
A
Terreinobject
is somewhat different from aPerceel
in the source of the data and the information provided. eg. A terreinobject has a centroid and a bounding box, while a perceel also has the centroid, but not the bounding box.
-
class
crabpy.gateway.crab.
Wegobject
(id, aard, centroid=None, bounding_box=None, metadata=None, **kwargs)[source]¶
-
class
crabpy.gateway.crab.
Wegsegment
(id, status, methode=None, geometrie=None, metadata=None, **kwargs)[source]¶
-
crabpy.gateway.crab.
check_lazy_load_adrespositie
(f)[source]¶ Decorator function to lazy load a
Adrespositie
.
-
crabpy.gateway.crab.
check_lazy_load_gemeente
(f)[source]¶ Decorator function to lazy load a
Gemeente
.
-
crabpy.gateway.crab.
check_lazy_load_huisnummer
(f)[source]¶ Decorator function to lazy load a
Huisnummer
.
-
crabpy.gateway.crab.
check_lazy_load_subadres
(f)[source]¶ Decorator function to lazy load a
Subadres
.
-
crabpy.gateway.crab.
check_lazy_load_terreinobject
(f)[source]¶ Decorator function to lazy load a
Terreinobject
.
-
crabpy.gateway.crab.
check_lazy_load_wegobject
(f)[source]¶ Decorator function to lazy load a
Wegobject
.
-
crabpy.gateway.crab.
check_lazy_load_wegsegment
(f)[source]¶ Decorator function to lazy load a
Wegsegment
.
-
crabpy.gateway.crab.
crab_gateway_request
(client, method, *args)[source]¶ Utility function that helps making requests to the CRAB service.
This is a specialised version of
crabpy.client.crab_request()
that allows adding extra functionality for the calls made by the gateway.Parameters: - client – A
suds.client.Client
for the CRAB service. - action (string) – Which method to call, eg. ListGewesten
Returns: Result of the SOAP call.
- client – A
Capakey gateway module¶
This module contains an opionated gateway for the capakey webservice.
New in version 0.2.0.
-
class
crabpy.gateway.capakey.
Afdeling
(id, naam=None, gemeente=None, centroid=None, bounding_box=None, shape=None, **kwargs)[source]¶ A Cadastral Division of a
Gemeente
.
-
class
crabpy.gateway.capakey.
CapakeyRestGateway
(**kwargs)[source]¶ A REST gateway to the capakey webservice.
New in version 0.8.0.
-
get_kadastrale_afdeling_by_id
(aid)[source]¶ Retrieve a ‘kadastrale afdeling’ by id.
Parameters: aid – An id of a kadastrale afdeling. Return type: A Afdeling
.
-
get_perceel_by_capakey
(capakey)[source]¶ Get a perceel.
Parameters: capakey – An capakey for a perceel. Return type: Perceel
-
get_perceel_by_coordinates
(x, y)[source]¶ Get a perceel.
Parameters: capakey – An capakey for a perceel. Return type: Perceel
-
get_perceel_by_id_and_sectie
(id, sectie)[source]¶ Get a perceel.
Parameters: - id – An id for a perceel.
- sectie – The
Sectie
that contains the perceel.
Return type:
-
get_perceel_by_percid
(percid)[source]¶ Get a perceel.
Parameters: percid – A percid for a perceel. Return type: Perceel
-
get_sectie_by_id_and_afdeling
(id, afdeling)[source]¶ Get a sectie.
Parameters: - id – An id of a sectie. eg. “A”
- afdeling – The
Afdeling
for in which the sectie can be found. Can also be the id of and afdeling.
Return type: A
Sectie
.
-
list_gemeenten
(sort=1)[source]¶ List all gemeenten in Vlaanderen.
Parameters: sort (integer) – What field to sort on. Return type: A list
ofGemeente
.
-
list_kadastrale_afdelingen
()[source]¶ List all kadastrale afdelingen in Flanders.
Parameters: sort (integer) – Field to sort on. Return type: A list
ofAfdeling
.
-
list_kadastrale_afdelingen_by_gemeente
(gemeente, sort=1)[source]¶ List all kadastrale afdelingen in a gemeente.
Parameters: - gemeente – The
Gemeente
for which the afdelingen are wanted. - sort (integer) – Field to sort on.
Return type: - gemeente – The
-
-
class
crabpy.gateway.capakey.
GatewayObject
(**kwargs)[source]¶ Abstract class for all objects being returned from the Gateway.
-
gateway
= None¶ The
crabpy.gateway.capakey.CapakeyGateway
to use when making further calls to the Capakey service.
-
-
class
crabpy.gateway.capakey.
Gemeente
(id, naam=None, centroid=None, bounding_box=None, shape=None, **kwargs)[source]¶ The smallest administrative unit in Belgium.
-
class
crabpy.gateway.capakey.
Perceel
(id, sectie, capakey, percid, adres=None, capatype=None, cashkey=None, centroid=None, bounding_box=None, shape=None, **kwargs)[source]¶ A Cadastral Parcel.
-
class
crabpy.gateway.capakey.
Sectie
(id, afdeling, centroid=None, bounding_box=None, shape=None, **kwargs)[source]¶ A subdivision of a
Afdeling
.
-
crabpy.gateway.capakey.
capakey_rest_gateway_request
(url, headers={}, params={})[source]¶ Utility function that helps making requests to the CAPAKEY REST service.
Parameters: Returns: Result of the call.
-
crabpy.gateway.capakey.
check_lazy_load_afdeling
(f)[source]¶ Decorator function to lazy load a
Afdeling
.
-
crabpy.gateway.capakey.
check_lazy_load_gemeente
(f)[source]¶ Decorator function to lazy load a
Gemeente
.
Gateway exception module¶
This module contains custom errors that can be generated by gateways.
New in version 0.2.0.
-
exception
crabpy.gateway.exception.
GatewayAuthenticationException
(message, soapfault)[source]¶ An exception that signifies something went wrong during authentication.
Wsa module¶
This module contains utiltiy functions for using WSA with SOAP services.
New in version 0.1.0.
Wsse module¶
This module adds a UsernameDigestToken
for use with SOAP services.
New in version 0.2.0.
-
class
crabpy.wsse.
UsernameDigestToken
(username=None, password=None)[source]¶ Represents a basic WS-Security token with password digest
History¶
1.2.4 (23-05-2023)¶
- Foute lijst van deelgemeenten gebruikt (#225)
1.2.3 (15-05-2023)¶
- Limiet van list op 1000 items (#221)
1.2.2 (09-05-2023)¶
- get percelen timeout (#217)
1.2.1 (04-05-2023)¶
- Adressenregister bugfixes
1.2.0 (04-05-2023)¶
- uniformiseer alles naar niscodes en check dat alle niscodes strings zijn (#208)
- errors checken en fine tunen (#209)
1.1.0 (03-05-2023)¶
- Lijst gemeenten statisch maken (#203)
1.0.0 (13-04-2023)¶
- Naar v2 van adressenregister (#185)
- File wordt niet geclosed (#133)
- black, flake8, python2 weg en pre-commit (#195)
- Uitbreidingen aan adressenregister model (#192)
- pip install van crabpy installeert ook een “tests” met alle data van crabpy (#165)
0.16.1 (29-03-2023)¶
- Add user agent header to geo.api calls (#190)
0.16.0 (29-03-2023)¶
- Overschakelen naar nieuwe AGIV services (#183)
0.15.0 (10-12-2021)¶
- Methode list_straten kan meer data laden (#172)
0.14.0 (18-11-2021)¶
- Bounding box geeft strings ipv floats (#168)
0.13.0 (14-09-2021)¶
- Verwijderen python 2 support (#160)
- Vervangen suds-jurko door suds-py (#160)
- Upgraden requirements
0.12.1 (28-01-2021)¶
- Adres toegevoegd aan Perceel (#147)
0.12.0 (24-06-2019)¶
- Switchen naar v2 van de capakey REST-API (#120)
- Mocken van calls naar externe url’s bij testen (#118)
- get_perceel_by_coordinates (#121)
0.11.0 (03-01-2019)¶
- Update deelgemeenten (#110, #116)
- Fix travis tests (#112)
- Update dependencies
0.10.0 (17-07-2018)¶
- Capakey service: change source base map (#95)
- Capakey service: return full geometry (#96)
0.9.0 (20-03-2018)¶
- Remove the deprecated CapakeyGateway (#92)
0.8.3 (07-12-2017)¶
- Fix some unit tests.
- Update some dependencies
- Configure pyup
0.8.2 (25-08-2017)¶
- Add zope.deprecation to setup.py #76
- Upgrade capakey rest service #78
0.8.1 (20-04-2017)¶
- Updated center and bounding box format in responses of the CapakeyRestGateway in accordance with the CapakeyGateway (#73).
0.8.0 (19-04-2017)¶
- Added a CapakeyRestGateway that uses the new Capakey REST service provided by Informatie Vlaanderen. (#45, #53)
- Deprecate Capakey SOAP gateway (#69)
- Fix a bug with list_huisnummers_by_perceel. (#67)
- Dropped support for Python 3.3 and added support for Python 3.6.
0.7.0 (25-01-2016)¶
- Add official support for python 3.5
- Implement list_huisnummers_by_perceel. (#56)
- Implement get_postadres_by_huisnummer and get_postadres_by_subadres. (#57)
- A a property Perceel.postadressen to get the postadressen for a certain Perceel. (#58)
- Implement a Deelgemeente object and list_deelgemeenten, list_deelgemeenten_by_gemeente and get_deelgemeente_by_id. (#63)
0.6.0 (01-06-2015)¶
- Implement operations dealing with Adrespositie. (#37) [TalissaJoly]
- Improve the coverage. (#39) [TalissaJoly]
- Fix a bug with objects that have an empty bounding box. (#46) [TalissaJoly]
- Better handling of unexisting objects. (#49) [TalissaJoly]
- Switch tests to py.test. (#19) [TalissaJoly]
0.5.0 (03-03-2015)¶
- Implement operations dealing with Subadres. This deals with things like postboxes in appartment complexes. (#34) (#40) [TalissaJoly]
- Drop support for python 3.2 (#36)
- Fix a bug with crab.list_aardsubadressen. (#38)
0.4.2 (18-09-2014)¶
- Fix an issue with CRAB Gateway list operations that contain no results. Previously these triggered an error, now they return an empty list. (#33)
- Clean up CHANGES.rst so it works on pypi again.
0.4.1 (05-09-2014)¶
- Fix an issues with pickling in list_gemeente_by_provincie.
- Removed the sort parameter from list_gemeenten_by_provincie since it didn’t work anyway.
0.4.0 (03-09-2014)¶
- Added a bounding box to a CRAB Straat. (#26)
- Added a bounding box to a CRAB Huisnummer. (#27)
- Added a Provincie object. (#31)
0.3.5 (02-09-2014)¶
- Fix hardcoded url in client.py. (#25)
0.3.4 (07-05-2014)¶
- Optimise lazy loading of capakey Gemeente. (#21)
- Optimise lazy loading of capakey Afdeling. (#22)
- General lazy loading optimisations.
- Some slight changes to CRAB lazy loading. (#24)
0.3.3 (02-05-2014)¶
- Added some debugging calls to allow an implementing application to track what calls are being made.
0.3.2 (07-04-2014)¶
- A Gebouw loaded through the crabpy.gateway.crab.CrabGateway.get_gebouw_by_id was not passed a crabpy.gateway.crab.CrabGateway. (#15)
- Always load a full crabpy.gateway.crab.Metadata object when returning from a get*_by_id method. (#13)
- Add a wegobjecten property to a crabpy.gateway.crab.Straat. (#17)
- Add a wegsegmenten property to a crabpy.gateway.crab.Straat. (#18)
- Added support for Coveralls. (#16)
0.3.1 (17-03-2014)¶
- Fixed a bug with lazy loading a Perceel’s capatype or cashkey. (#8)
- Removes duplicates from a list of gemeentes as returned by CRAB. (#10)
- Removed loading a Gemeente with an afdeling to speed up certain queries. (#7)
- Removed a few unneeded requests in the capakey gateway when working with Gemeente.id or Afdeling.id.
- Fixed printing of objects through the __str__ method on python 2.7. (#9)
- Adapted examples for python 3 print. (#11)
0.3.0 (12-03-2014)¶
- Added a Gateway <crabpy.gateway.crab.CrabGateway> for the Crab webservice.
- Added caching to the Crab Gateway using Dogpile
0.2.1 (21-02-2014)¶
- Document how to connect to the services through a proxy.
- Fix an incomplete release.
0.2.0 (03-12-2013)¶
- Added a Gateway <crabpy.gateway.capakey.CapakeyGateway> for the Capakey webservice.
- Added caching to the Capakey Gateway using Dogpile
- Better test coverage. Ability to skip integration tests.
- Added some documentation.
- Removed a dependency for resolving UsernameDigestTokens. This in term removed the original suds from the dependency chain.
- Due to removing those dependencies, compatibility with Python 3.2 and 3.3 is now present.
0.1.0 (25-10-2013)¶
- Initial release
- A working client for the CRAB webservice.
- A working client for the CapaKey webservice.