Skip to main content

Client-side libraries for the SEPA platform (Python3)

Project description

SEPA-python3-APIs

Client-side libraries for the SEPA platform (Python3)

Installation and usage

$ pip3 install sepy

Clone the repository.

cd SEPA-python3-APIs
sudo python3 setup.py build
sudo python3 setup.py sdist
sudo python3 setup.py install

To use the classes you have to import them in this way:

from sepy.<the class you want to import> import *

For example, if you want to import the SAPObject (used to handle JSAP files) you have to write:

from sepy.SAPObject import *

This library consists of 5 modules that can be used for different purposes:

  • SAPObject: An handler class for SAP files
  • SEPA: A low-level class used to develop a client for SEPA
  • ConnectionHandler: A class for connection handling
  • Exceptions
  • tablaze: A runnable script (also callable as a function, to nicely print SEPA output)

Let's talk about some classes deeply:

SEPA

These APIs allow to develop a client for the SEPA platform using a simple interface. First of all the class SEPA must be initialized. Then the standard methods to interact with the broker are available.

Parameters:

  • sapObject : A SAPObject file Default = None
  • logLevel : A number indicating the desired log level. Default = 40 The parameters are optional. If present, they activate query, update, subscribe, methods by SAPObject pick. If absent, only the equivalnt sparql_* methods are available, giving the host communication information each time.

Attributes:

  • logger
  • sap: the SAPObject
  • connectionManager : The underlying responsible for network connections

Creating a SEPA client

mySAP = open(path_to_sap,"r")
sap = SAPObject(yaml.load(mySAP))
sc = SEPA(sapObject=sap)

Query and Update

These four methods (query, sparql_query, update, sparql_update, query_all, clear) expect either a sap entry or a SPARQL query/update. In addition, it is possible to overwrite the sap communication parameters with sepa. When a new query/update is issued, it may be preferrable to catch the RegistrationFailedExceptions, TokenExpiredException and TokenRequestFailedException errors. The query methods return the SEPA answer.

Subscribe and Unsubscribe

The subscribe and sparql_subscribe primitive requires a sap entry or a SPARQL query, an alias for the subscription, an handler (a lambda expression or a method with two parameters, one for added, the other for removed) and if needed the overwriting params for communication. The unsubscribe primitive only needs to know the ID of the subscription.

SAPObject

This package supports Semantic Application Profiles. The package is encoding free, since it expects a dictionary in input. Therefore, for a ysap we have

mySAP = open(path_to_sap,"r")
sap = SAPObject(yaml.load(mySAP))

while for a jsap we have

mySAP = open(path_to_sap,"r")
sap = SAPObject(json.load(mySAP))

Something else?

Documentation is being written...

Foreseen changes

Minors, plus the addition of some utilities.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sepy-0.4.tar.gz (16.5 kB view details)

Uploaded Source

Built Distribution

sepy-0.4-py3-none-any.whl (25.1 kB view details)

Uploaded Python 3

File details

Details for the file sepy-0.4.tar.gz.

File metadata

  • Download URL: sepy-0.4.tar.gz
  • Upload date:
  • Size: 16.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/46.4.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.3

File hashes

Hashes for sepy-0.4.tar.gz
Algorithm Hash digest
SHA256 1e4e00b7b5067626668e9befa37042c264b1822309fe99bb9fee0642da1b6173
MD5 1c357b0246a01e8007b9a9b3af858116
BLAKE2b-256 a8c9704ab49c9a2e15489e95d0ff8302400054b0439f1f7c938fc630c02dae44

See more details on using hashes here.

File details

Details for the file sepy-0.4-py3-none-any.whl.

File metadata

  • Download URL: sepy-0.4-py3-none-any.whl
  • Upload date:
  • Size: 25.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/46.4.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.3

File hashes

Hashes for sepy-0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 3d9e73ef197f329c1f09c7f85a65735d400881b320373d68a3079ebd3f1572b2
MD5 9389bbec102979fa7c6b0319883bb63e
BLAKE2b-256 9b6d41d723d8dfbb943f35138b21ae53909a55fa33451a52d89775dc17ba5d4e

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page