
    IR-eP                     D    d Z dgZ G d d          Z G d d          ZdS )zr
A simple class to manage a piece of global science state.  See
:ref:`astropy:config-developer` for more details.
ScienceStatec                   &    e Zd Zd Zd Zd Zd ZdS )_ScienceStateContextc                 "    || _         || _        d S N_value_parent)selfparentvalues      3lib/python3.11/site-packages/astropy/utils/state.py__init__z_ScienceStateContext.__init__   s        c                     d S r    r
   s    r   	__enter__z_ScienceStateContext.__enter__   s    r   c                 (    | j         | j        _         d S r   r   )r
   typer   tbs       r   __exit__z_ScienceStateContext.__exit__   s    "kr   c                     t          | j        j                                      d          \  }}}|r|dz  }d| j        j         d| dS )N
z...z<ScienceState z: >)reprr	   r   	partition__name__)r
   
value_reprlb_s       r   __repr__z_ScienceStateContext.__repr__   s[     !!455??EE
B 	 %JF 5FFFFFFr   N)r   
__module____qualname__r   r   r   r!   r   r   r   r   r   
   sU            * * *G G G G Gr   r   c                   Z    e Zd ZdZd Zed             Zed             Zed             ZdS )r   aa  
    Science state subclasses are used to manage global items that can
    affect science results.  Subclasses will generally override
    `validate` to convert from any of the acceptable inputs (such as
    strings) to the appropriate internal objects, and set an initial
    value to the ``_value`` member so it has a default.

    Examples
    --------
    ::

        class MyState(ScienceState):
            @classmethod
            def validate(cls, value):
                if value not in ('A', 'B', 'C'):
                    raise ValueError("Must be one of A, B, C")
                return value
    c                      t          d          )Nz/This class is a singleton.  Do not instantiate.)RuntimeErrorr   s    r   r   zScienceState.__init__2   s    LMMMr   c                 6    |                      | j                  S )z6
        Get the current science state value.
        )validater   )clss    r   getzScienceState.get5   s    
 ||CJ'''r   c                 h    t          | | j                  }|                     |          }|| _        |S )z$Set the current science state value.)r   r   r(   )r)   r   ctxs      r   setzScienceState.set<   s6     #3
33 U##
 
r   c                     |S )z]
        Validate the value and convert it to its native type, if
        necessary.
        r   )r)   r   s     r   r(   zScienceState.validateI   s	     r   N)	r   r"   r#   __doc__r   classmethodr*   r-   r(   r   r   r   r   r      s         &N N N ( ( [( 
 
 [
   [  r   N)r/   __all__r   r   r   r   r   <module>r2      s{     
G G G G G G G G(1 1 1 1 1 1 1 1 1 1r   