Data structure for complexe enumeration.
Project description
Catalog is a data structure for storing complex enumeration. It provides a clean definition pattern and several options for member lookup.
Supports Python 2.7, 3.3+
Install
pip install pycatalog
Usage
from catalog import Catalog
class Color(Catalog):
_attrs = 'value', 'label', 'other'
red = 1, 'Red', 'stuff'
blue = 2, 'Blue', 'things'
# Access values as Attributes
> Color.red.value
1
> Color.red.label
'Red'
# Call to look up members by attribute value
> Color('Blue', 'label')
Color.blue
# Calling without attribute specified assumes first attribute defined in `_attrs`
> Color(1)
Color.red
Attributes
_attrs: Defines names of attributes of members. (default: ['value'])
_member_class: Override the class used to create members. Create a custom member class by extending CatalogMember.
Methods
_zip: Return all members as a tuple. If attrs are provided as positional arguments, only those attributes will be included, and in that order. Otherwise all attributes are included followed by the member name.
> Color._zip()
(('red', 1, 'Red', 'stuff'), ('blue', 2, 'Blue', 'things'))
> Colot._zip('value', 'label')
((1, 'Red'), (2, 'Blue'))
Changelog
1.2.0 - Add support for Python 2. (Wrong direction. I know)
1.1.1 - Add _zip method
1.0.0 - Initial build and packaging
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
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
File details
Details for the file pycatalog-1.2.0.tar.gz.
File metadata
- Download URL: pycatalog-1.2.0.tar.gz
- Upload date:
- Size: 4.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d0cc1497cdc8a3dd82f2de26bba519955132b5853e85a831cf2f174c85ece986
|
|
| MD5 |
949de381440fc67067c20ad75cb5cc1c
|
|
| BLAKE2b-256 |
37798ca814d4dc511216bbfa4fb009ec2717616c1ed5a292fa657f56845a0922
|
File details
Details for the file pycatalog-1.2.0-py3.5.egg.
File metadata
- Download URL: pycatalog-1.2.0-py3.5.egg
- Upload date:
- Size: 6.8 kB
- Tags: Egg
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
72bbcbc26aa6ae2797e6cbb3af80ec2adc814a9d65ff1e9346b4e9867c5b77fd
|
|
| MD5 |
ae0b623c8881250ca0570b746ab4fb31
|
|
| BLAKE2b-256 |
26bf531c485ab605b222fa84d39d04024128d3b6ff5cc380606174c500349d90
|