dk.collections package¶
Submodules¶
dk.collections.OrderedSet module¶
Ordered Set. Items can only be added once, further additions have no effect. The iterator iterates over the items in insertion order.
dk.collections.invdict module¶
Inversable dictionary.
dk.collections.mmap module¶
dk.collections.pset module¶
Mapping classes.
-
class
dk.collections.pset.
defset
(defval)[source]¶ Bases:
dk.collections.pset.pset
pset with default value.
-
class
dk.collections.pset.
keyval
(key, val)¶ Bases:
tuple
-
key
¶ Alias for field number 0
-
val
¶ Alias for field number 1
-
-
class
dk.collections.pset.
pset
(items=(), **attrs)[source]¶ Bases:
dict
This code is placed in the Public Domain, or released under the wtfpl (http://sam.zoy.org/wtfpl/COPYING) wherever PD is problematic.
Property Set class. A property set is an object where values are attached to attributes, but can still be iterated over as key/value pairs. The order of assignment is maintained during iteration. Only one value allowed per key.
>>> x = pset() >>> x.a = 42 >>> x.b = 'foo' >>> x.a = 314 >>> x pset(a=314, b='foo')
-
class
dk.collections.pset.
record
(items=(), **attrs)[source]¶ Bases:
dk.collections.pset.pset
A property set with commit, rollback, and encoding translation.
-
fields
¶ Verbose name of all fields.
-
-
dk.collections.pset.
test_pset
()[source]¶ Unit tests...
>>> request = pset(REQUEST={}, META={}, path='/', user=None, session={}, method='GET', ... COOKIES={}, LANGUAGE_CODE='no') >>> p = page(request) >>> p.forms = 'fruit' >>> p.forms.foo = 'bar' >>> print p.forms.foo bar >>> p.forms.fob = 'baz' >>> print p.forms.fob baz >>> x = pset() >>> x.a Traceback (most recent call last): ... AttributeError: a >>> y = pset(a=1, b=2, c=3) >>> y.a 1 >>> y.b 2 >>> y.c 3 >>> z = pset() >>> z.a = 1 >>> z.b = 2 >>> z.c = 3 >>> z[1] 2 >>> z pset(a=1, b=2, c=3) >>> class Point(pset): pass >>> p = Point(x=11, y=22) >>> p Point(y=22, x=11)
dk.collections.sdict module¶
dk.collections.xmlrec module¶
-
class
dk.collections.xmlrec.
xmlrec
(soup, **types)[source]¶ Bases:
dk.collections.pset.pset
-
convert
= {'date': <function Date>, 'int': <type 'int'>, 'NOK': <function NOK>, 'bool': <function Boolean>, 'datetime': <function Datetime>}¶
-
Module contents¶
Abstract Data Types – mostly record types with different semantics.