wardrobe’s documentation

wardrobe is a Python project that provides a stack-based datastructure: StackedDict.

StackedDict is a dictionary-like object with additional methods to save the current state (commit) and restore it (reset).

>>> from wardrobe import StackedDict
>>> clark = StackedDict(top='blue bodysuit', bottom='red underpants',
...                     sex_appeal=True)
>>> clark['bottom']
'red underpants'
>>> clark['friend'] = 'Lois'
>>> dict(clark) == {'top': 'blue bodysuit',
...                 'bottom': 'red underpants',
...                 'friend': 'Lois',
...                 'sex_appeal': True}
True
>>> clark.commit()  
<wardrobe.stackeddict.StackedDict object at 0x...>
>>> clark.update({'top': 'shirt', 'bottom': 'jeans', 'head': 'glasses'})
>>> del clark['sex_appeal']
>>> dict(clark) == {'top': 'shirt',
...                 'bottom': 'jeans',
...                 'head': 'glasses',
...                 'friend': 'Lois'}
True
>>> clark.reset()  
<wardrobe.stackeddict.StackedDict object at 0x...>
>>> dict(clark) == {'top': 'blue bodysuit',
...                 'bottom': 'red underpants',
...                 'friend': 'Lois',
...                 'sex_appeal': True}
True

Contents

Installation

This code is open-source. See License for details.

If you want to contribute to the code, you should go to Contributing to the project documentation.

Install the package with your favorite Python installer. As an example, with pip:

pip install PROJECT

Then, you should be able to use it!

>>> from wardrobe import StackedDict
>>> something = StackedDict()

See API for a detailed usage documentation.

API

This section details wardrobe API. It is automatically generated from sourcecode’s documentation.

wardrobe wardrobe package.
wardrobe.stackeddict StackedDict implementation.
wardrobe.exceptions

About wardrobe

This section is about the project itself.

Vision

wardrobe is about contextual tools for Python. Currently, it provides only one datastructure: StackedDict.

The project may provide more utilities or datastructures in future versions. But StackedDict may also become a standalone library.

License

Copyright (c) 2012, Benoît Bryon. All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  • Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  • Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  • Neither the name of wardrobe nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Authors & contributors

Changelog

0.1 (2012-07-26)
  • Initial implementation of StackedDict: mimics standard dict class.

Why “wardrobe” name?

Because, when one gets dressed, he pushes layers of clothes, then poppes them.

Contributing to the project

This document provides guidelines for people who want to contribute to the wardrobe project.

Create tickets

Please use the bugtracker [1] before starting some work:

  • check if the bug or feature request has already been filed. It may have been answered too!
  • else create a new ticket.
  • if you plan to contribute, tell us, so that we are given an opportunity to give feedback as soon as possible.
  • Then, in your commit messages, reference the ticket with some refs #TICKET-ID syntax.

Fork and branch

  • Work in forks and branches.
  • Prefix your branch with the ticket ID corresponding to the issue. As an example, if you are working on ticket #23 which is about contribute documentation, name your branch like 23-contribute-doc.

Setup a development environment

System requirements:

  • Python [2] version 2.6 or 2.7, available as python command.

    Note

    You may use Virtualenv [3] to make sure the active python is the right one.

  • make and wget to use the provided Makefile.

Execute:

git clone git@github.com/benoitbryon/wardrobe.git
cd wardrobe/
make develop

If you cannot execute the Makefile, read it and adapt the few commands it contains to your needs.

The Makefile

A Makefile is provided to ease development. Use it to:

  • setup the development environment: make develop
  • update it, as an example, after a pull: make update
  • run tests: make test
  • run benchmarks: make benchmark
  • build documentation: make documentation readme

The Makefile is intended to be a live reference for the development environment.

Documentation

Follow style guide for Sphinx-based documentations [4] when editing the documentation.

Test and build

Tests and builds will automatically be triggered before commit:

  • tests include the build of documentation and README as HTML.
  • a Git pre-commit hook [5] is installed during the development environment setup.

If you want to run them manually, use the Makefile.

Indices and tables