sugar.core.meta module¶
Metadata related classes, Attr and Meta
- class sugar.core.meta.Attr(*args, **kwargs)[source]¶
Bases:
MutableMappingA class which behaves like a dictionary.
- Parameters:
data (dict) – Dictionary with initial keywords.
Basic Usage
You can use the following syntax to modify or access data in this class.
>>> attr = Attr() >>> attr.comment = 'bla' >>> attr['another_comment'] = 'yeah' >>> print(attr.get('comment')) bla >>> print(attr['comment']) bla >>> print(attr.comment) bla
- setdefault(k, *args)[source]¶
Like
setdefault(), but creates a new Attr instance when no value is present and no default is setExample:
>>> seqs = read() >>> seqs[0].meta.setdefault('_stockholm').setdefault('GR').mykey = 'value' >>> print(seqs[0].meta._stockholm) Attr(GR=Attr(mykey='value'))