Skip to content

Commit

Permalink
Demonstration of using the proposed astropy custom config stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
Cadair committed Dec 6, 2018
1 parent 54291dc commit fdb6ab1
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 2 deletions.
6 changes: 4 additions & 2 deletions dkist/_dkist_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,12 @@
if os.path.isfile(config_template):
try:
update_default_config(
__package__, config_dir, version=__version__)
__package__, config_dir, version=__version__,
rootname='dkist')
except TypeError as orig_error:
try:
update_default_config(__package__, config_dir)
update_default_config(__package__, config_dir,
rootname='dkist')
except ConfigurationDefaultMissingError as e:
wmsg = (e.args[0] +
" Cannot install default profile. If you are "
Expand Down
9 changes: 9 additions & 0 deletions dkist/config/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import astropy.config as astropyconfig


class ConfigNamespace(astropyconfig.ConfigNamespace):
rootname = 'dkist'


class ConfigItem(astropyconfig.ConfigItem):
rootname = 'dkist'
3 changes: 3 additions & 0 deletions dkist/dkist.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[io]
## Name of Preferred fits module
# preferred_fits_library = 'astropy'
17 changes: 17 additions & 0 deletions dkist/io/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
from .fits import BaseFITSLoader, AstropyFITSLoader
from .reference_collections import (BaseFITSArrayContainer, DaskFITSArrayContainer,
NumpyFITSArrayContainer)
__all__ = ['BaseFITSLoader', 'AstropyFITSLoader', 'BaseFITSArrayContainer',
'NumpyFITSArrayContainer', 'DaskFITSArrayContainer', 'conf']


import dkist.config as _config


class Conf(_config.ConfigNamespace):
"""
Configuration Parameters for the IO Package.
"""

preferred_fits_library = _config.ConfigItem('astropy',
"Name of the preferred FITS module.")


conf = Conf()

0 comments on commit fdb6ab1

Please sign in to comment.