Skip to main content

Geddit

Simple zero-configuration retrieval of resources by URL.

This module provides a single geddit function which takes a single parameter specifying the URL to fetch. It will return a bytes object with the contents of the resource at that URL or will raise an exception specific to the URL scheme.

This library is intended to be used in situations where scheme-specific configuration can be inferred from the environment. (For example, in Google Cloud-hosted environments there is usually a default identity which the services run as. This identity will be used to fetch resources specified via the gs or sm schemes.)

This library is not intended to replace general use libraries such as requests.

Examples

from geddit import geddit

# The default scheme is file://
geddit('file:///etc/issue')     # == b'Debian GNU/Linux 10 \\n \\l\n\n'
geddit('/etc/issue')            # == b'Debian GNU/Linux 10 \\n \\l\n\n'
geddit('./README.md')           # Raises: ValueError

# Fetching using HTTP over TLS
geddit('https://www.gov.uk/bank-holidays.json')[:20]  # == b'{"england-and-wales"'

# HTTP errors are reported
geddit('https://www.example.com/not-found')  # raises requests.exceptions.HTTPError

# Google Storage objects. Uses default application credentials.
geddit('gs://my-bucket/some-object')          # fetches latest generation
geddit('gs://my-bucket/some-object#abcdefg')  # fetches generation abcdefg

# Google Secret Manager secrets. Uses default application credentials.
geddit('sm://my-project/some-secret')       # fetches latest version
geddit('sm://my-project/some-secret#3')     # fetches version 3

# Data URLs.
geddit('data:application/x-yaml;charset=utf-8;base64,eyJmb28iOjF9')  # == b'{"foo":1}'

Requirements

  • Python >= 3.11.

Installation

The latest release of this library on PyPI can be installed using pip:

$ pip3 install geddit

The library can also be installed directly from the git repository if you want the most up-to-date version.

$ pip3 install git+https://gitlab.developers.cam.ac.uk/uis/devops/lib/geddit.git

For developers, the tool can be installed from a cloned repo using pip:

$ cd /path/to/this/repo
$ pip3 install -e .

Publishing a new release

See the guidebook section on publishing to PyPI for more information.

License

This software is licensed under an MIT-like software license. See the LICENSE file for the full text of the license.

Scheme-specific notes

file

The file scheme is the default scheme. Only absolute paths can be specified.

https

There is no support for HTTP basic authentication as that involves putting the cleartext password into the URL.

Non-TLS ("http") URLs are not supported.

gs and sm

Only default application credentials are supported. To use specific credentials, set the GOOGLE_APPLICATION_CREDENTIALS environment variable to the absolute path to some JSON-formatted credentials.

data

Data URLs are not good way of passing secrets since their values are transparent. They can be useful for transferring non-secret configuration or for use in development environments.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

geddit-2.2.1.tar.gz (4.2 kB view details)

Uploaded Source

Built Distribution

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

geddit-2.2.1-py3-none-any.whl (4.9 kB view details)

Uploaded Python 3

File details

Details for the file geddit-2.2.1.tar.gz.

File metadata

  • Download URL: geddit-2.2.1.tar.gz
  • Upload date:
  • Size: 4.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.14.7

File hashes

Hashes for geddit-2.2.1.tar.gz
Algorithm Hash digest
SHA256 bf215f386eb6162a9c0aef854874ec53344b154d191946bcd72aa9fbcf817c6c
MD5 f5aaf18793859bb0ad7086f5798d37a8
BLAKE2b-256 b7cf5f91d113d2fd16b771bbb1f088b1687fc23fd50c725781135f02de2a4b60

See more details on using hashes here.

File details

Details for the file geddit-2.2.1-py3-none-any.whl.

File metadata

  • Download URL: geddit-2.2.1-py3-none-any.whl
  • Upload date:
  • Size: 4.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.14.7

File hashes

Hashes for geddit-2.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 0a66ddb8324ce0d5f4480ac0322893b728cc73a4911f4a3b2a31d4f8203432c2
MD5 200b197f64f374c348851355dc06e8e8
BLAKE2b-256 c6d5441eaeb351214de90bf439f31fff10b46f8288586eb58c03a246817a2b7a

See more details on using hashes here.

Release history Release notifications | RSS feed

2.2.8

2 files

2.2.7

2 files

2.2.6

2 files

2.2.5

2 files

2.2.4

2 files

2.2.3

2 files

2.2.2

2 files

This release

2.2.1 This release

2 files

2.2.0

2 files

2.1.8

2 files

2.1.7

2 files

2.1.6

2 files

2.1.5

2 files

2.1.4

2 files

2.1.3

2 files

2.1.1

2 files

2.1.0

2 files

2.0.0

2 files

1.1.0

2 files

1.0.3

2 files

1.0.2

2 files

1.0.1

2 files

0.1.1

2 files

0.1.0

2 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