Your IP : 216.73.216.213


Current Path : /opt/alt/python34/lib64/python3.4/Tools/scripts/__pycache__/
Upload File :
Current File : //opt/alt/python34/lib64/python3.4/Tools/scripts/__pycache__/parse_html5_entities.cpython-34.pyc

�
e f��@s�dZddlZddlZddlZddlmZddlmZdZdd�Z	dd	�Z
d
d�Zejdd
�Z
edkr�e
e	e��Zdejkr�ed�edje��e
e�q�dejkr�dZedZee���Zeed��zZdZxjeD]bZejd�r[e
ede�dZq*nerejd�r*dZq*q*neje�q*WWdQXWdQXeje�ejee�q�eekr�ed�q�eee�edje��ndS)z�
Utility for parsing HTML5 entity definitions available from:

    http://dev.w3.org/html5/spec/entities.json

Written by Ezio Melotti and Iuliia Proskurnia.

�N)�urlopen)�html5z*http://dev.w3.org/html5/spec/entities.jsonc	Cs7t|��}|j�jd�}WdQXtj|�S)zADownload the json file from the url and returns a decoded object.zutf-8N)r�read�decode�json�loads)Zurl�f�data�r
�G/opt/alt/python34/lib64/python3.4/Tools/scripts/parse_html5_entities.py�get_jsonsrcCs>i}x1|j�D]#\}}|d||jd�<qW|S)z3Create the html5 dict from the decoded json object.Z
characters�&)�items�lstrip)�entities�	new_html5�name�valuer
r
r�create_dictsrcCs�|j�|j�}|ritdjt|���x1t|�D] }tdj|||��qBWn|j�|j�}|r�tdjt|���x1t|�D] }tdj|||��q�Wnt�}xS|j�|j�@D];}||||kr�|j|||||f�q�q�W|r}tdjt|���x*t|�D]}tdj|��q]WndS)z8Compare the old and new dicts and print the differences.z{} entitie(s) have been added:z  {!r}: {!r}z {} entitie(s) have been removed:z!{} entitie(s) have been modified:z  {!r}: {!r} -> {!r}N)�keys�print�format�len�sorted�set�add)�old�newZaddedrZremovedZchanged�itemr
r
r�
compare_dicts s$!!	%rcCs|t|j��}t|dtj�}tdd|�x.|D]&}tdj|||�d|�q>Wtdd|�dS)z8Write the items of the dictionary in the specified file.�keyz	html5 = {�filez    {!r}: {!a},�}N)rr�str�lowerrr)rr!rrr
r
r�write_items5s

$r%�__main__z--createzQ# map the HTML5 named character references to the equivalent Unicode character(s)z)# Generated by {}.  Do not edit manually.z--patchzLib/html/entities.pyz.temp�wFz	html5 = {r!Tr"z"The current dictionary is updated.zwRun "./python {0} --patch" to update Lib/html/entities.html or "./python {0} --create" to see the generated dictionary.)�__doc__�os�sysrZurllib.requestrZ
html.entitiesrZentities_urlrrr�stdoutr%�__name__r�argvrr�__file__ZfnameZ
temp_fname�open�f1�f2�skip�line�
startswith�write�remove�renamer
r
r
r�<module>	sL


!