Skip to main content

A library for dealing with Service Interface for Real-time Information (SIRI) data

Project description

Latest PyPI version

A library for dealing with Service Interface for Real-time Information (SIRI) data

Contains:

  • Auto-generated python classes for dealing with SIRI data.

  • A method to parse SIRI XML.

  • A method to serialize objects into SIRI XML

This library leans heavily on the output and functions of xsdata

No warranty is provided with this library. This library does not defend against XML attacks.

Installation

$ pip install siri

Usage

Parse a file

>>> from siri import parse
>>> parse('my_siri_file.xml')

Parse an XML string

>>> from siri import parse
>>> xml_string = """
    <?xml version="1.0" encoding="UTF-8"?>
        <ns0:Siri xmlns:ns0="http://www.siri.org.uk/siri" version="2.0">
            <ns0:SubscriptionResponse>
                <ns0:ResponseTimestamp>2021-01-01T00:00:00</ns0:ResponseTimestamp>
                <ns0:ResponderRef>Responder Ref</ns0:ResponderRef>
                <ns0:ResponseStatus>
                    <ns0:ResponseTimestamp>2021-01-01T00:00:00</ns0:ResponseTimestamp>
                    <ns0:SubscriberRef>Subscriber Ref</ns0:SubscriberRef>
                    <ns0:SubscriptionRef>1</ns0:SubscriptionRef>
                    <ns0:Status>true</ns0:Status>
                </ns0:ResponseStatus>
            </ns0:SubscriptionResponse>
        </ns0:Siri>
    """
>>> siri_object = parse(xml_string)
>> print(siri_object.subscription_response.response_status.subscription_ref)
1

Build and serialize a SIRI object

>>> from siri import Siri, SubscriptionResponse, ResponseStatus
>>>
>>> obj = Siri(
>>>     subscription_response=SubscriptionResponse(
>>>      response_timestamp=datetime.datetime(2021, 1, 1).isoformat(),
>>>      responder_ref="Responder Ref",
>>>      response_status=ResponseStatus(
>>>          response_timestamp=datetime.datetime(2021, 1, 1).isoformat(),
>>>          subscriber_ref="Subscriber Ref",
>>>          subscription_ref="1",
>>>          status=True,
>>>      )
>>>  )
>>>
>>> serialize(obj)

"""<?xml version="1.0" encoding="UTF-8"?>
<ns0:Siri xmlns:ns0="http://www.siri.org.uk/siri" version="2.0">
    <ns0:SubscriptionResponse>
        <ns0:ResponseTimestamp>2021-01-01T00:00:00</ns0:ResponseTimestamp>
        <ns0:ResponderRef>Responder Ref</ns0:ResponderRef>
        <ns0:ResponseStatus>
            <ns0:ResponseTimestamp>2021-01-01T00:00:00</ns0:ResponseTimestamp>
            <ns0:SubscriberRef>Subscriber Ref</ns0:SubscriberRef>
            <ns0:SubscriptionRef>1</ns0:SubscriptionRef>
            <ns0:Status>true</ns0:Status>
        </ns0:ResponseStatus>
    </ns0:SubscriptionResponse>
</ns0:Siri>"""

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

siri-0.1.0.tar.gz (184.6 kB view details)

Uploaded Source

Built Distribution

siri-0.1.0-py3-none-any.whl (220.2 kB view details)

Uploaded Python 3

File details

Details for the file siri-0.1.0.tar.gz.

File metadata

  • Download URL: siri-0.1.0.tar.gz
  • Upload date:
  • Size: 184.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.8.10

File hashes

Hashes for siri-0.1.0.tar.gz
Algorithm Hash digest
SHA256 9fa4e35f66869740ac66c2f1024ce2cd44325c875d1bbcc1f5d5c66e98a106f6
MD5 91821d649c4c042862d0eb732ac18619
BLAKE2b-256 5407b6b07e8ef466c0654f37d30eb03188e8e55f9e29bec22638cf669351aa59

See more details on using hashes here.

File details

Details for the file siri-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: siri-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 220.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.8.10

File hashes

Hashes for siri-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 43e7707f359506b4e18b8b5a710b9899647cb6ee5998f13f66577cad3946c5ac
MD5 fde3e81cf4f4f81658ecfc85b88247d7
BLAKE2b-256 e9967b668a10b912db6e27a51818d2824da4e043c64b15293595a788334f396e

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