
    Jj
                         U d Z ddlZddlZddlZddlmZ defdZ ed          Zddedz  de	fdZ
i ae	ed	<   ddedz  de	fd
ZddefdZdS )up  TOML configuration file support.

Settings are resolved with this precedence (highest wins):

1. CLI flags
2. Environment variables / Docker-secrets ``_FILE`` variants
3. User config — ``$XDG_CONFIG_HOME/open-terminal/config.toml``
   (defaults to ``~/.config/open-terminal/config.toml``)
4. System config — ``/etc/open-terminal/config.toml``
5. Built-in defaults
    N)Pathreturnc                      t           j                            d          p<t           j                            t           j                            d          d          } t          |           dz  dz  S )z/Return the XDG-compliant user config file path.XDG_CONFIG_HOME~z.configzopen-terminalzconfig.toml)osenvirongetpathjoin
expanduserr   )xdgs    h/home/rurouni/.cache/uv/archive-v0/6mr0qdqUAO9GXgnL/lib/python3.11/site-packages/open_terminal/config.py_default_user_config_pathr      sZ    
*..*
+
+ rw||
30 0C 99&66    z/etc/open-terminal/config.tomlexplicit_pathc                    i }t                                           r~	 |                    t          j        t                               d                               n=# t          $ r0}t          dt            d| t          j	                   Y d}~nd}~ww xY w| rt          |           nt                      }|                                r	 |                    t          j        |                    d                               nP# t          $ rC}| rt          d| d|           |t          d| d| t          j	                   Y d}~nd}~ww xY w|S )ai  Load and merge TOML configuration files.

    Parameters
    ----------
    explicit_path:
        If given, this file replaces the *user-level* lookup.  The
        system-level config is still loaded underneath.

    Returns
    -------
    dict
        Merged configuration dictionary.  System values are overridden
        by user (or explicit) values.
    zutf-8zWarning: failed to read z: )fileNzError: failed to read )_SYSTEM_CONFIG_PATHis_fileupdatetomllibloads	read_text	Exceptionprintsysstderrr   r   
SystemExit)r   mergedexc	user_paths       r   load_configr#      s    F ""$$ 	MM'-(;(E(Eg(N(NOOPPPP 	 	 	G+>GG#GGZ        	 (5U]###:S:U:UI 
		MM'-	(;(;G(D(DEEFFFF 	 	 	 W !L)!L!Ls!L!LMMSVV=9====Z        		 Ms/   ?A 
B'&BB:D	 	
E9EE_configc                 .    t          |           at          S )zLoad config files and cache the result module-wide.

    This should be called once, early in startup (e.g. from the CLI
    entry-point), *before* ``env.py`` constants are evaluated.
    )r#   r$   )r   s    r   initr&   N   s     -((GNr   keyc                 8    t                               | |          S )z'Look up a value from the loaded config.)r$   r
   )r'   defaults     r   r
   r
   Y   s    ;;sG$$$r   )N)__doc__r   r   r   pathlibr   r   r   strdictr#   r$   __annotations__r&   r
    r   r   <module>r0      s  
 
 
 
			 



       74 7 7 7 7 d;<< ) )sTz )T ) ) ) )Z     d
 d    % %S % % % % % %r   