File: //usr/local/lib/python3.6/site-packages/selenium/webdriver/remote/__pycache__/utils.cpython-36.pyc
3
+�h� � @ sV d dl Z d dlZd dlZd dlZd dlZeje�Zdd� Zdd� Z dd� Z
dd � ZdS )
� Nc C s t j| dd�S )N� )�indent)�json�dumps)�json_struct� r �I/usr/local/lib/python3.6/site-packages/selenium/webdriver/remote/utils.py�format_json s r c C s
t j| �S )N)r r )r r r r � dump_json s r
c C s
t j| �S )N)r �loads)�sr r r � load_json$ s r
c C s� | st jj| � rdS tj| �}|j� dk r2dS tjd| � tj � }�y
xn|j
� D ]b}|jdt jj�jdt jj�}t jj
||�}|jt jj�rVt jj|� rVt j|� tjd| � qVW x�|j
� D ]z}|jdt jj�jdt jj�}t jj
||�}|jt jj�s�tjd| � t|d�}|j|j|�� |j� tjd| � q�W tjd | � |S tk
�r� } ztjd
| � dS d}~X nX dS )z�Unzip zipfile to a temporary directory.
The directory of the unzipped files is returned if success,
otherwise None is returned. NzExtracting zipped file: %s�\�/zDirectory %s created.zCopying file %s......�wbzFile %s copied.z Unzipped file can be found at %sz%Error in extracting webdriver.xpi: %s)�os�path�exists�zipfile�ZipFile�testzip�LOGGER�info�tempfile�mkdtemp�namelist�replace�sep�join�endswith�mkdir�debug�open�write�read�close�IOError�error)Z
zip_file_name�zf�tempdirZzip_name�name�dest�outfile�errr r r �unzip_to_temp_dir( s<