Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (pypi.python.org).
Help us improve Python packaging - Donate today!

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

Release History

Release History

This version
History Node

1.2.0

History Node

1.1.1

History Node

1.1.0

Download Files

Download Files

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

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
pycatalog-1.2.0-py3.5.egg (6.8 kB) Copy SHA256 Checksum SHA256 3.5 Egg Sep 1, 2017
pycatalog-1.2.0.tar.gz (4.6 kB) Copy SHA256 Checksum SHA256 Source Sep 1, 2017

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting