o
    [h                     @   sf   d dl Z d dlmZ d dlmZ 	 d dlmZ d dlmZ ddl	m
Z
 eZG dd	 d	e
Zd
d ZdS )    N)import_module)Path)get_class_bounds)BaseConstants   )BaseCommandc                   @   s   e Zd Zdd Zdd ZdS )Commandc                 C   s$   |j ddd |j ddddd d S )	Napps*)nargsz--keep
store_truekeep_old_filesF)actiondestdefault)add_argument)selfparser r   /home/ubuntu/experiments/live_experiments/Pythonexperiments/Otree/venv/lib/python3.10/site-packages/otree/cli/upcase_constants.pyadd_arguments   s   
zCommand.add_argumentsc                O   s@  t d}| D ]j}|d}|j}| sq|d}	d|	vr(td|  q|	dd}	t|}
|
j	}dd t
|D }t|	d	\}}|	|| }|D ]}td
| d
 | |}qM|	d | | |	|d   }|j|dd qg }dD ]
}||| qw|D ]}|d}tdt|}|j|dd qtd d S )N.z__init__.pyutf8zclass Constants(z	Skipping zclass C(c                 S   s   g | ]
}|t tvr|qS r   )varsr   ).0kr   r   r   
<listcomp>"   s    z"Command.handle.<locals>.<listcomp>Cz\b)encoding)z*.htmlz*.pyz*/*.htmlz*/*.pyz
*/*/*.htmlz*/*/*.pyz\bConstants\.(\w+)\bDone)r   iterdirjoinpathnameexists	read_textprint_functionreplacer   	Constantsr   r   resubupper
write_textextendglobupcase)r   r	   r   argsoptionsrootZappZ	init_pathZapp_nametextmoduler'   Z	classvarsZ	cls_startZcls_endZ	class_txtZclassvarfinalZfiles_to_replacer-   ptxtr   r   r   handle   s<   


zCommand.handleN)__name__
__module____qualname__r   r7   r   r   r   r   r      s    r   c                 C   s   |  d }d| S )Nr   zC.)groupr*   )matchZupcased_namer   r   r   r.   9   s   
r.   )r(   	importlibr   pathlibr   Zotree.commonr   Zotree.constantsr   baser   printr%   r   r.   r   r   r   r   <module>   s    ,