A python wrapper for the CDStar API
Project description
pycdstar
Python client library for CDStar
Usage
from pycdstar.api import Cdstar
# Initialize a client object, with connection info from a config file
cdstar = Cdstar()
# create a new object
obj = cdstar.get_object()
# with initially no associated metadata
assert obj.metadata is None
# assigning to the metadata property will create a metadata record
obj.metadata = {"creator": "pycdstar"}
# retrieve the now existing object
obj = cdstar.get_object(obj.id)
assert 'creator' in obj.metadata
# again, initially the bitstreams property is an empty list
assert not obj.bitstreams
# we add a bitstream by uploading a local file
bitstream = obj.add_bitstream(fname='README.txt')
# and re-read the object
obj.read()
# a bitstreams read method returns an iterator to allow for streaming,
# i.e. chunked downloads
assert ''.join(list(bitstream.read()))
assert len(obj.bitstreams) == 1
# to make sure the newly created resources are properly indexed, we allow
# for a short delay
sleep(1)
# now we search for a string we know to exist in the uploaded bitstream
res = cdstar.search('ssh')
assert len(res)
# the first element in the search results list has the bitstream as
# associated resource
assert 'ssh' in ''.join(list(res[0].resource.read()))
query = 'pycdstar'
res = cdstar.search(query, index='metadata')
assert len(res)
res = cdstar.search(query, index='fulltext')
assert not len(res)
bitstream.delete()
obj.delete()
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
pycdstar-1.1.0.tar.gz
(16.8 kB
view details)
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
pycdstar-1.1.0-py3-none-any.whl
(17.8 kB
view details)
File details
Details for the file pycdstar-1.1.0.tar.gz.
File metadata
- Download URL: pycdstar-1.1.0.tar.gz
- Upload date:
- Size: 16.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/3.7.3 pkginfo/1.7.0 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.8.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
24eb2ed25d895a49e04ef9ba660f1b520aa117b8b1e5ac4e2d69306e943c9678
|
|
| MD5 |
c3ce82b3d01d8dd15cb04e1b11c0df29
|
|
| BLAKE2b-256 |
a2c81a1fae27f3da11e27978e48bd521941bb849229a994d0cac0badbf288eb6
|
File details
Details for the file pycdstar-1.1.0-py3-none-any.whl.
File metadata
- Download URL: pycdstar-1.1.0-py3-none-any.whl
- Upload date:
- Size: 17.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/3.7.3 pkginfo/1.7.0 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.8.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a7c38ed31f565788d9717dc018adea5d6746925300ee63f77f3bd4e51dc17af7
|
|
| MD5 |
02a32451f4078afc02d42fe77765eaf0
|
|
| BLAKE2b-256 |
1337cba928a13a614741505f173f8505a12d3cde300cd219cdbb7485413afa92
|