Skip to main content

pycdstar3: Library and command-line client for GWDG CDSTAR 3.x

This is a client library and command-line toolbelt for accessing a GWDG CDSTAR 3 repository, written in Python (3.4+) and designed to be extensible and used for building your own tools and workflows.

There is already a library called pycdstar for accessing older versions of CDSTAR. The two libraries may be merged at some point, but for now, use pycdstar for CDSTAR 2 and pycdstar3 for CDSTAR 3.

Library

The pycdstar3.CDStar class closely reassembles the actual CDSTAR v3 REST API, one method per API endpoint. It provides basic connection pooling, transaction management, error handling and json parsing on top of the requests library, but tries to stay out of your way otherwise. Use this if you already know the CDSTAR API and need maximum control.

from pycdstar3 import CDStar
cdstar = CDStar("https://cdstar.gwdg.de/demo/v3/", auth=("USER", "PASS"))

with cdstar.begin(autocommit=True):  # Wrap everything in a transaction (optional)
    vault_name = "demo"
    archive_id = cdstar.create_archive(vault_name).id
    cdstar.put_file(vault_name, archive_id, "test.py", __file__)
    
    with cdstar.get_file(vault_name, archive_id, "test.py") as stream:
        with open("/tmp/test.py", "wb") as target:
            for chunk in stream.iter_content(buffsize=1024*64):
                target.write(chunk)

For a more fluent and high-level approach, wrap your CDStar instance in a CDStarVault. This hides the HTTP layer behind an object-oriented API and offers convenient wrappers and methods for the most common operations.

from pycdstar3 import CDStar, CDStarVault
cdstar = CDStar("https://cdstar.gwdg.de/demo/v3/", auth=("USER", "PASS"))

with cdstar.begin(autocommit=True):  # Wrap everything in a transaction (optional)
    vault = CDStarVault(cdstar, "demo")
    file = vault.new_archive().file("test.py")
    file.put(__file__)

    with file.stream() as stream:
        stream.save_to("/tmp/")

Command-Line interface

pycdstar3 is also a command-line toolbox to upload, download or manage data in a CDSTAR repository.

Please note that the command-line interface is made for humans, not scripts. The commands and output may change between releases. If you want to automate CDSTAR, consider implementing your tools directly against the pycdstar3 client library.

Workspace mode

Most pycdstar3 commands require --server and --vault arguments to be set, or CDSTAR_SERVER and CDSTAR_VAULT environment variables to be defined. As an alternative, you can run pycdstar3 init to create a workspace directory. When within this directory (or any sub-directory), the client will switch to workspace mode and read default values for --server, --vault and other settings from workspace configuration. This is particularly useful if you are working with multiple servers or vaults and want to easily switch between them.

# Explicit
pycdstar3 --server https://user:pass@example.com/v3/ --vault myVault search 'dcAuthor=Einstein'

# Environment Variables
export CDSTAR_SERVER=https://user:pass@example.com/v3/
export CDSTAR_VAULT=myVault
pycdstar3 search 'dcAuthor=Einstein'

# Workspace mode
pycdstar3 init  # creates .cdstar/workspace.conf
pycdstar3 search 'dcAuthor=Einstein'

Command Usage

This is an (incomplete) list of (planned) commands. For a complete list, run pycdstar3 -h and for details, see pycdstar3 COMMAND -h.

  • init: Create a new workspace.
  • put Upload files or folders into an archive.
  • get Download or stream a single file from an archive.
  • ls List files in an archive.
  • rm Remove files from an archive.
  • rma Remove archives.
  • meta get/set/list/edit Manage metadata attributes for archives or files.
  • acl get/set/list/edit Manage access control entries and permissions.
  • profile set/get/wait Change storage profile and wait for migrations to complete.
  • zip Download an entire archive as zip or tar.
  • scroll List all IDs in a vault.
  • search Search in a vault.

License

Copyright 2019-2024 Gesellschaft für wissenschaftliche Datenverarbeitung mbH Göttingen
Copyright 2019-2024 Marcel Hellkamp

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Release files for pycdstar3 3.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pycdstar3 3.1.0
File Size Uploaded
pycdstar3-3.1.0.tar.gz 24.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pycdstar3 3.1.0
File Interpreter ABI Platform
pycdstar3-3.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 58.2 kB

Release files / pycdstar3-3.1.0.tar.gz

Download URL pycdstar3-3.1.0.tar.gz
Size 24.1 kB
Tags Source
SHA-256 checksum
How to use checksums
34934f0887636777909bf83d4a90bbe2f9b5b469ba30beb45c6a310e1404526e
BLAKE2b-256 checksum
How to use checksums
51a66bd68c34066edd309af86ffa9c7171475ac460c2dce1ecaca37335c4b468
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-httpx/0.27.2

Release files / pycdstar3-3.1.0-py3-none-any.whl

Download URL pycdstar3-3.1.0-py3-none-any.whl
Size 34.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3265dbb18178367f201a15a92ff6329a1a5c913a9a205a486bf2e9e916850114
BLAKE2b-256 checksum
How to use checksums
a05755bc1efeccfc56ceea3c80d5b27fad95148e450e130a3bcdb773010926f8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-httpx/0.27.2

Release history Release notifications | RSS feed

This release

3.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page