Attr

class sunpy.net.attr.Attr[source] [edit on github]

Bases: object

This is the base for all attributes.

Methods Summary

collides(other)

update_values(adict)

Clients will use this method to register their values for subclasses of Attr.

Methods Documentation

collides(other)[source] [edit on github]
classmethod update_values(adict)[source] [edit on github]

Clients will use this method to register their values for subclasses of Attr.

The input has be a dictionary, with each key being a subclass of Attr. The value for each key should be a list of tuples with each tuple of the form (Name, Description). If you do not want to add a description, you can put None or an empty string. We sanitize the name you provide by removing all special characters and making it all lower case. If it still invalid we will append to the start of the name to make it a valid attribute name. This is an ugly workaround, so please try to pick a valid attribute name.

It is recommended that clients register values for all attrs used by their `_can_handle_query` method.

Parameters

adcit (dict) – A dictionary that has keys of Attr. Each key should have a list of tuples as it value. Each tuple should be a pair of strings. First string is the attribute name you want to register Second string is the description of the attribute.

Example

>>> from sunpy.net import attr, attrs 
>>> attr.Attr.update_values({attrs.Instrument: [('AIA', 'AIA is in Space.'),
...                         ('HMI', 'HMI is next to AIA.')]}) 
>>> attr.Attr._attr_registry[attrs.Instrument] 
attr(name=['aia', 'hmi'], name_long=['AIA', 'HMI'],
    desc=['AIA is in Space.', 'HMI is next to AIA.'])
>>> attr.Attr._attr_registry[attrs.Instrument].name 
['aia', 'hmi']
>>> attr.Attr._attr_registry[attrs.Instrument].name_long 
['AIA', 'HMI']
>>> attr.Attr._attr_registry[attrs.Instrument].desc 
['AIA is in Space.', 'HMI is next to AIA.']
>>> attrs.Instrument.aia, attrs.Instrument.hmi 
(<Instrument('AIA')>, <Instrument('HMI')>)