� ��g�+���dZddlmZddlZddlmZddlmZmZm Z m Z m Z m Z m Z mZmZmZeje��Zgd�ZGd�de��ZGd �d e��ZGd �d e��ZGd �de��ZGd�de��Zedd���Gd�d����ZGd�de ��Ze��ZGd�de ��ZdS)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��eZdZdZdS)rz%Base exception for the config module.N)�__name__� __module__� __qualname__�__doc__���j/home/asafur/pinokio/api/open-webui.git/app/env/lib/python3.11/site-packages/fontTools/misc/configTools.pyrr,s������/�/�/�/rrc�"��eZdZdZ�fd�Z�xZS)rz�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�R��t���d|�d���dS)N�Config option z is already registered.)�super�__init__)�self�name� __class__s �rr#z%ConfigAlreadyRegisteredError.__init__8s-��� �����G�$�G�G�G�H�H�H�H�Hr�rrrrr#� __classcell__�r&s@rrr0sK���������I�I�I�I�I�I�I�I�Irrc�"��eZdZdZ�fd�Z�xZS)rz3Raised when a configuration value cannot be parsed.c�r��t���d|�dt|���d���dS)Nr!z : value cannot be parsed (given �)�r"r#�repr�r$r%�valuer&s �rr#z ConfigValueParsingError.__init__?sE��� ����� Q�T� Q� Q�4��;�;� Q� Q� Q� � � � � rr'r)s@rrr<s>�������=�=� � � � � � � � � rrc�"��eZdZdZ�fd�Z�xZS)rz6Raised when a configuration value cannot be validated.c�r��t���d|�dt|���d���dS)Nr!z: value is invalid (given r,r-r/s �rr#z#ConfigValueValidationError.__init__HsE��� ����� K�T� K� K�T�%�[�[� K� K� K� � � � � rr'r)s@rrrEs>�������@�@� � � � � � � � � rrc�"��eZdZdZ�fd�Z�xZS)rz.Raised when a configuration option is unknown.c���t|t��rd|j�dt|���d�nd|�d�}t ���d|�d���dS)N�'z' (id=z)>r!z is unknown)� isinstancerr%�idr"r#)r$�option_or_namer%r&s �rr#z!ConfigUnknownOptionError.__init__Qsz����.�&�1�1� '� A��#� A� A�2�n�+=�+=� A� A� A� A�&�^�&�&�&� � �����;�$�;�;�;�<�<�<�<�<rr'r)s@rrrNs>�������8�8�=�=�=�=�=�=�=�=�=rrTF)�frozen�eqc��eZdZUded< ded< ded< ded< dZd ed < edd���Zedd���ZdS)r�strr%�helpr�default�Callable[[str], Any]�parseN�Optional[Callable[[Any], bool]]�validate�v�return�Optional[bool]c��t|�����}|dvrdS|dvrdS|dvrdStd���)N>�0�no�falseF>�1�yes�trueT>�auto�nonezinvalid optional bool: {v!r})r<�lower� ValueError)rC�ss r�parse_optional_boolzOption.parse_optional_boolhsW�� ��F�F�L�L�N�N�� �$� $� $��5� �$� $� $��4� � � � ��4��7�8�8�8r�boolc�4�|dupt|t��S�N)r6rS)rCs r�validate_optional_boolzOption.validate_optional_boolss���D�y�/�J�q�$�/�/�/r)rCr<rDrE)rCrrDrS)rrr�__annotations__rB� staticmethodrRrVrrrrr[s�������� �I�I�I�M� �I�I�I�$��L�L�L�(�����Q�04�H�4�4�4�4�@��9�9�9��\�9��0�0�0��\�0�0�0rrc�d�eZdZUdZded<d d!d �Z d d"d�Zd#d�Zd$d�Zd%d�Z d&d�Z d'd�Z d(d�Z dS))rz�Registry of available options for a given config system. Define new options using the :meth:`register()` method. Access existing options using the Mapping interface. zDict[str, Option]�_Options__optionsN�other� 'Options'rD�Nonec�t�i|_|�,|���D]}|�|���dSdSrU)rZ�values�register_option)r$r[�options rr#zOptions.__init__�sO����� � ��,�,�.�.� -� -���$�$�V�,�,�,�,� � � -� -rr%r<r=r>rr@r?rBrArc �N�|�t|||||����S)z!Create and register a new option.)r`r)r$r%r=r>r@rBs r�registerzOptions.register�s(���#�#�F�4��w��x�$P�$P�Q�Q�Qrrac�X�|j}||jvrt|���||j|<|S)zRegister a new option.)r%rZr)r$rar%s rr`zOptions.register_option�s5���{�� �4�>� !� !�.�t�4�4� 4�%���t��� rrSc�D�|j�|j��|uS)z<Return True if the same option object is already registered.)rZ�getr%)r$ras r� is_registeredzOptions.is_registered�s���~�!�!�&�+�.�.�&�8�8r�keyc�6�|j�|��SrU)rZ� __getitem__)r$rhs rrjzOptions.__getitem__�s���~�)�)�#�.�.�.r� Iterator[str]c�4�|j���SrU)rZ�__iter__�r$s rrmzOptions.__iter__�s���~�&�&�(�(�(r�intc�4�|j���SrU)rZ�__len__rns rrqzOptions.__len__�s���~�%�%�'�'�'rc��|jj�d�d�d�|j���D����zdzS)Nz({ �c3�8K�|]\}}d|�d|j�d�V��dS)z z: Option(default=z, ...), N)r>)�.0�krCs r� <genexpr>z#Options.__repr__.<locals>.<genexpr>�sP�������A�q�D�q�C�C�Q�Y�C�C�C������rz}))r&r�joinrZ�itemsrns r�__repr__zOptions.__repr__�sb���~�&� -� -� -��g�g��� �N�0�0�2�2������ � �  � rrU)r[r\rDr]� r%r<r=r<r>rr@r?rBrArDr)rarrDr)rarrDrS)rhr<rDr)rDrk�rDro�rDr<) rrrrrWr#rcr`rgrjrmrqrzrrrrrxs����������!� � � �-�-�-�-�-�59� R� R� R� R� R�����9�9�9�9�/�/�/�/�)�)�)�)�(�(�(�(� � � � � � rrc��eZdZUdZded<e d*d+d���Zded<iddfd,d�Zd-d�Z d.d/d�Z e fd0d�Z d �Z d1d!�Z d2d#�Zd3d$�Zd4d&�Zd5d(�Zd6d)�ZdS)7ra� 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}) zClassVar[Options]�optionsNr%r<r=r>rr@r?rBrArDrc�@�|j�|||||���S)z3Register an available option in this config system.)r=r>r@rB)rrc)�clsr%r=r>r@rBs rr`zAbstractConfig.register_option�s.���{�#�#� �t�W�E�H�$� � � rzDict[str, Any]�_valuesFr_�4Union[AbstractConfig, Dict[Union[Option, str], Any]]� parse_valuesrS� skip_unknownc��i|_t|t��r|jn|}|���D]\}}|�||||���dSrU)r�r6rry�set)r$r_r�r�� values_dictr%r0s rr#zAbstractConfig.__init__�sj�� �� �(2�6�>�(J�(J�V�f�n�n�PV� �&�,�,�.�.� >� >�K�D�%� �H�H�T�5�,� � =� =� =� =� >� >rr8�Union[Option, str]c�X�t|t��r-|}|j�|��st |���|St|t ��r-|} |j|S#t $rt |���wxYwtdt|��j �d|�����)Nzexpected Option or str, found z: ) r6rrrgrr<�KeyError� TypeError�typer)r$r8rar%s r�_resolve_optionzAbstractConfig._resolve_option�s��� �n�f� -� -� �#�F��<�-�-�f�5�5� 7�.�v�6�6�6��M� ��� ,� ,� �!�D� 5��|�D�)�)��� 5� 5� 5�.�t�4�4�4� 5�����G���'�'�0�G�G�4B�G�G��� s � A(�(Br0c�� |�|��}nB#t$r5}|r-t�t |����Yd}~dS�d}~wwxYw|r? |�|��}n(#t $r}t|j|��|�d}~wwxYw|j �*|� |��st|j|���||j |j<dS)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@� Exceptionrr%rBrr�)r$r8r0r�r�ra�es rr�zAbstractConfig.set�s��, ��)�)�.�9�9�F�F��'� � � �� �� � �#�a�&�&�!�!�!������� �����  ���� � I� I�� � �U�+�+����� I� I� I�-�f�k�5�A�A�q�H����� I���� �?� &�v���u�/E�/E� &�,�V�[�%�@�@� @�$)�� �V�[�!�!�!s2�� A�)A�A�A�A3�3 B�=B�Bc��|�|��}|j|jvr|j|jS|tur|S|jS)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$r8r>ras rrfzAbstractConfig.get)sN��2�%�%�n�5�5�� �;�$�,� &� &��<�� �,� ,� �-� -� -��N��~�rc�6�|�|j��SrU)r&r�rns r�copyzAbstractConfig.copyIs���~�~�d�l�+�+�+rc�,�|�|��SrU)rf)r$r8s rrjzAbstractConfig.__getitem__Ls���x�x��'�'�'rr]c�.�|�||��SrU)r�)r$r8r0s r� __setitem__zAbstractConfig.__setitem__Os���x�x���.�.�.rc�J�|�|��}|j|j=dSrU)r�r�r%)r$r8ras r� __delitem__zAbstractConfig.__delitem__Rs'���%�%�n�5�5�� �L��� %� %� %r� Iterable[str]c�4�|j���SrU)r�rmrns rrmzAbstractConfig.__iter__Vs���|�$�$�&�&�&rroc�*�t|j��SrU)�lenr�rns rrqzAbstractConfig.__len__Ys���4�<� � � rc�J�|jj�dt|j���d�S)N�(r,)r&rr.r�rns rrzzAbstractConfig.__repr__\s(���.�)�A�A�D���,>�,>�A�A�A�ArrUr{)r_r�r�rSr�rS)r8r�rDr)FF)r8r�r0rr�rSr�rS)r8r�r>rrDr)r8r�rDr)r8r�r0rrDr])r8r�rDr])rDr�r|r})rrrrrW� classmethodr`r#r�r�r�rfr�rjr�r�rmrqrzrrrrr�sn���������0�����59�  �  �  �  ��[�  �����HJ�"�"� >� >� >� >� >�����,#�"� )*�)*�)*�)*�)*�XBU������@,�,�,�(�(�(�(�/�/�/�/�&�&�&�&�'�'�'�'�!�!�!�!�B�B�B�B�B�Brr) r� __future__r�logging� dataclassesr�typingrrrrr r r r r r� getLoggerrr��__all__r�rrrrrrr�objectr�rrrr�<module>r�sz�� � �#�"�"�"�"�"�����!�!�!�!�!�!� � � � � � � � � � � � � � � � � � � � � � � � ��g���!�!�� � � ��0�0�0�0�0�)�0�0�0� I� I� I� I� I�;� I� I� I� � � � � �k� � � � � � � � �� � � � =� =� =� =� =�{� =� =� =� ��$�5�!�!�!�0�0�0�0�0�0�0�"�!�0�88 �8 �8 �8 �8 �g�8 �8 �8 �v�f�h�h��gB�gB�gB�gB�gB�^�gB�gB�gB�gB�gBr
Memory