Skip to main content
https://secure.travis-ci.org/barberj/shackles.png?branch=develop

Access and inspect attributes shackled to an object. Shackles is MIT Licensed.

Installation

To install configit, simply:

$ pip install shackles

API Documentation

shackles.broken(obj, chain)

Return name of first missing named attribute of object.

If chain is not broken (all attributes are represented in chain) nothing is returned.

# obj.a.b.e
assert shackles.broken(obj, 'a.b.c') == 'c'
shackles.get(obj, chain[, default])

Return value of final named attribute in chain of object.

If a named attribute does not exist, default is returned if provided, otherwise AttributeError is raised.

# obj.a.b
assert shackles.get(obj, 'a.b.c', 5) == 5

# obj.a.b.c = 6
assert shackles.get(obj, 'a.b.c', 5) == 6
shackles.has(obj, chain)

Return True if the chain of attributes exists on the object, False if not.

# obj.a.b.c
assert shackles.has(obj, 'a.b.c']) == True
shackles.walk(obj, chain)

Generate the values of the attributes in the chain by walking the named attributes in the chain from the object.

If a named attribute does not exist, default is returned if provided, otherwise AttributeError is raised.

# a = obj; b = obj; c = obj
# a.name = 'a'; b.name = 'b'; c.name = 'c'
# a.b = b; b.c = c
assert next(shackles.walk(a, 'b.c')).name == 'b'

For further examples refer to included tests.

Contribute

  1. Fork the repository on Github to start making your changes to the develop branch (or branch off of it).

  2. Install to your env or venv by running:

    $ python setup.py develop
  3. Write a test which shows that the bug was fixed or that the feature works as expected.

  4. Send a pull request and bug the maintainer until it gets merged and published. :) Make sure to add yourself to AUTHORS.

Metadata

Release files for shackles 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 shackles 1.0
File Size Uploaded
shackles-1.0.tar.gz 3.4 kB Details

Release files / shackles-1.0.tar.gz

Download URL shackles-1.0.tar.gz
Size 3.4 kB
Tags Source
SHA-256 checksum
How to use checksums
485890b2527aae93a9336a2f3293d38ea82dff95e5953a9e9db6de28e6ae6bb4
BLAKE2b-256 checksum
How to use checksums
e768b93264638e501d16f00da13bbdc0c811c5f151d96afaadf2c7920446ac34
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

1.0 This release

1 release file

0.1.1

1 release file

0.0.2

1 release file

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