U
    d»{jÆ  ã                   @   sd   d dl mZ d dlmZ d dlmZ d dlmZ ddgZddd	d
ddgZ	dd„ Z
G dd„ deƒZdS )é    )Úcontextmanager©Úwraps)ÚFunctionType)ÚQTableÚBaseTimeSeriesÚautocheck_required_columnsÚ
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   ˆ | f|ž|Ž}|   ¡  |S )N)Ú_check_required_columns)ÚselfÚargsÚkwargsÚresult©Úmethod© úV/var/www/html/bwave/python/venv/lib/python3.8/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  dd„ }| j sd S | jd k	rþ| jr8| jd t| jƒ… }n| j}t|ƒdkrNdnd}| jsŠt| jƒdkrŠt| jj› d|d › d|› d	�ƒ‚nN| jd t|ƒ… |krØt| jj› d
||ƒ› d|› d|| jd t|ƒ… ƒ› �ƒ‚| jrþ| j| jd t| jƒ… krþd| _d S )Nc                 S   s>   t | dƒsd| › d�S t| ƒdkr2d| d › d�S t| ƒS d S )NÚ__len__ú'é   r   )r   ÚlenÚstr)Úobjr   r   r   Úas_scalar_or_list_str9   s
    
zEBaseTimeSeries._check_required_columns.<locals>.as_scalar_or_list_strr   ÚsÚ r   z object is invalid - expected 'z' as the first columnz but time series has no columnsz object is invalid - expected z as the first columnz but found F)Ú_required_columns_enabledÚ_required_columnsÚ_required_columns_relaxr    Zcolnamesr   Ú	__class__Ú__name__)r   r#   Zrequired_columnsÚpluralr   r   r   r
   8   s.    
ÿ2ÿÿÿþz&BaseTimeSeries._check_required_columnsc                 c   s   d| _ d V  d| _ |  ¡  d S )NFT)r&   r
   )r   r   r   r   Ú_delay_required_column_checksb   s    z,BaseTimeSeries._delay_required_column_checks)	r*   Ú
__module__Ú__qualname__r'   r&   r(   r
   r   r,   r   r   r   r   r   .   s   *N)Ú
contextlibr   Ú	functoolsr   Útypesr   Zastropy.tabler   Ú__all__r   r   r   r   r   r   r   Ú<module>   s   ú
