chula.collection – Collection package¶
chula.data.base¶
Flexible collection that supports both dictionary and attribute style access.
- class chula.collection.base.Collection¶
Example usage:
>>> from chula import collection >>> person = collection.Collection() >>> person.name = 'Mr. Smith' >>> person.age = 20 >>> person.timezone = 'PST' >>> >>> print person.age 20
>>> print person['timezone'] PST
>>> print person {'timezone': 'PST', 'age': 20, 'name': 'Mr. Smith'}
- add(key, value)¶
Allow set via method
Parameters: - key (str) – Key to be set
- value (Any) – Value of key
- copy_into(collection)¶
Copy the current object into the object passed
Parameters: collection (chula.collection.Collection) – Object to be copied into Return type: chula.collection.Collection (filled copy)
chula.data.restricted¶
Collection with a configurable, but enforced number of attributes. This class is useful for situations where you you need to enforce every instance of the collection has the exact same structure.
- class chula.collection.restricted.RestrictedCollection¶
Collection class with a pre-determined set of validkeys attributes
- strip()¶
Purge privatekeys from the collection. This is useful when passing the collection along, without it’s private keys. This does actually delete the private keys, and thus acts on itself. If this isn’t what you want use copy.deepcopy().