Skip to main content

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.cql)
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 can 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

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.0.5.tar.gz (8.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sruthi-0.0.5-py3-none-any.whl (8.6 kB view details)

Uploaded Python 3

File details

Details for the file sruthi-0.0.5.tar.gz.

File metadata

  • Download URL: sruthi-0.0.5.tar.gz
  • Upload date:
  • Size: 8.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.8.3

File hashes

Hashes for sruthi-0.0.5.tar.gz
Algorithm Hash digest
SHA256 ebedcb284548ab2aabb1d1f0bb4804f0838fc680b877d7bb335dbe436827b0f2
MD5 b892cfa95503c13d86545a62a2b4f07d
BLAKE2b-256 644bf5a6f968b0c8fce4398b04fb54e90a569f52812e3d0984fe95a9ccbe169e

See more details on using hashes here.

File details

Details for the file sruthi-0.0.5-py3-none-any.whl.

File metadata

  • Download URL: sruthi-0.0.5-py3-none-any.whl
  • Upload date:
  • Size: 8.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.8.3

File hashes

Hashes for sruthi-0.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 43267dfee9ce200b9a3a386846c232780b98f0b40a4b4e23274bcbf6d322d8d3
MD5 2158536078d64cc8f89c8728f1671bbf
BLAKE2b-256 53506a6eaa191ee8493c1b745a65adfb17d0d75e1a688fcb6b7970e0da0cfabd

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page