§
    ¹³Ùg}'  ã                   óÂ   — d Z ddlZddlZddlmZ ddlmZ ej                             ej         	                    d¦  «        dd¦  «        Z
 G d„ d	¦  «        Zdd
„Zd„ ZdS )z1Utils for reading a user preference config files.é    N)Úwarn)Ú
exceptionsú~z.qiskitzsettings.confc                   ó    — e Zd ZdZdd„Zd„ ZdS )Ú
UserConfiga‡  Class representing a user config file

    The config file format should look like:

    [default]
    circuit_drawer = mpl
    circuit_mpl_style = default
    circuit_mpl_style_path = ~/.qiskit:<default location>
    circuit_reverse_bits = True
    circuit_idle_wires = False
    transpile_optimization_level = 1
    parallel = False
    num_processes = 4
    sabre_all_threads = true

    Nc                 óp   — |€t           | _        n|| _        i | _        t          j        ¦   «         | _        dS )z²Create a UserConfig

        Args:
            filename (str): The path to the user config file. If one isn't
                specified, ~/.qiskit/settings.conf is used.
        N)ÚDEFAULT_FILENAMEÚfilenameÚsettingsÚconfigparserÚConfigParserÚconfig_parser)Úselfr
   s     úH/granary/edev/quantum/lib/python3.11/site-packages/qiskit/user_config.pyÚ__init__zUserConfig.__init__*   s8   € ð ÐÝ,ˆDŒMˆMà$ˆDŒMØˆŒÝ)Ô6Ñ8Ô8ˆÔÐÐó    c                 ó\  — t           j                             | j        ¦  «        sdS | j                             | j        ¦  «         d| j                             ¦   «         v �rH| j                             ddd¬¦  «        }|r%|dvrt          j	        |› d�¦  «        ‚|| j
        d<   | j                             ddd¬¦  «        }|rLg d¢}||vr:d	                     d
„ |D ¦   «         ¦  «        }t          j	        d|› d|› d�¦  «        ‚|| j
        d<   | j                             ddd¬¦  «        }|r8t          |t          ¦  «        st          |› d�t          d¦  «         || j
        d<   | j                             ddd¬¦  «        }|ry|                     d¦  «        }|D ]W}t           j                             t           j                             |¦  «        ¦  «        st          |› d�t          d¦  «         ŒX|| j
        d<   	 | j                             ddd¬¦  «        }	n6# t(          $ r)}
t          j	        dt          |
¦  «        › �¦  «        ‚d}
~
ww xY w|	�
|	| j
        d<   	 | j                             ddd¬¦  «        }n6# t(          $ r)}
t          j	        dt          |
¦  «        › �¦  «        ‚d}
~
ww xY w|�
|| j
        d<   | j                             ddd¬¦  «        }|dk    r*|dk     s|dk    rt          j	        d¦  «        ‚|| j
        d<   | j                             ddd¬¦  «        }|�
|| j
        d<   | j                             ddd¬¦  «        }|dk    r$|dk    rt          j	        d¦  «        ‚|| j
        d<   | j                             dd d¬¦  «        }|�|| j
        d <   dS dS dS )!z?Read config file and parse the contents into the settings attr.NÚdefaultÚcircuit_drawer)Úfallback)ÚtextÚmplÚlatexÚlatex_sourceÚautozi is not a valid circuit drawer backend. Must be either 'text', 'mpl', 'latex', 'latex_source', or 'auto'.Ústate_drawer)Úreprr   r   r   ÚqsphereÚhintonÚblochz', 'c              3   ó   K  — | ]}|V — Œd S ©N© )Ú.0Úcs     r   ú	<genexpr>z.UserConfig.read_config_file.<locals>.<genexpr>V   s"   è è € Ð6VÐ6V¸Q°qÐ6VÐ6VÐ6VÐ6VÐ6VÐ6Vr   ú'z5' is not a valid state drawer backend. Choose from: 'Úcircuit_mpl_stylezN is not a valid mpl circuit style. Must be a text string. Will not load style.é   Úcircuit_mpl_style_pathú:zT is not a valid circuit mpl style path. Correct the path in ~/.qiskit/settings.conf.Úcircuit_reverse_bitsz5Value assigned to circuit_reverse_bits is not valid. Úcircuit_idle_wiresz3Value assigned to circuit_idle_wires is not valid. Útranspile_optimization_leveléÿÿÿÿr   é   z<%s is not a valid optimization level. Must be 0, 1, 2, or 3.ÚparallelÚparallel_enabledÚnum_processesz=%s is not a valid number of processes. Must be greater than 0Úsabre_all_threads)ÚosÚpathÚisfiler
   r   ÚreadÚsectionsÚgetr   ÚQiskitUserConfigErrorr   ÚjoinÚ
isinstanceÚstrr   ÚUserWarningÚsplitÚexistsÚ
expanduserÚ
getbooleanÚ
ValueErrorÚgetint)r   r   r   Úvalid_state_drawersÚvalid_choices_stringr(   r*   Ú
cpath_listr6   r,   Úerrr-   r.   r2   r3   r4   s                   r   Úread_config_filezUserConfig.read_config_file8   s  € åŒw�~Š~˜dœmÑ,Ô,ð 	ØˆFØÔ×Ò ¤Ñ.Ô.Ð.Ø˜Ô*×3Ò3Ñ5Ô5Ð5Ñ5à!Ô/×3Ò3°IÐ?OÐZ^Ð3Ñ_Ô_ˆNØð AØ!Ð)YÐYÐYÝ$Ô:Ø)ð "ð "ð "ñô ð ð
 3A�”Ð.Ñ/ð  Ô-×1Ò1°)¸^ÐVZÐ1Ñ[Ô[ˆLØð =ð'ð 'ð 'Ð#ð  Ð':Ð:Ð:Ø+1¯;ª;Ð6VÐ6VÐBUÐ6VÑ6VÔ6VÑ+VÔ+VÐ(Ý$Ô:ðA˜Lð Að AØ)=ðAð Að Añô ð ð 1=�”˜nÑ-ð !%Ô 2× 6Ò 6ØÐ.¸ð !7ñ !ô !Ðð !ð GÝ!Ð"3µSÑ9Ô9ð ÝØ,ð >ð >ð >å#Øñ	ô ð ð 6G�”Ð1Ñ2ð &*Ô%7×%;Ò%;ØÐ3¸dð &<ñ &ô &Ð"ð &ð 
EØ3×9Ò9¸#Ñ>Ô>�
Ø&ð ð �DÝœ7Ÿ>š>­"¬'×*<Ò*<¸TÑ*BÔ*BÑCÔCð ÝØ#ð Lð Lð Lå'Øñ	ô ð øð ;E�”Ð6Ñ7ðØ'+Ô'9×'DÒ'DØÐ5Àð (Eñ (ô (Ð$Ð$øõ ð ð ð Ý Ô6ØVÍCÐPSÉHÌHÐVÐVñô ð øøøøðøøøð $Ð/Ø8L�”Ð4Ñ5ðØ%)Ô%7×%BÒ%BØÐ3¸dð &Cñ &ô &Ð"Ð"øõ ð ð ð Ý Ô6ØTÍ#ÈcÉ(Ì(ÐTÐTñô ð øøøøðøøøð "Ð-Ø6H�”Ð2Ñ3ð ,0Ô+=×+DÒ+DØÐ9ÀBð ,Eñ ,ô ,Ð(ð ,¨rÒ1Ð1Ø/°!Ò3Ð3Ð7SÐVWÒ7WÐ7WÝ$Ô:ØVñô ð ð A]�”Ð<Ñ=ð  $Ô1×<Ò<¸YÈ
Ð]aÐ<ÑbÔbÐØÐ+Ø4D�”Ð0Ñ1ð !Ô.×5Ò5°iÀÐ[]Ð5Ñ^Ô^ˆMØ Ò"Ð"Ø  AÒ%Ð%Ý$Ô:ØWñô ð ð 2?�”˜oÑ.ð !%Ô 2× =Ò =ØÐ.¸ð !>ñ !ô !Ðð !Ð,Ø5F�”Ð1Ñ2Ð2Ð2ði 6Ð5ðf -Ð,s0   ÈH È
IÈ)$IÉIÉ"J  Ê 
J3Ê
$J.Ê.J3r"   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   rJ   r#   r   r   r   r      sK   € € € € € ðð ð"9ð 9ð 9ð 9ðyGð yGð yGð yGð yGr   r   c           	      ó  — |pt          j        dt          ¦  «        }|€dn|}t          | t          ¦  «        st          j        d¦  «        ‚h d£}|dv r| |vrt          j        | › d�¦  «        ‚t          j        ¦   «         }| 	                    |¦  «         || 
                    ¦   «         vr|                     |¦  «         |                     || t	          |¦  «        ¦  «         	 t          |d¦  «        5 }|                     |¦  «         ddd¦  «         n# 1 swxY w Y   n:# t          $ r-}t          j        d	|› d
t	          |¦  «        › d�¦  «        ‚d}~ww xY wt!          |¦  «        }	|	                     ¦   «          dS )aq  Adds or modifies a user configuration

    It will add configuration to the currently configured location
    or the value of file argument.

    Only valid user config can be set in 'default' section. Custom
    user config can be added in any other sections.

    Changes to the existing config file will not be reflected in
    the current session since the config file is parsed at import time.

    Args:
        key (str): name of the config
        value (obj): value of the config
        section (str, optional): if not specified, adds it to the
            `default` section of the config file.
        file_path (str, optional): the file to which config is added.
            If not specified, adds it to the default config file or
            if set, the value of `QISKIT_SETTINGS` env variable.

    Raises:
        QiskitUserConfigError: if the config is invalid
    ÚQISKIT_SETTINGSNr   zKey must be string type>	   r1   r3   r   r(   r4   r-   r,   r*   r.   )Nr   z is not a valid user config.ÚwzUnable to load the config file z
. Error: 'r'   )r5   Úgetenvr	   r=   r>   r   r;   r   r   r8   r9   Úadd_sectionÚsetÚopenÚwriteÚOSErrorr   rJ   )
ÚkeyÚvalueÚsectionÚ	file_pathr
   Úvalid_configÚconfigÚcfgfileÚexÚuser_configs
             r   Ú
set_configra   ´   sè  € ð0 ÐJ�BœIÐ&7Õ9IÑJÔJ€HØ"˜?ˆiˆi°€Gå�c�3ÑÔð JÝÔ.Ð/HÑIÔIÐIð
ð 
ð 
€Lð Ð#Ð#Ð#Ø�lÐ"Ð"ÝÔ2°cÐ3WÐ3WÐ3WÑXÔXÐXåÔ&Ñ(Ô(€FØ
‡K‚K�ÑÔÐà�f—o’oÑ'Ô'Ð'Ð'Ø×Ò˜7Ñ#Ô#Ð#à
‡J‚Jˆw˜�S ™ZœZÑ(Ô(Ð(ð
Ý�(˜CÑ Ô ð 	" GØ�LŠL˜Ñ!Ô!Ð!ð	"ð 	"ð 	"ñ 	"ô 	"ð 	"ð 	"ð 	"ð 	"ð 	"ð 	"øøøð 	"ð 	"ð 	"ð 	"øøåð 
ð 
ð 
ÝÔ.ØL¨hÐLÐLÅ#ÀbÁ'Ä'ÐLÐLÐLñ
ô 
ð 	
øøøøð
øøøõ ˜XÑ&Ô&€KØ× Ò Ñ"Ô"Ð"Ð"Ð"s<   Ã'D% Ã7DÄD% ÄDÄD% Ä DÄ!D% Ä%
EÄ/(EÅEc                  óÌ   — t          j        dt          ¦  «        } t           j                             | ¦  «        si S t          | ¦  «        }|                     ¦   «          |j        S )aa  Read the config file from the default location or env var

    It will read a config file at either the default location
    ~/.qiskit/settings.conf or if set the value of the QISKIT_SETTINGS env var.

    It will return the parsed settings dict from the parsed config file.
    Returns:
        dict: The settings dict from the parsed config file.
    rP   )r5   rR   r	   r6   r7   r   rJ   r   )r
   r`   s     r   Ú
get_configrc   ÷   sZ   € õ ŒyÐ*Õ,<Ñ=Ô=€HÝŒ7�>Š>˜(Ñ#Ô#ð Øˆ	Ý˜XÑ&Ô&€KØ× Ò Ñ"Ô"Ð"ØÔÐr   )NN)rN   r   r5   Úwarningsr   Úqiskitr   r6   r<   rB   r	   r   ra   rc   r#   r   r   ú<module>rf      sÙ   ðð 8Ð 7à Ð Ð Ð Ø 	€	€	€	Ø Ð Ð Ð Ð Ð à Ð Ð Ð Ð Ð à”7—<’< ¤× 2Ò 2°3Ñ 7Ô 7¸ÀOÑTÔTÐ ðYGð YGð YGð YGð YGñ YGô YGð YGðx@#ð @#ð @#ð @#ðF ð  ð  ð  ð  r   