� ��g�M���ddlZddlZddlZddlmZddlmZmZddlZddlm Z ej Z dddd�Z Gd�d ej ��Zd �Zdd �ZGd �de��ZGd�dej��ZGd�dej��ZGd�de��Zefd�Zefd�Zedkr/ddlZejejej���j ��dSdS)�N��wraps)�Mapping�Callable)� PercentStylez%(levelname)s: %(message)sz %(message)s)�*�INFO�DEBUGc�.��eZdZdZd�fd� Z�fd�Z�xZS)�LevelFormattera�Log formatter with level-specific formatting. Formatter class which optionally takes a dict of logging levels to format strings, allowing to customise the log records appearance for specific levels. Attributes: fmt: A dictionary mapping logging levels to format strings. The ``*`` key identifies the default format string. datefmt: As per py:class:`logging.Formatter` style: As per py:class:`logging.Formatter` >>> import sys >>> handler = logging.StreamHandler(sys.stdout) >>> formatter = LevelFormatter( ... fmt={ ... '*': '[%(levelname)s] %(message)s', ... 'DEBUG': '%(name)s [%(levelname)s] %(message)s', ... 'INFO': '%(message)s', ... }) >>> handler.setFormatter(formatter) >>> log = logging.getLogger('test') >>> log.setLevel(logging.DEBUG) >>> log.addHandler(handler) >>> log.debug('this uses a custom format string') test [DEBUG] this uses a custom format string >>> log.info('this also uses a custom format string') this also uses a custom format string >>> log.warning("this one uses the default format string") [WARNING] this one uses the default format string N�%c����|dkrtd���|�t}t|t��r|}i}nMt|t��r&t |��}|�dd��}ntd|z���tt|��� ||��|j |_ i|_ |���D]#\}}tj|��}||j |<�$dS)Nr z:only '%' percent style is supported in both python 2 and 3rz&fmt must be a str or a dict of str: %r)� ValueError�DEFAULT_FORMATS� isinstance�strr�dict�pop� TypeError�superr �__init__�_fmt�default_format�custom_formats�items�logging� _checkLevel)�self�fmt�datefmt�stylerr�level� __class__s ��k/home/asafur/pinokio/api/open-webui.git/app/env/lib/python3.11/site-packages/fontTools/misc/loggingTools.pyrzLevelFormatter.__init__8s��� �C�<�<��L��� � �;�!�C� �c�3� � � L� �N��N�N� ��W� %� %� L�!�#�Y�Y�N�+�/�/��T�:�:�N�N��D�s�J�K�K� K� �n�d�#�#�,�,�^�W�E�E�E�"�i��� ���(�.�.�0�0� -� -�J�E�3��'��.�.�E�),�D� �� &� &� -� -�c���|jrR|j�|j|j��}|j|kr"||_t rt |��|_tt|��� |��S�N) r�get�levelnorrr�_stylerr �format)r�recordrr#s �r$r+zLevelFormatter.formatNst��� � � 4��%�)�)�&�.�$�:M�N�N�C��y�C����� ��4�".�s�"3�"3�D�K��^�T�*�*�1�1�&�9�9�9r%)NNr )�__name__� __module__� __qualname__�__doc__rr+� __classcell__�r#s@r$r r sa���������B-�-�-�-�-�-�,:�:�:�:�:�:�:�:�:r%r c ���|�dd��}|�d|vrd|vrtd���nd|vsd|vrtd���|�q|�dd��}|�dd��}|rtj||��}n*|�dd��}tj|��}|g}|�d d ��}|rt |t ��rtj|��}t|j � ��|�d d��}|�d d��}|�dd��} t||| ��} |�dg��} |D]T}|j �|� | ��|j s| D]} |�| ���|�|���U|j dkr|�dd��|_|�dd��} | �|�| ��|r9d�|�����}td|z���dS)a� A more sophisticated logging system configuation manager. This is more or less the same as :py:func:`logging.basicConfig`, with some additional options and defaults. The default behaviour is to create a ``StreamHandler`` which writes to sys.stderr, set a formatter using the ``DEFAULT_FORMATS`` strings, and add the handler to the top-level library logger ("fontTools"). A number of optional keyword arguments may be specified, which can alter the default behaviour. Args: logger: Specifies the logger name or a Logger instance to be configured. (Defaults to "fontTools" logger). Unlike ``basicConfig``, this function can be called multiple times to reconfigure a logger. If the logger or any of its children already exists before the call is made, they will be reset before the new configuration is applied. filename: Specifies that a ``FileHandler`` be created, using the specified filename, rather than a ``StreamHandler``. filemode: Specifies the mode to open the file, if filename is specified. (If filemode is unspecified, it defaults to ``a``). format: Use the specified format string for the handler. This argument also accepts a dictionary of format strings keyed by level name, to allow customising the records appearance for specific levels. The special ``'*'`` key is for 'any other' level. datefmt: Use the specified date/time format. level: Set the logger level to the specified level. stream: Use the specified stream to initialize the StreamHandler. Note that this argument is incompatible with ``filename`` - if both are present, ``stream`` is ignored. handlers: If specified, this should be an iterable of already created handlers, which will be added to the logger. Any handler in the list which does not have a formatter assigned will be assigned the formatter created in this function. filters: If specified, this should be an iterable of already created filters. If the ``handlers`` do not already have filters assigned, these filters will be added to them. propagate: All loggers have a ``propagate`` attribute which determines whether to continue searching for handlers up the logging hierarchy. If not provided, the "propagate" attribute will be set to ``False``. �handlersN�stream�filenamez8'stream' and 'filename' should not be specified togetherzG'stream' or 'filename' should not be specified together with 'handlers'�filemode�a�logger� fontTools)�parentr+r r!r �filters�root� propagateFr"z, zUnrecognised argument(s): %s)rrr� FileHandler� StreamHandlerrr� getLogger�_resetExistingLoggers�namer � formatter� setFormatterr<� addFilter� addHandlerr>�setLevel�join�keys)�kwargsr4r6�mode�hr5r9�fs�dfsr!rr<�fr"rJs r$� configLoggerrQYs���Z�z�z�*�d�+�+�H��� �v� � �*��"6�"6��M��� �� �v� � ��v�!5�!5��5��� ����:�:�j�$�/�/���z�z�*�c�*�*�� � .��#�H�d�3�3�A�A��Z�Z��$�/�/�F��%�f�-�-�A��3�� �Z�Z��+� .� .�F� �+�Z���,�,�+��"�6�*�*�����-�-�-�-� ���H�d� #� #�B� �*�*�Y�� %� %�C� �J�J�w�� $� $�E� ��S�%� (� (�C��j�j��B�'�'�G� ���� �;� � �N�N�3� � � ��y� �� � ��� � �A��������!����� �{�f���!�:�:�k�5�9�9��� �J�J�w�� %� %�E� ��������� �@��y�y������'�'���7�$�>�?�?�?�@�@r%r=c��tj}t|jj�����}|dkr|g|z}n�||vrdS||vr~|g}|�|��dz}|dz}t|��}t|��}||kr:||d|�|kr|�||��|dz }||k�:|D]�}|dkru|� tj ��|j dd�D]} |� | ���|j dd�D]} |�| ���d|_�}|jj|} tj| _g| _ g| _ d| _d| _��dS)z�Reset the logger named 'parent' and all its children to their initial state, if they already exist in the current configuration. r=N��.FT)rr=�sorted�manager� loggerDictrJ�index�len�appendrH�WARNINGr4� removeHandlerr<� removeFilters�disabled�NOTSETr"r>) r;r=�existing�loggers_to_reset�i�prefixed�pflen� num_existingrCrMrPr9s r$rBrB�s��� �<�D��d�l�-�2�2�4�4�5�5�H� ����"�8�h�.��� �x� � ��� �8� � �"�8�� �N�N�6� "� "�Q� &���C�<���H� � ���8�}�}� ��,�����{�6�E�6�"�h�.�.� �'�'��� �4�4�4� ��F�A��,���!�$�$�� �6�>�>� �M�M�'�/� *� *� *��]�1�1�1�%� &� &���"�"�1�%�%�%�%��\�!�!�!�_� &� &���"�"�1�%�%�%�%�!�D�M�M��\�,�T�2�F�"�>�F�L� �F�O��F�N�#�F� �#�F�O�O�$�$r%c�p�eZdZdZejZdZdZdd�Z dd�Z d�Z d�Z d �Z d �Zd �Zdd �Zd �Zd�Zd�ZdS)�TimeraYKeeps track of overall time and split/lap times. >>> import time >>> timer = Timer() >>> time.sleep(0.01) >>> print("First lap:", timer.split()) First lap: ... >>> time.sleep(0.02) >>> print("Second lap:", timer.split()) Second lap: ... >>> print("Overall time:", timer.time()) Overall time: ... Can be used as a context manager inside with-statements. >>> with Timer() as t: ... time.sleep(0.01) >>> print("%0.3f seconds" % t.elapsed) 0... seconds If initialised with a logger, it can log the elapsed time automatically upon exiting the with-statement. >>> import logging >>> log = logging.getLogger("my-fancy-timer-logger") >>> configLogger(logger=log, level="DEBUG", format="%(message)s", stream=sys.stdout) >>> with Timer(log, 'do something'): ... time.sleep(0.01) Took ... to do something The same Timer instance, holding a reference to a logger, can be reused in multiple with-statements, optionally with different messages or levels. >>> timer = Timer(log) >>> with timer(): ... time.sleep(0.01) elapsed time: ...s >>> with timer('redo it', level=logging.INFO): ... time.sleep(0.02) Took ... to redo it It can also be used as a function decorator to log the time elapsed to run the decorated function. >>> @timer() ... def test1(): ... time.sleep(0.01) >>> @timer('run test 2', level=logging.INFO) ... def test2(): ... time.sleep(0.02) >>> test1() Took ... to run 'test1' >>> test2() Took ... to run test 2 zelapsed time: %(time).3fszTook %(time).3fs to %(msg)sNc���|�|��|�8dD]5}t���|���td|z����6||_|�|nt |_||_dS)N)�msgr"z*'%s' can't be specified without a 'logger')�reset�localsr(rr9� TIME_LEVELr"ri)rr9rir"�start�args r$rzTimer.__init__#s|�� � � �5���� �>�'� Y� Y���8�8�<�<��$�$�0�$�%Q�TW�%W�X�X�X�1��� �#�/�U�U�Z�� �����r%c�r�|�|���|_n||_|j|_d|_dS)z0Reset timer to 'start_time' or the current time.N�)�_timerm�last�elapsed)rrms r$rjz Timer.reset-s3�� �=������D�J�J��D�J��J�� ��� � � r%c�:�|���|jz S)z=Return the overall time (in seconds) since the timer started.)rqrm�rs r$�timez Timer.time6s���z�z�|�|�d�j�(�(r%c�d�|���}||jz |_||_|jS)z=Split and return the lap time (in seconds) in between splits.�rqrrrs)r�currents r$�splitz Timer.split:s,���*�*�,�,�����*�� ��� ��|�r%c��|s|j}|�d��dkr|j||d�z}n |d|iz}n#ttf$rYnwxYw|S)z�Format 'time' value in 'msg' and return formatted string. If 'msg' contains a '%(time)' format string, try to use that. Otherwise, use the predefined 'default_format'. If 'msg' is empty or None, fall back to 'default_msg'. z%(time)r�rirvrv)� default_msg�findr�KeyErrorr)rrirvs r$� formatTimezTimer.formatTimeAs��� � #��"�C� �8�8�I� � �� "� "��%��T�(B�(B�B�C�C� ��V�T�N�*�����j�)� � � ��� ����� s�:�A� Ac�F�|���|_d|_|S)zStart a new laprprxrus r$� __enter__zTimer.__enter__Rs���J�J�L�L�� ��� �� r%c���|���}|j�|rdS|�|j|��}|j|d�}|j�|j||��dS)z�End the current lap. If timer has a logger, log the time elapsed, using the format string in self.msg (or the default one). Nr|)rzr9r�ri�logr")r�exc_type� exc_value� tracebackrv�message� msg_partss r$�__exit__zTimer.__exit__Xsk���z�z�|�|�� �;� �(� � �F��/�/�$�(�D�1�1��!�H�d�3�3� � � ���� �G�Y�7�7�7�7�7r%c �6���t|t��r5|��jsd�jz�_t �����fd���}|S|p|�d��}|�d�j��}���j||��S)aVIf the first argument is a function, return a decorator which runs the wrapped function inside Timer's context manager. Otherwise, treat the first argument as a 'msg' string and return an updated Timer instance, referencing the same logger. A 'level' keyword can also be passed to override self.level. zrun '%s'c�L���5�|i|��cddd��S#1swxYwYdSr'�)�args�kwds�funcrs ��r$�wrapperzTimer.__call__.<locals>.wrapperts����/�/��4��.��.�.�/�/�/�/�/�/�/�/�/�/�/�/����/�/�/�/�/�/s ���rir") rrrir-rr(r"r#r9)r� func_or_msgrKr�rir"r�s` @r$�__call__zTimer.__call__gs����� �k�8� ,� ,� ;��D��8� 6�%�� �5��� �4�[�[� /� /� /� /� /��[� /��N��2����E�!2�!2�C��J�J�w�� �3�3�E��>�>�$�+�s�E�:�:� :r%c��|jSr'�rsrus r$� __float__zTimer.__float__s ���|�r%c�*�t|j��Sr')�intrsrus r$�__int__z Timer.__int__�s���4�<� � � r%c��d|jzS)Nz%.3fr�rus r$�__str__z Timer.__str__�s���� �$�$r%)NNNNr')r-r.r/r0�timeit� default_timerrqr}rrrjrvrzr�r�r�r�r�r�r�r�r%r$rgrg�s�������6�6�r � �E�-�K�2�N���������)�)�)�������"��� 8� 8� 8�;�;�;�;�0���!�!�!�%�%�%�%�%r%rgc��eZdZdZd�Zd�ZdS)�ChannelsFilteraQProvides a hierarchical filter for log entries based on channel names. Filters out records emitted from a list of enabled channel names, including their children. It works the same as the ``logging.Filter`` class, but allows the user to specify multiple channel names. >>> import sys >>> handler = logging.StreamHandler(sys.stdout) >>> handler.setFormatter(logging.Formatter("%(message)s")) >>> filter = ChannelsFilter("A.B", "C.D") >>> handler.addFilter(filter) >>> root = logging.getLogger() >>> root.addHandler(handler) >>> root.setLevel(level=logging.DEBUG) >>> logging.getLogger('A.B').debug('this record passes through') this record passes through >>> logging.getLogger('A.B.C').debug('records from children also pass') records from children also pass >>> logging.getLogger('C.D').debug('this one as well') this one as well >>> logging.getLogger('A.B.').debug('also this one') also this one >>> logging.getLogger('A.F').debug('but this one does not!') >>> logging.getLogger('C.DE').debug('neither this one!') c�^�||_t|��|_d�|D��|_dS)Nc�.�i|]}|t|����Sr�)rY)�.0�ns r$� <dictcomp>z+ChannelsFilter.__init__.<locals>.<dictcomp>�s ��1�1�1�a��3�q�6�6�1�1�1r%)�namesrY�num�lengths)rr�s r$rzChannelsFilter.__init__�s/���� ��u�:�:���1�1�5�1�1�1�� � � r%c���|jdkrdS|jD]Q}|j|}||jkrdS|j�|d|��dkr|j|dkrdS�RdS)NrTrTF)r�r�r�rCr~)rr,rC�nlens r$�filterzChannelsFilter.filter�s��� �8�q�=�=��4��J� � �D��<��%�D��v�{�"�"��t�t���!�!�$��4�0�0�A�5�5�&�+�d�:K�s�:R�:R��t�t���ur%N)r-r.r/r0rr�r�r%r$r�r��s<��������42�2�2� � � � � r%r�c�8��eZdZ�fd�Zd�Zd�Zd�Zdd�Z�xZS)�CapturingLogHandlerc����tt|���|���g|_t |t ��rt j|��|_dS||_dS)N)r") rr�r�recordsrrrrAr9)rr9r"r#s �r$rzCapturingLogHandler.__init__�s_��� �!�4�(�(�1�1��1�>�>�>��� � �f�c� "� "� !�!�+�F�3�3�D�K�K�K� �D�K�K�Kr%c��|jj|_|jj|_|jj|_|j�|��|j�|j��d|j_d|j_|S)NF) r9r^�original_disabledr"�original_levelr>�original_propagaterGrHrus r$r�zCapturingLogHandler.__enter__�sp��!%��!5���"�k�/���"&�+�"7��� � ���t�$�$�$� � ���T�Z�(�(�(�$�� �� %�� ��� r%c��|j�|��|j�|j��|j|j_|j|j_|Sr')r9r\rHr�r�r^r�r>)r�type�valuer�s r$r�zCapturingLogHandler.__exit__�sP�� � �!�!�$�'�'�'� � ���T�0�1�1�1�#�5�� �� $� 7�� ��� r%c�:�|j�|��dSr')r�rZ)rr,s r$�emitzCapturingLogHandler.emit�s�� � ���F�#�#�#�#�#r%Nc��ddl}|�|��}|jD],}|�|�����rdS�-|�d|z}J|���)NrTz(Pattern '%s' not found in logger records)�re�compiler��search� getMessage)r�regexprir��pattern�rs r$� assertRegexzCapturingLogHandler.assertRegex�so��� � � ��*�*�V�$�$���� � �A��~�~�a�l�l�n�n�-�-� ��t�t� � �;�<�v�E�C��#� � �qr%r') r-r.r/rr�r�r�r�r1r2s@r$r�r��sy�������!�!�!�!�!� � � ����$�$�$� � � � � � � � r%r�c�(�eZdZdZed���ZdS)�LogMixina2Mixin class that adds logging functionality to another class. You can define a new class that subclasses from ``LogMixin`` as well as other base classes through multiple inheritance. All instances of that class will have a ``log`` property that returns a ``logging.Logger`` named after their respective ``<module>.<class>``. For example: >>> class BaseClass(object): ... pass >>> class MyClass(LogMixin, BaseClass): ... pass >>> a = MyClass() >>> isinstance(a.log, logging.Logger) True >>> print(a.log.name) fontTools.misc.loggingTools.MyClass >>> class AnotherClass(MyClass): ... pass >>> b = AnotherClass() >>> isinstance(b.log, logging.Logger) True >>> print(b.log.name) fontTools.misc.loggingTools.AnotherClass c��t|d��sDd�|jj|jjf��}t j|��|_|jS)N�_logrT)�hasattrrIr#r.r-rrAr�)rrCs r$r�z LogMixin.log�sN���t�V�$�$� 0��8�8�T�^�6���8O�P�Q�Q�D��)�$�/�/�D�I��y�r%N)r-r.r/r0�propertyr�r�r%r$r�r��s9��������6����X���r%r�c�>�tj|�d|��|d���dS)z:Raise a warning about deprecated function argument 'name'.� is deprecated; ���category� stacklevelN)�warnings�warn)rCrir�s r$�deprecateArgumentr�s+�� �M�D�D�D�#�#�6��VW�X�X�X�X�X�Xr%c������fd�}|S)zBDecorator to raise a warning when a deprecated function is called.c�B���t������fd���}|S)Nc�V��tj�j�d����d����|i|��S)Nr��r�)r�r�r-)r�rKr�r�ris ���r$r�z5deprecateFunction.<locals>.decorator.<locals>.wrappersI��� �M�*.�-�-�-���=�!�� � � � � �4��(��(�(� (r%r)r�r�r�ris` ��r$� decoratorz$deprecateFunction.<locals>.decorator s>���� �t��� )� )� )� )� )� )� �� )��r%r�)rir�r�s`` r$�deprecateFunctionr� s*���� � � � � � � �r%�__main__)� optionflags)r=)!�sysrr�� functoolsr�collections.abcrrr�rr rlr� Formatterr rQrB�objectrg�Filterr��Handlerr�r�� UserWarningr�r�r-�doctest�exit�testmod�ELLIPSIS�failedr�r%r$�<module>r�s�� � � � ����� � � � �������-�-�-�-�-�-�-�-����� � � � � � ��]� � &� � ����@:�@:�@:�@:�@:�W�&�@:�@:�@:�F`@�`@�`@�F&$�&$�&$�&$�Ra%�a%�a%�a%�a%�F�a%�a%�a%�H)�)�)�)�)�W�^�)�)�)�X)�)�)�)�)�'�/�)�)�)�X!�!�!�!�!�v�!�!�!�H+6�Y�Y�Y�Y� %0�����$ �z����N�N�N� �C�H�_�W�_��)9� :� :� :� A�B�B�B�B�B��r%
Memory