
    qh0                    j   % S SK Jr  S SKJrJr  S SKJr  S SKJrJ	r	J
r
  S SKJrJrJr  \(       a  S SKJr  SSKJr  S	rS
\S'    " S S\
5      r\\\      " S/ 5      r\\\\\\	4   4      " S0 5      r\\   " SS 5      r\\\4rS\S'   S qS
\S'   SS jrSS jr \SS j5       r!SS jr"SS jr#S S jr$g)!    )annotations)contextmanagersuppressPath)TYPE_CHECKINGAny	TypedDict)
BaseOptionGameHiddenOption)Iterator   )TextMod   intCURRENT_MOD_INFO_VERSIONc                  f    \ rS rSr% S\S'   S\S'   S\S'   S\S	'   S
\S'   S
\S'   S
\S'   S
\S'   Srg)ModInfo   floatmodify_timebool	ignore_mez
int | Nonespark_service_idxzGame | Nonerecommended_gamestrtitleauthorversiondescription N)__name__
__module____qualname____firstlineno____annotations____static_attributes__r"       cZ:\mnt\Skyabridged\SteamLibrary\steamapps\common\Borderlands 2\sdk_mods\text_mod_loader\settings.pyr   r      s.    O!!!!JKLr)   r   auto_enablemod_infor    ztuple[BaseOption, ...]all_settings#suppress_auto_enable_update_counterc                    [         R                  [        :w  a  [        R                  R	                  5         [        [         l        [
        R                   V s/ s HU  n [        U 5      =nR                  5       (       d  M%  UR                  5       (       d  M<  [        UR                  5       5      PMW     sn [
        l        [        R                  R                  5        VVs0 s HX  u  p#[        U5      =nR                  5       (       d  M'  UR                  5       (       d  M>  [        UR                  5       5      U_MZ     snn[        l        [        R                  5         gs  sn f s  snnf )z
Sanitizes the mod file paths we're storing in settings.

Normalizes mod file paths them, and removes any for mod files which no longer exist on disk.
Clears cached mod info on TML updates.
N)r    valuer   r,   clearr+   r   existsis_filer   resolveitemssave)xpathkvs       r*   sanitize_settingsr;   -   s     }}00,GM """AGOD##% 	*.,,. 	DLLN"K NN((**DAGOD##% 	*.,,. 	DLLNQ*HN MMO
s$   $E" E"E"!&E'E'"E'c                d   [         S:  a  g[        U R                  R                  5       5      n[	        [
        5         [        R                  R                  U5        SSS5        U(       a  [        R                  R                  U5        [        R                  5         g! , (       d  f       NI= f)z{
Changes if a mod should be auto-enabled.

Args:
    mod: The mod to edit.
    enable: True if the mod should auto-enable.
r   N)r.   r   filer4   r   
ValueErrorr+   r0   removeappendr6   )modenabler8   s      r*   change_mod_auto_enablerC   J   sw     +Q.sxx!"D 
*	  & 
   & 
	s    B!!
B/c               #  8   #    [         S-  q Sv   [         S-  q g7f)zWContext manager which suppresses any changes to the auto enabled mod list while active.r   N)r.   r"   r)   r*   suppress_auto_enable_updatesrE   a   s       (1,'	'1,'   c               #  N   #    S [         R                   5        Sh  vN   g N7f)zS
Gets the mod file paths which should auto-enable.

Yields:
    The mod file paths
c              3  8   #    U  H  n[        U5      v   M     g 7f)Nr   ).0r7   s     r*   	<genexpr>*iter_auto_enabled_paths.<locals>.<genexpr>q   s     3!2AQ!2rF   N)r+   r0   r"   r)   r*   iter_auto_enabled_pathsrL   j   s      4!2!2333s   %#%c           	     h   [         R                  R                  [        U R	                  5       5      5      =nc  gSSSSU R
                  SSSS.U-  n[        US   [        5      (       a%  [        R                  R                  US   5      US'   U R                  5       R                  US   :  a  gU$ )	z
If we have the mod info for the given path cached, gets it.

Args:
    path: The path to check for mod info on.
Returns:
    The mod info, or None if not cached.
Nr   FzText Mod Loader r   r   r   r   r   r   r    r!   r   r   )r,   r0   getr   r4   name
isinstancer   __members__statst_mtime)r8   raw_dictcached_infos      r*   get_cached_mod_inforX   t   s     NN&&s4<<>':;;D ! #	 		K +01377*.*:*:*>*>{K]?^*_&' yy{k-88r)   c           	         US   US   US   US   =nc  SOUR                   US   US   US   US	   S
.[        R                  [        U R	                  5       5      '   [        R                  5         g)zo
Cache the mod info for the given path.

Args:
    path: The path to cache under.
    info: The info to cache.
r   r   r   r   Nr   r   r    r!   rO   )rQ   r,   r0   r   r4   r6   )r8   infogames      r*   update_cached_mod_infor\      s|     M*+&!"56-12D-E%ET$NDTXT]T]gx.	?M*	+HNN3t||~&' MMOr)   N)returnNone)rA   r   rB   r   r]   r^   )r]   zIterator[None])r]   zIterator[Path])r8   r   r]   zModInfo | None)r8   r   rZ   r   r]   r^   )%
__future__r   
contextlibr   r   pathlibr   typingr   r	   r
   	mods_baser   r   r   collections.abcr   text_modr   r   r'   r   listr   r+   dictr,   r   r    r-   r.   r;   rC   rE   rL   rX   r\   r"   r)   r*   <module>rh      s    " /  0 0 4 4(! ! # !
i 
 49%mR8S$sCx.012:rB s
Iq
) ($  ,- #S ,:. - -4!Hr)   