o
    Ni                     @   s0   d dl mZ ddhZdd Zdd Zdd	 Zd
S )    )data_filenameDescriptionPrefixc                 c   sz    g }| D ].}| d}|dkrt|E dH  |  q|dr.|d  |dd 7  < q|| qt|E dH  dS )z
    Take an open file containing the IANA subtag registry, and yield a
    dictionary of information for each subtag it describes.
    
z%%Nz     )rstrip
parse_itemclear
startswithappend)filelinesline r   Q/home/ubuntu/.local/lib/python3.10/site-packages/language_data/registry_parser.py
parse_file   s   


r   c                 c   sn    i }| D ]"}| dd\}}|tv r||g | q||vs#J |||< qd|v s0d|v r5|V  dS dS )a  
    Given the lines that form a subtag entry (after joining wrapped lines
    back together), parse the data they contain.
    
    Returns a generator that yields once if there was any data there
    (and an empty generator if this was just the header).
    z: r   SubtagTagN)split	LIST_KEYS
setdefaultr   )r   infor   keyvaluer   r   r   r	      s   

r	   c                  c   sF    t tddd} t| E dH  W d   dS 1 sw   Y  dS )zn
    Yield a sequence of dictionaries, containing the info in the included
    IANA subtag registry file.
    zlanguage-subtag-registry.txtzutf-8)encodingN)openr   r   )	data_filer   r   r   parse_registry1   s   "r   N)language_data.utilr   r   r   r	   r   r   r   r   r   <module>   s
    