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-0.4.0.tar.gz
(11.4 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-0.4.0-py3-none-any.whl
(14.2 kB
view details)
File details
Details for the file pycdstar-0.4.0.tar.gz.
File metadata
- Download URL: pycdstar-0.4.0.tar.gz
- Upload date:
- Size: 11.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
320c9f396a235a14d6bcae8f7b205f6a4484d695bfd34cd372bce94f2c541f30
|
|
| MD5 |
76071f4c569cefa10ba615933e95ebf9
|
|
| BLAKE2b-256 |
f383b7896f4b9c5106a028731988d630b82d7982bfcee85e24dd189d47c6b41d
|
File details
Details for the file pycdstar-0.4.0-py3-none-any.whl.
File metadata
- Download URL: pycdstar-0.4.0-py3-none-any.whl
- Upload date:
- Size: 14.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
89f773a102b51f7f37f13453626dfa08ae3d0d34c61f10dba48bb5033d1f8606
|
|
| MD5 |
719ceead219df9f5fd25020399f46865
|
|
| BLAKE2b-256 |
052cf4dc5a6d699df61c034015b8740443e2f16f1e42de71de19ef5bd3d6a535
|