U
    [Ožh  ã                   @   sœ   d Z ddlZddlmZ ejdd„ ƒZejdd„ ƒZejdd	„ ƒZejd
d„ ƒZejdd„ ƒZejdd„ ƒZ	dd„ Z
dd„ Zejdd„ ƒZejdd„ ƒZdS )z)
all decorators used in moviepy go there
é    N)Úcvsecsc                 O   s   |  ¡ }| |f|ž|Ž |S )z8 Applies f(clip.copy(), *a, **k) and returns clip.copy())Úcopy©ÚfÚclipÚaÚkZnewclip© r	   úD/var/www/html/venv/lib/python3.8/site-packages/moviepy/decorators.pyÚoutplace
   s    r   c                 O   s   |j r| ¡ }| |f|ž|ŽS )zF If the clip is a mask, convert it to RGB before running the function )ZismaskZto_RGB©r   r   r   r   r	   r	   r
   Úconvert_masks_to_RGB   s    r   c                 O   s4   | |f|ž|Ž}t |ddƒr0| |jf|ž|Ž|_|S )z^ This decorator will apply the same function f to the mask of
        the clip created with f ÚmaskN)Úgetattrr   r   r	   r	   r
   Úapply_to_mask   s    r   c                 O   s4   | |f|ž|Ž}t |ddƒr0| |jf|ž|Ž|_|S )zZ This decorator will apply the function f to the audio of
        the clip created with f ÚaudioN)r   r   r   r	   r	   r
   Úapply_to_audio$   s    r   c                 O   s(   |j dkrtdƒ‚n| |f|ž|ŽS dS )z, Raise an error if the clip has no duration.NzAttribute 'duration' not set)ÚdurationÚ
ValueErrorr   r	   r	   r
   Úrequires_duration/   s    

r   c                 O   sH   t |dƒr4| ¡ }|jdk	r0| |jf|ž|Ž|_|S | |f|ž|ŽS dS )zõ Use an audio function on a video/audio clip
    
    This decorator tells that the function f (audioclip -> audioclip)
    can be also used on a video clip, at which case it returns a
    videoclip with unmodified video and modified audio.
    r   N)Úhasattrr   r   r   r	   r	   r
   Úaudio_video_fx:   s    	

r   c                    s   ‡ ‡fdd„}t   |¡S )zD Applies fun to variables in varnames before launching the function c                    sZ   t | dƒr| j}n| j}|j}‡ ‡fdd„t||ƒD ƒ}‡ ‡fdd„| ¡ D ƒ}| ||ŽS )NÚ	func_codec                    s$   g | ]\}}|ˆkrˆ |ƒn|‘qS r	   r	   ©Ú.0ÚargÚname©ÚfunÚvarnamesr	   r
   Ú
<listcomp>U   s   ÿz4preprocess_args.<locals>.wrapper.<locals>.<listcomp>c                    s&   i | ]\}}||ˆkrˆ |ƒn|“qS r	   r	   ©r   r   Úvr   r	   r
   Ú
<dictcomp>W   s   ÿ z4preprocess_args.<locals>.wrapper.<locals>.<dictcomp>©r   r   Ú__code__Úco_varnamesÚzipÚitems)r   r   Úkwr   ÚnamesÚnew_aÚnew_kwr   r	   r
   ÚwrapperN   s    
ÿÿz preprocess_args.<locals>.wrapper)Ú	decorator)r   r   r-   r	   r   r
   Úpreprocess_argsK   s    r/   c                 C   s
   t t| ƒS )z+Converts the specified variables to seconds)r/   r   )r   r	   r	   r
   Úconvert_to_seconds]   s    r0   c                 O   s"   |j dkr| ¡ }| |f|ž|ŽS )z* Add a mask to the clip if there is none. N)r   Zadd_maskr   r	   r	   r
   Úadd_mask_if_nonec   s    
r1   c                    sr   ‡ ‡fdd„‰t ˆdƒr ˆj}nˆj}|jdd… }‡fdd„t||ƒD ƒ}‡fdd	„| ¡ D ƒ}ˆˆ f|ž|ŽS )
z4 Will use clip.fps if no fps=... is provided in **k c                    s0   | d k	r| S t ˆ dd ƒrˆ jS tdˆj ƒ‚d S )NÚfpszÎNo 'fps' (frames per second) attribute specified for function %s and the clip has no 'fps' attribute. Either provide e.g. fps=24 in the arguments of the function, or define the clip's fps with `clip.fps=24`)r   r2   ÚAttributeErrorÚ__name__©r2   )r   r   r	   r
   r   p   s    ýz$use_clip_fps_by_default.<locals>.funr   é   Nc                    s$   g | ]\}}|d krˆ |ƒn|‘qS r5   r	   r   ©r   r	   r
   r    ‚   s   ÿz+use_clip_fps_by_default.<locals>.<listcomp>c                    s&   i | ]\}}||d krˆ |ƒn|“qS r5   r	   r!   r7   r	   r
   r#   „   s   ÿ z+use_clip_fps_by_default.<locals>.<dictcomp>r$   )r   r   r   r   r   r*   r+   r,   r	   )r   r   r   r
   Úuse_clip_fps_by_defaultl   s    

ÿ
ÿr8   )Ú__doc__r.   Zmoviepy.toolsr   r   r   r   r   r   r   r/   r0   r1   r8   r	   r	   r	   r
   Ú<module>   s(   








