Ë
    £eh´+  ã                  óZ  — d Z ddlmZ ddlZddlmZ ddlmZmZm	Z	m
Z
mZmZmZmZmZmZ  ej"                  e«      Zg d¢Z G d„ de«      Z G d	„ d
e«      Z G d„ de«      Z G d„ de«      Z G d„ de«      Z edd¬«       G d„ d«      «       Z G d„ de«      Z e«       Z G d„ de«      Zy)a`  
Code of the config system; not related to fontTools or fonts in particular.

The options that are specific to fontTools are in :mod:`fontTools.config`.

To create your own config system, you need to create an instance of
:class:`Options`, and a subclass of :class:`AbstractConfig` with its
``options`` class variable set to your instance of Options.

é    )ÚannotationsN)Ú	dataclass)
ÚAnyÚCallableÚClassVarÚDictÚIterableÚMappingÚMutableMappingÚOptionalÚSetÚUnion)ÚAbstractConfigÚConfigAlreadyRegisteredErrorÚConfigErrorÚConfigUnknownOptionErrorÚConfigValueParsingErrorÚConfigValueValidationErrorÚOptionÚOptionsc                  ó   — e Zd ZdZy)r   z%Base exception for the config module.N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__© ó    úX/var/www/skyplay_api_hub/venv/lib/python3.12/site-packages/fontTools/misc/configTools.pyr   r   ,   s   „ Ú/r   r   c                  ó"   ‡ — e Zd ZdZˆ fd„Zˆ xZS )r   z¶Raised when a module tries to register a configuration option that
    already exists.

    Should not be raised too much really, only when developing new fontTools
    modules.
    c                ó,   •— t         ‰| �  d|› d�«       y )NúConfig option z is already registered.)ÚsuperÚ__init__)ÚselfÚnameÚ	__class__s     €r   r#   z%ConfigAlreadyRegisteredError.__init__8   s   ø€ Ü‰Ñ˜>¨$¨Ð/FÐGÕHr   ©r   r   r   r   r#   Ú__classcell__©r&   s   @r   r   r   0   s   ø„ ñ÷Ið Ir   r   c                  ó"   ‡ — e Zd ZdZˆ fd„Zˆ xZS )r   z3Raised when a configuration value cannot be parsed.c                óD   •— t         ‰| �  d|› dt        |«      › d�«       y )Nr!   z : value cannot be parsed (given ú)©r"   r#   Úrepr©r$   r%   Úvaluer&   s      €r   r#   z ConfigValueParsingError.__init__?   s'   ø€ Ü‰ÑØ˜T˜FÐ"BÄ4ÈÃ;À-ÈqÐQõ	
r   r'   r)   s   @r   r   r   <   s   ø„ Ù=÷
ð 
r   r   c                  ó"   ‡ — e Zd ZdZˆ fd„Zˆ xZS )r   z6Raised when a configuration value cannot be validated.c                óD   •— t         ‰| �  d|› dt        |«      › d�«       y )Nr!   z: value is invalid (given r,   r-   r/   s      €r   r#   z#ConfigValueValidationError.__init__H   s'   ø€ Ü‰ÑØ˜T˜FÐ"<¼TÀ%»[¸MÈÐKõ	
r   r'   r)   s   @r   r   r   E   s   ø„ Ù@÷
ð 
r   r   c                  ó"   ‡ — e Zd ZdZˆ fd„Zˆ xZS )r   z.Raised when a configuration option is unknown.c                ó�   •— t        |t        «      rd|j                  › dt        |«      › d�nd|› d�}t        ‰| �  d|› d�«       y )Nú'z' (id=z)>r!   z is unknown)Ú
isinstancer   r%   Úidr"   r#   )r$   Úoption_or_namer%   r&   s      €r   r#   z!ConfigUnknownOptionError.__init__Q   sZ   ø€ ô ˜.¬&Ô1ð �×#Ñ#Ð$ F¬2¨nÓ+=Ð*>¸bÑAà�^Ð$ AÐ&ð 	ô
 	‰Ñ˜>¨$¨¨{Ð;Õ<r   r'   r)   s   @r   r   r   N   s   ø„ Ù8÷=ð =r   r   TF)ÚfrozenÚeqc                  ór   — e Zd ZU ded<   	 ded<   	 ded<   	 ded<   	 dZd	ed
<   	 edd„«       Zedd„«       Zy)r   Ústrr%   Úhelpr   ÚdefaultúCallable[[str], Any]ÚparseNúOptional[Callable[[Any], bool]]Úvalidatec                óh   — t        | «      j                  «       }|dv ry|dv ry|dv ry t        d«      ‚)N>   Ú0ÚnoÚfalseF>   Ú1ÚyesÚtrueT>   ÚautoÚnonezinvalid optional bool: {v!r})r<   ÚlowerÚ
ValueError)ÚvÚss     r   Úparse_optional_boolzOption.parse_optional_boolh   sA   € ä�‹F�L‰L‹NˆØÐ$Ñ$ØØÐ$Ñ$ØØÐ Ñ ØÜÐ7Ó8Ð8r   c                ó.   — | d u xs t        | t        «      S ©N)r6   Úbool)rN   s    r   Úvalidate_optional_boolzOption.validate_optional_bools   s   € à�DˆyÒ/œJ q¬$Ó/Ð/r   )rN   r<   ÚreturnzOptional[bool])rN   r   rU   rS   )r   r   r   Ú__annotations__rB   ÚstaticmethodrP   rT   r   r   r   r   r   [   sW   … à
ƒIØMØ
ƒIØ$ØƒLØ(ØÓØQØ04€HÐ-Ó4Ø@àò9ó ð9ð ò0ó ñ0r   r   c                  óx   — e Zd ZU dZded<   ddd„Z	 d	 	 	 	 	 	 	 	 	 	 	 dd„Zdd„Zdd„Zdd	„Z	dd
„Z
dd„Zdd„Zy)r   z´Registry of available options for a given config system.

    Define new options using the :meth:`register()` method.

    Access existing options using the Mapping interface.
    zDict[str, Option]Ú_Options__optionsNc                ód   — i | _         |�'|j                  «       D ]  }| j                  |«       Œ y y rR   )rY   ÚvaluesÚregister_option)r$   ÚotherÚoptions      r   r#   zOptions.__init__‚   s7   € ØˆŒØÐØŸ,™,›.ò -�Ø×$Ñ$ VÕ,ñ-ð r   c           	     ó>   — | j                  t        |||||«      «      S )z!Create and register a new option.)r\   r   )r$   r%   r=   r>   r@   rB   s         r   ÚregisterzOptions.registerˆ   s"   € ð ×#Ñ#¤F¨4°°wÀÀxÓ$PÓQÐQr   c                ón   — |j                   }|| j                  v rt        |«      ‚|| j                  |<   |S )zRegister a new option.)r%   rY   r   )r$   r^   r%   s      r   r\   zOptions.register_option“   s5   € à�{‰{ˆØ�4—>‘>Ñ!Ü.¨tÓ4Ð4Ø%ˆ�‰�tÑØˆr   c                óP   — | j                   j                  |j                  «      |u S )z<Return True if the same option object is already registered.)rY   Úgetr%   )r$   r^   s     r   Úis_registeredzOptions.is_registered›   s    € à�~‰~×!Ñ! &§+¡+Ó.°&Ð8Ð8r   c                ó8   — | j                   j                  |«      S rR   )rY   Ú__getitem__)r$   Úkeys     r   rf   zOptions.__getitem__Ÿ   s   € Ø�~‰~×)Ñ)¨#Ó.Ð.r   c                ó6   — | j                   j                  «       S rR   )rY   Ú__iter__©r$   s    r   ri   zOptions.__iter__¢   s   € Ø�~‰~×&Ñ&Ó(Ð(r   c                ó6   — | j                   j                  «       S rR   )rY   Ú__len__rj   s    r   rl   zOptions.__len__¥   s   € Ø�~‰~×%Ñ%Ó'Ð'r   c                óœ   — | j                   j                  › d�dj                  d„ | j                  j	                  «       D «       «      z   dz   S )Nz({
Ú c              3  óH   K  — | ]  \  }}d |›d|j                   ›d�–— Œ y­w)z    z: Option(default=z, ...),
N)r>   )Ú.0ÚkrN   s      r   ú	<genexpr>z#Options.__repr__.<locals>.<genexpr>«   s0   è ø€ ò á�A�qð �q�eÐ,¨Q¯Y©Y¨M¸ÔCñùs   ‚ "z}))r&   r   ÚjoinrY   Úitemsrj   s    r   Ú__repr__zOptions.__repr__¨   sQ   € à�~‰~×&Ñ&Ð' uÐ-Ø�g‰gñ à ŸN™N×0Ñ0Ó2ôó ñð
 ñð	
r   rR   )r]   z	'Options'rU   ÚNone©r%   r<   r=   r<   r>   r   r@   r?   rB   rA   rU   r   )r^   r   rU   r   )r^   r   rU   rS   )rg   r<   rU   r   )rU   zIterator[str]©rU   Úint©rU   r<   )r   r   r   r   rV   r#   r`   r\   rd   rf   ri   rl   ru   r   r   r   r   r   x   s}   … ñð !Ó ô-ð 59ð	Ràð	Rð ð	Rð ð		Rð
 $ð	Rð 2ð	Rð 
ó	Róó9ó/ó)ó(ô
r   r   c                  óÜ   — e Zd ZU dZded<   e	 d	 	 	 	 	 	 	 	 	 	 	 dd„«       Zded<   i ddf	 	 	 	 	 dd	„Zdd
„Z	 	 d	 	 	 	 	 	 	 dd„Z	e
f	 	 	 	 	 dd„Zd„ Zdd„Zdd„Zdd„Zdd„Zdd„Zd d„Zy)!r   aü  
    Create a set of config values, optionally pre-filled with values from
    the given dictionary or pre-existing config object.

    The class implements the MutableMapping protocol keyed by option name (`str`).
    For convenience its methods accept either Option or str as the key parameter.

    .. seealso:: :meth:`set()`

    This config class is abstract because it needs its ``options`` class
    var to be set to an instance of :class:`Options` before it can be
    instanciated and used.

    .. code:: python

        class MyConfig(AbstractConfig):
            options = Options()

        MyConfig.register_option( "test:option_name", "This is an option", 0, int, lambda v: isinstance(v, int))

        cfg = MyConfig({"test:option_name": 10})

    zClassVar[Options]ÚoptionsNc                óB   — | j                   j                  |||||¬«      S )z3Register an available option in this config system.)r=   r>   r@   rB   )r|   r`   )Úclsr%   r=   r>   r@   rB   s         r   r\   zAbstractConfig.register_optionÑ   s+   € ð �{‰{×#Ñ#Ø�t W°EÀHð $ó 
ð 	
r   zDict[str, Any]Ú_valuesFc                ó¦   — i | _         t        |t        «      r|j                   n|}|j                  «       D ]  \  }}| j	                  ||||«       Œ y rR   )r   r6   r   rt   Úset)r$   r[   Úparse_valuesÚskip_unknownÚvalues_dictr%   r0   s          r   r#   zAbstractConfig.__init__á   sN   € ð ˆŒÜ(2°6¼>Ô(J�f—n’nÐPVˆØ&×,Ñ,Ó.ò 	>‰KˆD�%Ø�H‰H�T˜5 ,°Õ=ñ	>r   c                ó2  — t        |t        «      r*|}| j                  j                  |«      st	        |«      ‚|S t        |t
        «      r|}	 | j                  |   S t        dt        |«      j                  › d|›�«      ‚# t        $ r t	        |«      ‚w xY w)Nzexpected Option or str, found z: )
r6   r   r|   rd   r   r<   ÚKeyErrorÚ	TypeErrorÚtyper   )r$   r8   r^   r%   s       r   Ú_resolve_optionzAbstractConfig._resolve_optionì   s¢   € Ü�n¤fÔ-Ø#ˆFØ—<‘<×-Ñ-¨fÔ5Ü.¨vÓ6Ð6ØˆMÜ˜¬Ô,Ø!ˆDð5Ø—|‘| DÑ)Ð)ô Ø0Ü˜Ó'×0Ñ0Ð1°°NÐ3EðGóð øô ò 5Ü.¨tÓ4Ð4ð5ús   ÁB ÂBc                ó¦  — 	 | j                  |«      }|r	 |j                  |«      }|j                  �'|j                  |«      st        |j                  |«      ‚|| j                  |j                  <   y# t        $ r+}|r#t        j                  t	        |«      «       Y d}~y‚ d}~ww xY w# t        $ r}t        |j                  |«      |‚d}~ww xY w)a_  Set the value of an option.

        Args:
            * `option_or_name`: an `Option` object or its name (`str`).
            * `value`: the value to be assigned to given option.
            * `parse_values`: parse the configuration value from a string into
                its proper type, as per its `Option` object. The default
                behavior is to raise `ConfigValueValidationError` when the value
                is not of the right type. Useful when reading options from a
                file type that doesn't support as many types as Python.
            * `skip_unknown`: skip unknown configuration options. The default
                behaviour is to raise `ConfigUnknownOptionError`. Useful when
                reading options from a configuration file that has extra entries
                (e.g. for a later version of fontTools)
        N)r‰   r   ÚlogÚdebugr<   r@   Ú	Exceptionr   r%   rB   r   r   )r$   r8   r0   r‚   rƒ   r^   Úes          r   r�   zAbstractConfig.setþ   s»   € ð,	Ø×)Ñ)¨.Ó9ˆFñ ðIØŸ™ UÓ+�ð �?‰?Ð&¨v¯©¸uÔ/EÜ,¨V¯[©[¸%Ó@Ð@à$)ˆ�‰�V—[‘[Ò!øô# (ò 	ÙÜ—	‘	œ#˜a›&Ô!ÜØûð		ûô ò IÜ-¨f¯k©k¸5ÓAÀqÐHûðIús4   ‚A4 –B+ Á4	B(Á= B#Â"B#Â#B(Â+	CÂ4CÃCc                ó²   — | j                  |«      }|j                  | j                  v r| j                  |j                     S |t        ur|S |j                  S )a£  
        Get the value of an option. The value which is returned is the first
        provided among:

        1. a user-provided value in the options's ``self._values`` dict
        2. a caller-provided default value to this method call
        3. the global default for the option provided in ``fontTools.config``

        This is to provide the ability to migrate progressively from config
        options passed as arguments to fontTools APIs to config options read
        from the current TTFont, e.g.

        .. code:: python

            def fontToolsAPI(font, some_option):
                value = font.cfg.get("someLib.module:SOME_OPTION", some_option)
                # use value

        That way, the function will work the same for users of the API that
        still pass the option to the function call, but will favour the new
        config mechanism if the given font specifies a value for that option.
        )r‰   r%   r   Ú_USE_GLOBAL_DEFAULTr>   )r$   r8   r>   r^   s       r   rc   zAbstractConfig.get)  sO   € ð2 ×%Ñ% nÓ5ˆØ�;‰;˜$Ÿ,™,Ñ&Ø—<‘< §¡Ñ,Ð,ØÔ-Ñ-ØˆNØ�~‰~Ðr   c                ó8   — | j                  | j                  «      S rR   )r&   r   rj   s    r   ÚcopyzAbstractConfig.copyI  s   € Ø�~‰~˜dŸl™lÓ+Ð+r   c                ó$   — | j                  |«      S rR   )rc   )r$   r8   s     r   rf   zAbstractConfig.__getitem__L  s   € Ø�x‰x˜Ó'Ð'r   c                ó&   — | j                  ||«      S rR   )r�   )r$   r8   r0   s      r   Ú__setitem__zAbstractConfig.__setitem__O  s   € Ø�x‰x˜¨Ó.Ð.r   c                óT   — | j                  |«      }| j                  |j                  = y rR   )r‰   r   r%   )r$   r8   r^   s      r   Ú__delitem__zAbstractConfig.__delitem__R  s"   € Ø×%Ñ% nÓ5ˆØ�L‰L˜Ÿ™Ñ%r   c                ó6   — | j                   j                  «       S rR   )r   ri   rj   s    r   ri   zAbstractConfig.__iter__V  s   € Ø�|‰|×$Ñ$Ó&Ð&r   c                ó,   — t        | j                  «      S rR   )Úlenr   rj   s    r   rl   zAbstractConfig.__len__Y  s   € Ü�4—<‘<Ó Ð r   c                ó`   — | j                   j                  › dt        | j                  «      › d�S )Nú(r,   )r&   r   r.   r   rj   s    r   ru   zAbstractConfig.__repr__\  s*   € Ø—.‘.×)Ñ)Ð*¨!¬D°·±Ó,>Ð+?¸qÐAÐAr   rR   rw   )r[   z4Union[AbstractConfig, Dict[Union[Option, str], Any]]r‚   rS   rƒ   rS   )r8   úUnion[Option, str]rU   r   )FF)r8   r�   r0   r   r‚   rS   rƒ   rS   )r8   r�   r>   r   rU   r   )r8   r�   rU   r   )r8   r�   r0   r   rU   rv   )r8   r�   rU   rv   )rU   zIterable[str]rx   rz   )r   r   r   r   rV   Úclassmethodr\   r#   r‰   r�   r�   rc   r’   rf   r•   r—   ri   rl   ru   r   r   r   r   r   ¶   s  … ñð0 Óàð 59ð
àð
ð ð
ð ð	
ð
 $ð
ð 2ð
ð 
ò
ó ð
ð Óð HJØ"Ø"ð		>àDð	>ð ð	>ð ó		>óð, #Ø"ð)*à*ð)*ð ð)*ð ð	)*ð
 ó)*ðX BUðØ0ðØ;>ðà	óò@,ó(ó/ó&ó'ó!ôBr   r   ) r   Ú
__future__r   ÚloggingÚdataclassesr   Útypingr   r   r   r   r	   r
   r   r   r   r   Ú	getLoggerr   r‹   Ú__all__r�   r   r   r   r   r   r   r   Úobjectr�   r   r   r   r   ú<module>r¦      sÄ   ðñ	õ #ã Ý !÷÷ ÷ ð €g×Ñ˜Ó!€ò	€ô0�)ô 0ô	I ;ô 	Iô
˜kô 
ô
 ô 
ô	=˜{ô 	=ñ �$˜5Ô!÷0ð 0ó "ð0ô88
ˆgô 8
ñv “hÐ ôgB�^õ gBr   