PrefixAccess¶
- class domilite.accessors.PrefixAccess(prefix: str, tag: T)[source]¶
Bases:
MutableMapping[str,str|bool],Generic[T]Provide access to attributes automatically prefixed with some value.
For example, a prefix accessor for aria provides access to keys like current-page which when rendered will be rendered as aria-current-page.
Attributes Summary
Attribute prefix
The tag to access
Methods Summary
clear()get(k[,d])items()keys()pop(k[,d])If key is not found, d is returned if given, otherwise KeyError is raised.
popitem()as a 2-tuple; but raise KeyError if D is empty.
remove(name)Remove an attribute with the given name.
set(name, value)Set an attribute with the given name.
setdefault(k[,d])update([E, ]**F)If E present and has a .keys() method, does: for k in E: D[k] = E[k] If E present and lacks .keys() method, does: for (k, v) in E: D[k] = v In either case, this is followed by: for k, v in F.items(): D[k] = v
values()Attributes Documentation
- prefix: str¶
Attribute prefix
- tag: T¶
The tag to access
Methods Documentation
- clear() None. Remove all items from D.¶
- get(k[, d]) D[k] if k in D, else d. d defaults to None.¶
- items() a set-like object providing a view on D's items¶
- keys() a set-like object providing a view on D's keys¶
- pop(k[, d]) v, remove specified key and return the corresponding value.¶
If key is not found, d is returned if given, otherwise KeyError is raised.
- popitem() (k, v), remove and return some (key, value) pair¶
as a 2-tuple; but raise KeyError if D is empty.
- remove(name: str) T[source]¶
Remove an attribute with the given name.
This is useful for chaining methods on a tag.
- set(name: str, value: str | bool) T[source]¶
Set an attribute with the given name.
This is useful for chaining methods on a tag.
- setdefault(k[, d]) D.get(k,d), also set D[k]=d if k not in D¶
- update([E, ]**F) None. Update D from mapping/iterable E and F.¶
If E present and has a .keys() method, does: for k in E: D[k] = E[k] If E present and lacks .keys() method, does: for (k, v) in E: D[k] = v In either case, this is followed by: for k, v in F.items(): D[k] = v
- values() an object providing a view on D's values¶