
    eg              	       d   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          R  Z e
eg ed          R  Z e
eg edd          R  Z e
eg ed          R  ZdS )zRGlobal objects with the content of the microarchitecture
JSON file and its schema
    N)Tuplec                   L    e Zd ZdZd Zed             Zd Zd Zd Z	d Z
d Zd	S )
LazyDictionaryzLazy dictionary that gets constructed on first access to any object key

    Args:
        factory (callable): factory function to construct the dictionary
    c                 >    || _         || _        || _        d | _        d S N)factoryargskwargs_data)selfr   r	   r
   s       3lib/python3.11/site-packages/archspec/cpu/schema.py__init__zLazyDictionary.__init__   s"    	


    c                 V    | j          | j        | j        i | j        | _         | j         S )z)Returns the lazily constructed dictionary)r   r   r	   r
   r   s    r   datazLazyDictionary.data   s0     :%ty@DK@@DJzr   c                     | j         |         S r   r   r   keys     r   __getitem__zLazyDictionary.__getitem__#   s    y~r   c                     || j         |<   d S r   r   )r   r   values      r   __setitem__zLazyDictionary.__setitem__&   s    	#r   c                     | j         |= d S r   r   r   s     r   __delitem__zLazyDictionary.__delitem__)   s    IcNNNr   c                 *    t          | j                  S r   )iterr   r   s    r   __iter__zLazyDictionary.__iter__,   s    DIr   c                 *    t          | j                  S r   )lenr   r   s    r   __len__zLazyDictionary.__len__/   s    49~~r   N)__name__
__module____qualname____doc__r   propertyr   r   r   r   r   r"    r   r   r   r      s              X            r   r   ARCHSPEC_CPU_DIRARCHSPEC_EXTENSION_CPU_DIRF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                             }|                                }|| z  }d}|rUt          t
          j        v rBt          j        t
          j        t                             }|                                 || 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 B,
::<
+? @AA  ""H8#IN 26"*DDRZ0N%OPP   &1n$$r   r;   r<   c                    t          | dd          5 }t          j        |          }d d d            n# 1 swxY w Y   |r|                                s|S t          |dd          5 }t          j        |          }d d d            n# 1 swxY w Y   t	          |                                          }|D ](}||vr||                             ||                    )|S )Nrzutf-8)encoding)openr/   loadexistslistkeysupdate)r;   r<   filer   extension_datatop_level_sectionsr   s          r   _loadrK   Q   sf   	iw	/	/	/ 4y                !6!6!8!8 	ncG	4	4	4 )4) ) ) ) ) ) ) ) ) ) ) ) ) ) ) diikk**! . .n$$S	,----Ks   488)B

BB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 ! ! !J *  "> % % %D %U7<QXQ]C]=^ % % % %.W\ 7<    , ~e_jj1JY]&^&^&^___ %nUZZZ8X-Y-YZZZ  ^EPJJ|$$O$O$OPPP
 #N5K::6I+J+JKKK   r   