o
    Hi8                     @   s\   d Z ddlmZ ddlZddlZddlZdd Zdd Zdd	 Zd
d Z	dd Z
dd ZdS )u   
修改xcodeproj中的uuid
    )oc_utilNc                  C   s   t jd } tt j|  d S )Nz
.xcodeproj)r   name_current_projectmodify_proj_uuidpath_mix_project)xcodeproj_name r   ?/data/storage/obfuscation/tool/ObjectiveC/oc_function/p_uuid.pyinit   s   
r	   c           	   
      s   t j| ddD ]Y\}}} fdd|D |d d < |D ]D}|dkr_t j||}t|d}| }t|}W d    n1 s@w   Y  t|d}|| W d    n1 sZw   Y  qqd S )NT)topdownc                    s   g | ]}| kr|qS r   r   ).0ddir_namer   r   
<listcomp>   s    z$modify_proj_uuid.<locals>.<listcomp>zproject.pbxprojrw)oswalkpathjoinopenreadsearch_and_replace_file_addresswrite)	r   r   rootdirsfilesname	file_pathffileContentr   r   r   r      s   
r   c           	      C   s   g d}g }g }t d| }dd |D }|D ]}t|dkr(||vr(|| q|D ]}t||}|d }|d }| ||} q+| S )N)0123456789ABCDEFz([\n \tG-Zg-z])c                 S   s    g | ]}t | d kr|qS )r   )lenstrip)r   ar   r   r   r      s     z3search_and_replace_file_address.<locals>.<listcomp>      r   )resplitr1   appendrandom_new_uuidreplace)	file_content	char_listold_uuid_listnew_uuid_listaListr3   uuid	tuple_newnew_uuidr   r   r   r      s    

r   c                 C   s
   t | dS )N   )intnumr   r   r   
hex_to_int)   s   
rG   c                 C   s   t | dd  S )N   )hexrE   r   r   r   
int_to_hex+   s   rJ   c                 C   sD   d}t dD ]	}|t| }q|| v rt| |S | | || fS )N r4   )rangerandomchoicer9   r8   )r>   r<   rB   _r   r   r   r9   .   s   

r9   )__doc__
ObjectiveCr   r   r6   rM   r	   r   r   rG   rJ   r9   r   r   r   r   <module>   s    