
    eg              	       z   d Z ddlZddlZddlZddlZddlmZ  G d dej                  j                        Z
dZdZdded	ed
eej                  ej                  f   fdZdej                  dej                  fdZ e
eg edd       Z e
eg ed       Z e
eg edd       Z e
eg ed       Zy)zRGlobal objects with the content of the microarchitecture
JSON file and its schema
    N)Tuplec                   D    e Zd ZdZd Zed        Zd Zd Zd Z	d Z
d Zy	)
LazyDictionaryzLazy dictionary that gets constructed on first access to any object key

    Args:
        factory (callable): factory function to construct the dictionary
    c                 <    || _         || _        || _        d | _        y N)factoryargskwargs_data)selfr   r	   r
   s       3lib/python3.12/site-packages/archspec/cpu/schema.py__init__zLazyDictionary.__init__   s    	
    c                     | j                   + | j                  | j                  i | j                  | _         | j                   S )z)Returns the lazily constructed dictionary)r   r   r	   r
   r   s    r   datazLazyDictionary.data   s7     ::%tyy@DKK@DJzzr   c                      | j                   |   S r   r   r   keys     r   __getitem__zLazyDictionary.__getitem__#   s    yy~r   c                 "    || j                   |<   y r   r   )r   r   values      r   __setitem__zLazyDictionary.__setitem__&   s    		#r   c                     | j                   |= y r   r   r   s     r   __delitem__zLazyDictionary.__delitem__)   s    IIcNr   c                 ,    t        | j                        S r   )iterr   r   s    r   __iter__zLazyDictionary.__iter__,   s    DIIr   c                 ,    t        | j                        S r   )lenr   r   s    r   __len__zLazyDictionary.__len__/   s    499~r   N)__name__
__module____qualname____doc__r   propertyr   r   r   r   r   r"    r   r   r   r      s9      r   r   ARCHSPEC_CPU_DIRARCHSPEC_EXTENSION_CPU_DIRfilenameallow_customreturnc                    t        j                  t              j                  dz  dz  dz  }|r@t        t
        j                  v r*t        j                  t
        j                  t                 }|j                         }|| z  }d}|rUt        t
        j                  v r?t        j                  t
        j                  t                 }|j                          || z  }||fS )a  Given a filename, returns the absolute path for the main JSON file, and an
    optional absolute path for an extension JSON file.

    Args:
        filename: filename for the JSON file
        allow_custom: if True, allows overriding the location  where the file resides
    z..jsoncpuN)	pathlibPath__file__parentDIR_FROM_ENVIRONMENTosenvironabsoluteEXTENSION_DIR_FROM_ENVIRONMENT)r+   r,   json_dir	json_fileextension_fileextension_dirs         r   
_json_filer>   :   s     ||H%,,t3f<uDH,

:<<

+? @A  "H8#IN6"**DRZZ0N%OP &1n$$r   r;   r<   c                    t        | dd      5 }t        j                  |      }d d d        |r|j                         sS t        |dd      5 }t        j                  |      }d d d        t	        j                               }|D ]  }|vr||   j                  ||            |S # 1 sw Y   xY w# 1 sw Y   SxY w)Nrzutf-8)encoding)openr/   loadexistslistkeysupdate)r;   r<   filer   extension_datatop_level_sectionsr   s          r   _loadrK   Q   s    	iw	/4yy 
0 !6!6!8	ncG	44 
5 diik*!n$S	,-	 " K! 
0	/ 
5	4s   B+B7+B47C zmicroarchitectures.jsonT)r,   zmicroarchitectures_schema.jsonz
cpuid.jsonzcpuid_schema.json)F)r&   collections.abccollectionsr/   r6   r1   typingr   abcMutableMappingr   r5   r9   strboolr2   r>   rK   TARGETS_JSONTARGETS_JSON_SCHEMA
CPUID_JSONCPUID_JSON_SCHEMAr(   r   r   <module>rW      s   
   	  ![__33 !J *  "> % %D %U7<<QXQ]Q]C]=^ %.W\\ 7<< , e_j1JY]&^_ %UZZ8X-YZ  EPJ|$$OP
 #5K:6I+JK r   