SunPy util

sunpy.util Package

Functions

deprecated(since[, message, name, …])

Used to mark a function or class as deprecated.

dict_keys_same(list_of_dicts)

Makes sure that a list of dictionaries all have the same keys.

expand_list(inp)

Expand a list of lists or tuples.

expand_list_generator(inp)

get_sys_dict()

Test which packages are installed on system.

get_width()

Gets the width of the current terminal.

hash_file(path)

Returns the SHA-256 hash of a file.

replacement_filename(path)

Return a replacement path if input path is currently in use.

system_info()

Takes dictionary from sys_info() and prints the contents in an attractive fashion.

unique(itr[, key])

Return only unique elements of a sequence.

Classes

MetaDict(*args)

A class to hold metadata associated with a sunpy.map.Map derivative.

SunpyDeprecationWarning

A warning class to indicate a deprecated feature.

SunpyMetadataWarning

Warning class for cases metadata is missing.

SunpyPendingDeprecationWarning

A warning class to indicate a soon-to-be deprecated feature.

SunpyUserWarning

The primary warning class for Sunpy.

SunpyWarning

The base warning class from which all Sunpy warnings should inherit.

Class Inheritance Diagram

Inheritance diagram of sunpy.util.metadata.MetaDict, sunpy.util.exceptions.SunpyDeprecationWarning, sunpy.util.exceptions.SunpyMetadataWarning, sunpy.util.exceptions.SunpyPendingDeprecationWarning, sunpy.util.exceptions.SunpyUserWarning, sunpy.util.exceptions.SunpyWarning

sunpy.util.config Module

This module provides SunPy’s configuration file functionality.

Functions

load_config()

Read the “sunpyrc” configuration file.

copy_default_config([overwrite])

Copies the default sunpy config file to the user’s config directory.

print_config()

Print current configuration options.

sunpy.util.datatype_factory_base Module

This module provides the base registration factory used for all SunPy data/net factories.

Classes

BasicRegistrationFactory([…])

Generalized registerable factory type.

NoMatchError

Exception for when no candidate class is found.

MultipleMatchError

Exception for when too many candidate classes are found.

ValidationFunctionError

Exception for when no candidate class is found.

Class Inheritance Diagram

Inheritance diagram of sunpy.util.datatype_factory_base.BasicRegistrationFactory, sunpy.util.datatype_factory_base.NoMatchError, sunpy.util.datatype_factory_base.MultipleMatchError, sunpy.util.datatype_factory_base.ValidationFunctionError

sunpy.util.multimethod Module

This module provides multimethod implementation in pure Python.

Classes

TypeWarning

MultiMethod(get)

A multimethod is a callable object that decides which code to execute based on the type of one or more of its arguments.

Class Inheritance Diagram

Inheritance diagram of sunpy.util.multimethod.TypeWarning, sunpy.util.multimethod.MultiMethod

sunpy.util.net Module

This module provides general net utility functions.

Functions

slugify(text[, delim])

Slugify given unicode text.

get_content_disposition(content_disposition)

Get the content disposition filename from given header.

get_filename(sock, url)

Get filename from given urlopen object and URL.

get_system_filename(sock, url[, default])

Get filename from given urlopen object and URL.

download_file(url, directory[, default, …])

Download a file from a url into a directory.

download_fileobj(opn, directory[, url, …])

Download a file from a url into a directory.

sunpy.util.xml Module

This module provides XML helper functions.

Functions

xml_to_dict(xmlstring)

Converts an XML string to a Python dictionary.

node_to_dict(node)

Scans through the children of the node and makes a dictionary from the content.

get_node_text(node)

Scans through all children of Element node and gathers the text.

Class Inheritance Diagram

Inheritance diagram of sunpy.util.xml.NotTextNodeError

sunpy.util.scraper Module

This module provides a web scraper.

Classes

Scraper(pattern[, regex])

A Scraper to scrap web data archives based on dates.

Class Inheritance Diagram

Inheritance diagram of sunpy.util.scraper.Scraper

sunpy.util.sphinx Package

Helpers and extensions for sphinx.

This subpackage contains two sphinx directives:

  • .. generate:: which includes raw output generated by a Python script into a .. raw:: block. This can be used to for example, include HTML output into the built docs.

  • .. changelog:: which renders the latest changelog with towncrier and includes it in the documentation.

To use them add 'sunpy.util.sphinx.generate' and 'sunpy.util.sphinx.changelog' to the extensions list in your conf.py file.

sunpy.util.sphinx.generate Module

Classes

Generate(name, arguments, options, content, …)

Custom directive to include raw output generated using supplied Python code

Class Inheritance Diagram

Inheritance diagram of sunpy.util.sphinx.generate.Generate

sunpy.util.sphinx.changelog Module

Classes

ChangeLog(name, arguments, options, content, …)

Render the changelog for the current commit using towncrier.

Class Inheritance Diagram

Inheritance diagram of sunpy.util.sphinx.changelog.ChangeLog

sunpy.util.functools Module

This file defines wrappers and variants of things in the functools standard lib.

Functions

seconddispatch(func)

A variant of functools.singledispatch which dispatches on type of the second argument.