CLI tool for retrieving holding counts for a list of OCNs and libraries, simplified version
Project description
lib-holdings
Based on the https://pypi.org/project/lib-holdings/ Copyright (c) 2024 Max Paulus
Command Line Interface (CLI) tool for retrieving holding counts for a list of OCNs and institutes.
Uses the OCLC API: https://developer.api.oclc.org/
Simplied version which only uses the "wcapi"-scope
Installation
First of all, you will need to have Python installed on your computer and available on the command line. If this sounds scary, consider installing the Anaconda Navigator, an application that comes with Python and a command line.
Once installed, find and run the Anaconda Prompt which is the command line interface.
Again, knowing the command line is not a requirement. Simply copy the following into the window and press enter:
pip install --upgrade lib-holdings-simplified
After the tool has been installed, continue below to learn how it works.
Usage
Preparation
Make sure you have the two input files ready:
- A text file (e.g. .txt) containing OCNs with 1 OCN per line
- A text file (e.g. .txt) containing institute symbols with 1 symbol per line
It is recommended to create a folder on your computer in which you place these input files.
Note down the path to this folder, e.g. C:/Users/username/myfolder (on Windows).
Execute the following command, replacing PATH with your path:
cd PATH
The command line now has access to that folder.
Create an empty folder (e.g. out) in which the results will be stored.
Also, keep your API key and secret handy.
Run the program
Copy and execute the following command, after replacing the indicated arguments.
(Description of the arguments can be found below)
holdings [OPTIONS] INFILE_OCNS INFILE_SYMB OUT_FOLDER
ARGUMENTS:
INFILE_OCNS: name of the text file containing OCNs (1 per line)
INFILE_SYMB: name of the text file containing institute symbols (1 per line)
OUT_FOLDER: output directory
OPTIONS:
--start INTEGER Position of OCN to start with.
--key TEXT OCLC API key.
--secret TEXT OCLC API secret.
--details BOOL Use the detaild search or not (default = True)
Note:
The start option is handy when the program is interrupted or exits with an error. In that case, you can re-run the program, providing the start value shown.
The details option determines which of the URLs is used:
- True = https://americas.discovery.api.oclc.org/worldcat/search/v2/bibs-detailed-holdings
- False = https://americas.discovery.api.oclc.org/worldcat/search/v2/bibs-holdings
Changes
To make a new versions of the package and deploy it to
https://pypi.org/project/lib-holdings-simplified/
see:
https://packaging.python.org/en/latest/tutorials/packaging-projects/
Short step-by-step instructions
- Apply any changes and test locally
- Remove previous package builds from the
/dist-folder - Get the build-package:
python3 -m pip install --upgrade build - Edit
pyproject.tomland change the name to 'lib-holdings-simplified-test' and the version. - Build the distribution:
python3 -m build - Check created distributions in the 'dist'-folder for the correct version number
- Get the twine-package:
python3 -m pip install --upgrade twine - Upload to test repository:
python3 -m twine upload --repository testpypi dist/* - Test in test-application with
python3 -m pip install --upgrade --index-url https://test.pypi.org/simple/ --no-deps lib-holdings-simplified - If all ok:
- Remove test builds from the
/dist-folder - Change back name and set correct version in
pyproject.toml - Create finale distribution with
python3 -m build - Upload to real repository:
python3 -m twine upload dist/*
- Remove test builds from the
Changelog
V 1.0.1
In __main__.py
Regels 45-47: skip transform_records and merge
Lines 68: function transform_records() is no longer used.
In api.py
Line 43: function extract_record_type() is no longer used
V 1.1.0
In api.py
Line 9: Add scope as extra parameter to init function.
Line 11: removed ‘WMS_COLLECTION_MANAGEMENT’ scope.
V 1.2.0
Added '--details'-option
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file lib_holdings_simplified-1.2.0.tar.gz.
File metadata
- Download URL: lib_holdings_simplified-1.2.0.tar.gz
- Upload date:
- Size: 5.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.11.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
52471699528b8ec03d2851a0000d45606c49fc82a2770d25d6dd2c0e3ea2db3c
|
|
| MD5 |
e664aa8e5ecacad7395accf09422ed30
|
|
| BLAKE2b-256 |
1cd29cd2a5248eda40804e6c7ef19ee0279333d1774f18af50402fe597f08270
|
File details
Details for the file lib_holdings_simplified-1.2.0-py3-none-any.whl.
File metadata
- Download URL: lib_holdings_simplified-1.2.0-py3-none-any.whl
- Upload date:
- Size: 7.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.11.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fd868e7e476c547a38adf43d2f042d69aead51fd0654ebb79b494ff7d8993fd9
|
|
| MD5 |
c65ab982a485ce18881250dd5eb4ce2c
|
|
| BLAKE2b-256 |
69d9b511fb1be8c1bc81a169523897ff2d7e1aecd39d32bda8459d999c7bf3fe
|