a
    Dg
                     @   s   d dl Z d dlZd dlZd dlmZ d dlmZ d dlmZ	 d dl
mZ G dd dZG dd	 d	eeZG d
d de	eZG dd deZdS )    N)Command)	bdist_egg)sdist)
__semver__c                   @   s$   e Zd Zdd Zdd Zdd ZdS )assets_mixinc              
   C   sZ   zt g d W nB tt jfyT } z$tdt|  tdW Y d }~n
d }~0 0 d S )N)npmrunbuildzError compiling assets:    
subprocess
check_callOSErrorCalledProcessErrorprintstr
SystemExitselfe r   R/var/www/lab.imftr.de/x/nb_venv/lib/python3.9/site-packages/wagtail/utils/setup.pycompile_assets   s
    zassets_mixin.compile_assetsc              
   C   sZ   zt g d W nB tt jfyT } z$tdt|  tdW Y d }~n
d }~0 0 d S )N)r   publishclientz#Error publishing front-end assets: r
   r   r   r   r   r   publish_assets   s
    zassets_mixin.publish_assetsc              
   C   s&  t jddd}z<t|d}t| }W d   n1 s@0    Y  W n@ ty } z(td| d |  t	dW Y d}~n
d}~0 0 t
|d	< zLt|d
dd*}|ttj|ddd W d   n1 s0    Y  W n> ty  } z$tdt|  t	dW Y d}~n
d}~0 0 dS )zM
        Writes the current Wagtail version number into package.json
        .r   zpackage.jsonrNzUnable to read  r
   versionwzutf-8)encoding   F)indentensure_asciiz0Error setting the version for front-end assets: )ospathjoinopenjsonloadsread
ValueErrorr   r   r   writer   dumpsr   )r   r&   fpackager   r   r   r   bump_client_version   s     0<
z assets_mixin.bump_client_versionN)__name__
__module____qualname__r   r   r1   r   r   r   r   r      s   r   c                   @   s(   e Zd Zg Zdd Zdd Zdd ZdS )assetsc                 C   s   d S Nr   r   r   r   r   initialize_options7   s    zassets.initialize_optionsc                 C   s   d S r6   r   r7   r   r   r   finalize_options:   s    zassets.finalize_optionsc                 C   s   |    |   |   d S r6   )r1   r   r   r7   r   r   r   r   =   s    z
assets.runN)r2   r3   r4   user_optionsr8   r9   r   r   r   r   r   r5   4   s   r5   c                   @   s   e Zd Zdd ZdS )r   c                 C   s   |    t|  d S r6   )r   
base_sdistr   r7   r   r   r   r   D   s    z	sdist.runN)r2   r3   r4   r   r   r   r   r   r   C   s   r   c                   @   s   e Zd ZdZdd ZdS )check_bdist_eggzwagtail/wagtailadmin/static/c                 C   s.   t |  tj| js*tdg d d S )N
)<************************************************************z-The front end assets for Wagtail are missing.z<To generate the assets, please refer to the documentation inzdocs/contributing/developing.mdr>   )r   r   r%   r&   isdirsentinel_dirr   r'   r7   r   r   r   r   M   s    
zcheck_bdist_egg.runN)r2   r3   r4   r@   r   r   r   r   r   r<   I   s   r<   )r)   r%   r   
setuptoolsr   Zsetuptools.command.bdist_eggr   Zsetuptools.command.sdistr   r;   Zwagtailr   r   r5   r<   r   r   r   r   <module>   s   (