Skip to main content

SRU client for Python

Project description

sruthi

sruthi is a client for python to make SRU requests (Search/Retrieve via URL).

Currently only SRU 1.2 is supported.

Table of Contents

Installation

sruthi is available on PyPI, so to install it simply use:

$ pip install sruthi

Usage

See the examples directory for more scripts.

searchretrieve operation

import sruthi

records = sruthi.searchretrieve('https://suche.staatsarchiv.djiktzh.ch/SRU/', query='Zurich')

for record in records:
    # print fields from schema
    print(record['reference'])
    print(record['title'])
    print(record['date'])
    print(record['extra']['link']) # extra record data is available at the 'extra' key
# you can get more information at each step
import sruthi

# note: records is an iterator
records = sruthi.searchretrieve('https://suche.staatsarchiv.djiktzh.ch/SRU/', query='Human')
print(records.sru_version)
print(records.count)

for record in records:
    print(record)
    print(record['schema'])

The return value of searchretrieve is iterable, so you can easily loop over it. Or you can use indices to access elements, e.g. records[1] to get the second elemenet, or records[-1] to get the last one.

Even slicing is supported, so you can do things like only iterate over the first 5 elements using

for records in records[:5]:
   print(record)

explain operation

import sruthi

info = sruthi.explain('https://suche.staatsarchiv.djiktzh.ch/SRU/')
print(info.server)
print(info.database)
print(info.index)
print(info.schema)

Schemas

sruthi does not make any assumptions about the record data schema. The data is provided as-is (as a flattend dict). sruthi has been tested with the following schemas:

Release

To create a new release, follow these steps (please respect Semantic Versioning):

  1. Adapt the version number in sruthi/__init__.py
  2. Update the CHANGELOG with the version
  3. Create a pull request to merge develop into master (make sure the tests pass!)
  4. Create a new release/tag on GitHub (on the master branch)
  5. The publication on PyPI happens via GitHub Actions on every tagged commit

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

sruthi-0.1.2.tar.gz (9.2 kB view hashes)

Uploaded Source

Built Distribution

sruthi-0.1.2-py3-none-any.whl (9.3 kB view hashes)

Uploaded Python 3

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