Skip to main content

No project description provided

Project description

nuldc

A simple CLI for consuming Northwestern University Libraries Digital Collections API. It also includes a set of python helpers for rolling your own scripts.

Quickstart

Install it

pip install nuldc

Upgrading to a new verson

pip install --upgrade nuldc

❯ nuldc --help

NULDC

USAGE:
    nuldc works <id> [--as=<format>]
    nuldc collections <id> [--as=<format> --all]
    nuldc search <query> [--model=<model>] [--as=<format>] [--all]
    nuldc csv <query> [--fields=<fields>] [--all] <outfile>
    nuldc xml <query> [--all] <outfile>
    nuldc --version

OPTIONS:
    --as=<format>      get results as [default: opensearch]
    --model=<model>    search model (works,collections,filesets) [default: works]
    --all              get all records from search
    --fields=<fields>  optional set of fields,e.g id,ark,test defaults to all
    -h --help          Show this screen

ARGUMENTS:
    as: opensearch
        iiif

Examples

Get a work

Let's get a work's manifest

nuldc works c1960aac-74f0-4ce8-a795-f713b2e3cc22

Maybe we should grab that work as a IIIF manifest.

nuldc works c1960aac-74f0-4ce8-a795-f713b2e3cc22 --as iiif

Get collection's metadata

nuldc collections ecacd539-fe38-40ec-bbc0-590acee3d4f2

or get metadata as iiif

nuldc collections ecacd539-fe38-40ec-bbc0-590acee3d4f2 --as iiif

Get the whole collection as IIIF, stitching together all the pages

nuldc collections ecacd539-fe38-40ec-bbc0-590acee3d4f2 --as iiif --all

Search for things

Simple search

nuldc search "berkeley AND guitars"

Page through all the results and return one big list of items (limit 200 pages)

nuldc search "trains AND chicago" --all

as iiif

nuldc search "trains AND chicago" --as iiif --all

Save to CSV

Dumping to CSV is simple. By default it dumps all the fields that are "label". If you need to dig into specific fields you can do that as well.

nuldc csv "trains AND chicago" --all example.csv

Let's grab just a few fields.

nuldc csv "trains AND chicago" --all --fields id,title,ark example.csv

It also supports "dot" notation for getting into nested, special purpose fields.

nuldc csv "trains AND chicago" --all --fields id,title,ark,subject.id example.csv

Save to xml

You can export search results to an xml serialization of the data structure as well.

nuldc xml "trains AND chicago" out.xml

Or get all the records

nuldc xml "trains AND chicago" --all all.xml

Pipeable and Works great with jq!

All of this is pipe-able too, so if you want to do further analysis with JQ or pipe data through some other processing pipeline, go for it! For instance, let's grab just a coupld of fields from the json and reformat it into a simplified shape.

nuldc search "berkeley AND guitars" --all | jq -r '.data[] | [.title,.id]

Advanced Search

You can search within specific fields and perform complex searches using the opensearch/elasticsearch query-string-query syntax. The query syntax is valid for all "search" operations: search, csv, xml.

Examples:

Get a csv file of all works that have a fileset label including "recto"

nuldc csv "file_sets.label:Recto*" ~/Desktop/rectos.csv

Look at results that have a subject that includes "Chicago"

nuldc search "subject.label:*Chicago*"

Get Results that have a subject of "Chicago" AND a title of "Bus"

nuldc search "subject.label:*Chicago* AND title:bus"

Get results from a known collection that were modified before a certain date:

nuldc search "modified_date:<2022-10-01 AND collection.title:Berkeley*"

Development

This project is built using POETRY. Follow the latest install instructions, clone the repository and poetry install.

Tests

This project uses pytest and has a very small set of tests to ensure things are running as expected.

From a poetry shell run pytest.

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

nuldc-0.12.0.tar.gz (8.0 kB view details)

Uploaded Source

Built Distribution

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

nuldc-0.12.0-py3-none-any.whl (9.8 kB view details)

Uploaded Python 3

File details

Details for the file nuldc-0.12.0.tar.gz.

File metadata

  • Download URL: nuldc-0.12.0.tar.gz
  • Upload date:
  • Size: 8.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.2 CPython/3.11.0 Linux/6.8.0-1021-azure

File hashes

Hashes for nuldc-0.12.0.tar.gz
Algorithm Hash digest
SHA256 ea04f21e509ddf4f158c8735b472c0cf88982ae439bf9b295479581fac4db159
MD5 afeae3eec8f244d60dee8d34052e95c9
BLAKE2b-256 35411ecbe911b11580be1fa9b0eef7acfa445219564bf19805f81bb337bd8d9f

See more details on using hashes here.

File details

Details for the file nuldc-0.12.0-py3-none-any.whl.

File metadata

  • Download URL: nuldc-0.12.0-py3-none-any.whl
  • Upload date:
  • Size: 9.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.2 CPython/3.11.0 Linux/6.8.0-1021-azure

File hashes

Hashes for nuldc-0.12.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8bea7a1871e597c2ebfa7ec19bc165551172ccb18802d6aef5cfed515c154dfa
MD5 c487b4b383cb979998c4cbf1f78575ac
BLAKE2b-256 a14ddeb01f6f10c5995eeb962cb091054760ee194bb7acc10b7d4ce81fb45b5a

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 Pingdom Monitoring Sentry Error logging StatusPage Status page