a
    ߙfb                     @   s\   d dl mZ d dlmZ d dlmZ d dlmZ ddgZg dZ	dd Z
G d	d deZd
S )    )FunctionType)contextmanagerwraps)QTableBaseTimeSeriesautocheck_required_columns)Z
add_columnZadd_columnsZkeep_columnsZremove_columnZremove_columnsZrename_columnc                 C   sT   dd }t D ]B}t| |r*tt| |ts8t| dt| ||t| | q| S )a  
    This is a decorator that ensures that the table contains specific
    methods indicated by the _required_columns attribute. The aim is to
    decorate all methods that might affect the columns in the table and check
    for consistency after the methods have been run.
    c                    s   t   fdd}|S )Nc                    s"    | g|R i |}|    |S )N)_check_required_columns)selfargskwargsresultmethod 6lib/python3.9/site-packages/astropy/timeseries/core.pywrapper   s    zEautocheck_required_columns.<locals>.decorator_method.<locals>.wrapperr   )r   r   r   r   r   decorator_method   s    z4autocheck_required_columns.<locals>.decorator_methodz is not a valid method)COLUMN_RELATED_METHODShasattr
isinstancegetattrr   
ValueErrorsetattr)clsr   namer   r   r   r      s    

c                   @   s,   e Zd ZdZdZdZdd Zedd ZdS )r   NTFc                 C   s   | j s
d S | jd ur| jr0| jd t| j }n| j}t|dkrFdnd}| jszt| jdkrztd| jj|d |n8| jd t| |krtd| jj|d || jd | jr| j| jd t| j krd| _d S )N   s r   zY{} object is invalid - expected '{}' as the first column{} but time series has no columnszI{} object is invalid - expected '{}' as the first column{} but found '{}'F)	_required_columns_enabled_required_columns_required_columns_relaxlenZcolnamesr   format	__class____name__)r
   Zrequired_columnsZpluralr   r   r   r	   9   s&    
z&BaseTimeSeries._check_required_columnsc                 c   s   d| _ d V  d| _ |   d S )NFT)r   r	   )r
   r   r   r   _delay_required_column_checksW   s    z,BaseTimeSeries._delay_required_column_checks)	r%   
__module____qualname__r    r   r!   r	   r   r&   r   r   r   r   r   .   s   N)typesr   
contextlibr   	functoolsr   Zastropy.tabler   __all__r   r   r   r   r   r   r   <module>   s   