Coverage for /opt/obspy/update-docs/src/obspy/obspy/core/util/attribdict : 95%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
# -*- coding: utf-8 -*- AttribDict class for ObsPy.
:copyright: The ObsPy Development Team (devs@obspy.org) :license: GNU Lesser General Public License, Version 3 (http://www.gnu.org/copyleft/lesser.html) """
""" A class which behaves like a dictionary.
:type data: dict, optional :param data: Dictionary with initial keywords.
.. rubric:: Basic Usage
You may use the following syntax to change or access data in this class.
>>> stats = AttribDict() >>> stats.network = 'BW' >>> stats['station'] = 'ROTZ' >>> stats.get('network') 'BW' >>> stats['network'] 'BW' >>> stats.station 'ROTZ' >>> x = stats.keys() >>> x = sorted(x) >>> x[0:3] ['network', 'station'] """
""" An AttribDict can be initialized in two ways. It can be given an existing dictionary as a simple argument or alternatively all keyword arguments will become (key, value) pairs.
>>> attrib_dict_1 = AttribDict({"a":1, "b":2}) >>> attrib_dict_2 = AttribDict(a=1, b=2) >>> print attrib_dict_1 AttribDict({'a': 1, 'b': 2}) >>> assert(attrib_dict_1 == attrib_dict_2) """ # set default values directly # use overwritable update method to set arguments
# check if we got any default value given at class level return self.defaults[name] # if both are missing check for a given default value
# set default values # update with pickle dictionary
""" Return better readable string representation of AttribDict object.
:type priorized_keys: List of str, optional :param priorized_keys: Keywords of current AttribtDict which will be shown before all other keywords. Those keywords must exists otherwise an exception will be raised. Defaults to empty list. :type min_label_length: int, optional :param min_label_length: Minimum label length for keywords. Defaults to ``16``. :return: String representation of current AttribDict object. """ # determine longest key name for alignment of all items except ValueError: # no keys return "" # check if keys exist # priorized keys first + all other keys
if __name__ == '__main__': import doctest doctest.testmod(exclude_empty=True) |