Hacked By AnonymousFox

Current Path : /opt/cloudlinux/venv/lib/python3.11/site-packages/coverage/__pycache__/
Upload File :
Current File : //opt/cloudlinux/venv/lib/python3.11/site-packages/coverage/__pycache__/plugin.cpython-311.pyc

�

�܋fEL���dZddlmZddlZddlmZddlmZmZm	Z	m
Z
mZmZm
Z
ddlmZddlmZddlmZmZmZmZGd	�d
��ZGd�d��ZGd
�de��ZejGd�de����ZdS)af
.. versionadded:: 4.0

Plug-in interfaces for coverage.py.

Coverage.py supports a few different kinds of plug-ins that change its
behavior:

* File tracers implement tracing of non-Python file types.

* Configurers add custom configuration, using Python code to change the
  configuration.

* Dynamic context switchers decide when the dynamic context has changed, for
  example, to record what test function produced the coverage.

To write a coverage.py plug-in, create a module with a subclass of
:class:`~coverage.CoveragePlugin`.  You will override methods in your class to
participate in various aspects of coverage.py's processing.
Different types of plug-ins have to override different methods.

Any plug-in can optionally implement :meth:`~coverage.CoveragePlugin.sys_info`
to provide debugging information about their operation.

Your module must also contain a ``coverage_init`` function that registers an
instance of your plug-in class::

    import coverage

    class MyPlugin(coverage.CoveragePlugin):
        ...

    def coverage_init(reg, options):
        reg.add_file_tracer(MyPlugin())

You use the `reg` parameter passed to your ``coverage_init`` function to
register your plug-in object.  The registration method you call depends on
what kind of plug-in it is.

If your plug-in takes options, the `options` parameter is a dictionary of your
plug-in's options from the coverage.py configuration file.  Use them however
you want to configure your object before registering it.

Coverage.py will store its own information on your plug-in object, using
attributes whose names start with ``_coverage_``.  Don't be startled.

.. warning::
    Plug-ins are imported by coverage.py before it begins measuring code.
    If you write a plugin in your own project, it might import your product
    code before coverage.py can start measuring.  This can result in your
    own code being reported as missing.

    One solution is to put your plugins in your project tree, but not in
    your importable Python package.


.. _file_tracer_plugins:

File Tracers
============

File tracers implement measurement support for non-Python files.  File tracers
implement the :meth:`~coverage.CoveragePlugin.file_tracer` method to claim
files and the :meth:`~coverage.CoveragePlugin.file_reporter` method to report
on those files.

In your ``coverage_init`` function, use the ``add_file_tracer`` method to
register your file tracer.


.. _configurer_plugins:

Configurers
===========

.. versionadded:: 4.5

Configurers modify the configuration of coverage.py during start-up.
Configurers implement the :meth:`~coverage.CoveragePlugin.configure` method to
change the configuration.

In your ``coverage_init`` function, use the ``add_configurer`` method to
register your configurer.


.. _dynamic_context_plugins:

Dynamic Context Switchers
=========================

.. versionadded:: 5.0

Dynamic context switcher plugins implement the
:meth:`~coverage.CoveragePlugin.dynamic_context` method to dynamically compute
the context label for each measured frame.

Computed context labels are useful when you want to group measured data without
modifying the source code.

For example, you could write a plugin that checks `frame.f_code` to inspect
the currently executed method, and set the context label to a fully qualified
method name if it's an instance method of `unittest.TestCase` and the method
name starts with 'test'.  Such a plugin would provide basic coverage grouping
by test and could be used with test runners that have no built-in coveragepy
support.

In your ``coverage_init`` function, use the ``add_dynamic_context`` method to
register your dynamic context switcher.

�)�annotationsN)�	FrameType)�Any�Dict�Iterable�Optional�Set�Tuple�Union)�files��_needs_to_implement)�TArc�
TConfigurable�TLineNo�TSourceTokenLinesc�X�eZdZUdZded<ded<dd	�Zdd�Zdd�Zdd�Zdd�Z	dd�Z
dS) �CoveragePluginz$Base class for coverage.py plug-ins.�str�_coverage_plugin_name�bool�_coverage_enabled�filename�return�Optional[FileTracer]c��dS)a�Get a :class:`FileTracer` object for a file.

        Plug-in type: file tracer.

        Every Python source file is offered to your plug-in to give it a chance
        to take responsibility for tracing the file.  If your plug-in can
        handle the file, it should return a :class:`FileTracer` object.
        Otherwise return None.

        There is no way to register your plug-in for particular files.
        Instead, this method is invoked for all  files as they are executed,
        and the plug-in decides whether it can trace the file or not.
        Be prepared for `filename` to refer to all kinds of files that have
        nothing to do with your plug-in.

        The file name will be a Python file being executed.  There are two
        broad categories of behavior for a plug-in, depending on the kind of
        files your plug-in supports:

        * Static file names: each of your original source files has been
          converted into a distinct Python file.  Your plug-in is invoked with
          the Python file name, and it maps it back to its original source
          file.

        * Dynamic file names: all of your source files are executed by the same
          Python file.  In this case, your plug-in implements
          :meth:`FileTracer.dynamic_source_filename` to provide the actual
          source file for each execution frame.

        `filename` is a string, the path to the file being considered.  This is
        the absolute real path to the file.  If you are comparing to other
        paths, be sure to take this into account.

        Returns a :class:`FileTracer` object to use to trace `filename`, or
        None if this plug-in cannot trace this file.

        N���selfrs  �b/builddir/build/BUILD/cloudlinux-venv-1.0.6/venv/lib64/python3.11/site-packages/coverage/plugin.py�file_tracerzCoveragePlugin.file_tracer�s
��L�t��Union[FileReporter, str]c�&�t|d��dS)a�Get the :class:`FileReporter` class to use for a file.

        Plug-in type: file tracer.

        This will only be invoked if `filename` returns non-None from
        :meth:`file_tracer`.  It's an error to return None from this method.

        Returns a :class:`FileReporter` object to use to report on `filename`,
        or the string `"python"` to have coverage.py treat the file as Python.

        �
file_reporterNr
rs  r r%zCoveragePlugin.file_reporter�s��	�D�/�2�2�2�2�2r"�framer�
Optional[str]c��dS)a�Get the dynamically computed context label for `frame`.

        Plug-in type: dynamic context.

        This method is invoked for each frame when outside of a dynamic
        context, to see if a new dynamic context should be started.  If it
        returns a string, a new context label is set for this and deeper
        frames.  The dynamic context ends when this frame returns.

        Returns a string to start a new dynamic context, or None if no new
        context should be started.

        Nr)rr&s  r �dynamic_contextzCoveragePlugin.dynamic_context��	��"�tr"�src_dir�
Iterable[str]c��gS)a�Yield all of the executable files in `src_dir`, recursively.

        Plug-in type: file tracer.

        Executability is a plug-in-specific property, but generally means files
        which would have been considered for coverage analysis, had they been
        included automatically.

        Returns or yields a sequence of strings, the paths to files that could
        have been executed, including files that had been executed.

        r)rr+s  r �find_executable_filesz$CoveragePlugin.find_executable_files�s	�� �	r"�configr�Nonec��dS)a�Modify the configuration of coverage.py.

        Plug-in type: configurer.

        This method is called during coverage.py start-up, to give your plug-in
        a chance to change the configuration.  The `config` parameter is an
        object with :meth:`~coverage.Coverage.get_option` and
        :meth:`~coverage.Coverage.set_option` methods.  Do not call any other
        methods on the `config` object.

        Nr)rr/s  r �	configurezCoveragePlugin.configure�s	��	
�r"�Iterable[Tuple[str, Any]]c��gS)aGet a list of information useful for debugging.

        Plug-in type: any.

        This method will be invoked for ``--debug=sys``.  Your
        plug-in can return any information it wants to be displayed.

        Returns a list of pairs: `[(name, value), ...]`.

        r�rs r �sys_infozCoveragePlugin.sys_info��	���	r"N)rrrr)rrrr#)r&rrr')r+rrr,)r/rrr0)rr3)�__name__�
__module__�__qualname__�__doc__�__annotations__r!r%r)r.r2r6rr"r rrs��������.�.���������&�&�&�&�P3�3�3�3�"����&����$
�
�
�
������r"rc��eZdZUdZded<dS)�CoveragePluginBasezMPlugins produce specialized objects, which point back to the original plugin.r�_coverage_pluginN)r8r9r:r;r<rr"r r>r>�s$�������W�W�$�$�$�$�$�$r"r>c�2�eZdZdZdd�Zdd�Zdd�Zdd
�ZdS)�
FileTraceraSupport needed for files during the execution phase.

    File tracer plug-ins implement subclasses of FileTracer to return from
    their :meth:`~CoveragePlugin.file_tracer` method.

    You may construct this object from :meth:`CoveragePlugin.file_tracer` any
    way you like.  A natural choice would be to pass the file name given to
    `file_tracer`.

    `FileTracer` objects should only be created in the
    :meth:`CoveragePlugin.file_tracer` method.

    See :ref:`howitworks` for details of the different coverage.py phases.

    rrc�&�t|d��dS)a�The source file name for this file.

        This may be any file name you like.  A key responsibility of a plug-in
        is to own the mapping from Python execution back to whatever source
        file name was originally the source of the code.

        See :meth:`CoveragePlugin.file_tracer` for details about static and
        dynamic file names.

        Returns the file name to credit with this execution.

        �source_filenameNr
r5s r rCzFileTracer.source_filenames��	�D�"3�4�4�4�4�4r"rc��dS)amDoes this FileTracer have dynamic source file names?

        FileTracers can provide dynamically determined file names by
        implementing :meth:`dynamic_source_filename`.  Invoking that function
        is expensive. To determine whether to invoke it, coverage.py uses the
        result of this function to know if it needs to bother invoking
        :meth:`dynamic_source_filename`.

        See :meth:`CoveragePlugin.file_tracer` for details about static and
        dynamic file names.

        Returns True if :meth:`dynamic_source_filename` should be called to get
        dynamic source file names.

        Frr5s r �has_dynamic_source_filenamez&FileTracer.has_dynamic_source_filename$s	�� �ur"rr&rr'c��dS)ajGet a dynamically computed source file name.

        Some plug-ins need to compute the source file name dynamically for each
        frame.

        This function will not be invoked if
        :meth:`has_dynamic_source_filename` returns False.

        Returns the source file name for this frame, or None if this frame
        shouldn't be measured.

        Nr)rrr&s   r �dynamic_source_filenamez"FileTracer.dynamic_source_filename6r*r"�Tuple[TLineNo, TLineNo]c��|j}||fS)awGet the range of source line numbers for a given a call frame.

        The call frame is examined, and the source line number in the original
        file is returned.  The return value is a pair of numbers, the starting
        line number and the ending line number, both inclusive.  For example,
        returning (5, 7) means that lines 5, 6, and 7 should be considered
        executed.

        This function might decide that the frame doesn't indicate any lines
        from the source file were executed.  Return (-1, -1) in this case to
        tell coverage.py that no lines should be recorded for this frame.

        )�f_lineno)rr&�linenos   r �line_number_rangezFileTracer.line_number_rangeIs������v�~�r"N�rr)rr)rrr&rrr')r&rrrH)r8r9r:r;rCrErGrLrr"r rArAsn�������� 
5�
5�
5�
5�����$����&�����r"rAc��eZdZdZd&d�Zd'd�Zd'd�Zd'd	�Zd(d�Zd(d�Z	d)d�Z
d*d�Zd(d�Zd+d�Z
d,d�Z	d-d.d�Zd/d �Zd0d$�Zd0d%�ZdZdS)1�FileReportera�Support needed for files during the analysis and reporting phases.

    File tracer plug-ins implement a subclass of `FileReporter`, and return
    instances from their :meth:`CoveragePlugin.file_reporter` method.

    There are many methods here, but only :meth:`lines` is required, to provide
    the set of executable lines in the file.

    See :ref:`howitworks` for details of the different coverage.py phases.

    rrrr0c��||_dS)aSimple initialization of a `FileReporter`.

        The `filename` argument is the path to the file being reported.  This
        will be available as the `.filename` attribute on the object.  Other
        method implementations on this base class rely on this attribute.

        N)rrs  r �__init__zFileReporter.__init__is��!��
�
�
r"c�,�d�|��S)Nz0<{0.__class__.__name__} filename={0.filename!r}>)�formatr5s r �__repr__zFileReporter.__repr__ss��A�H�H��N�N�Nr"c�4�tj|j��S)a#Get the relative file name for this file.

        This file path will be displayed in reports.  The default
        implementation will supply the actual project-relative file path.  You
        only need to supply this method if you have an unusual syntax for file
        paths.

        )r�relative_filenamerr5s r rVzFileReporter.relative_filenamevs���&�t�}�5�5�5r"c��t|jd���5}|���cddd��S#1swxYwYdS)a"Get the source for the file.

        Returns a Unicode string.

        The base implementation simply reads the `self.filename` file and
        decodes it as UTF-8.  Override this method if your file isn't readable
        as a text file, or if you need other encoding support.

        zutf-8)�encodingN)�openr�read)r�fs  r �sourcezFileReporter.source�s����$�-�'�
2�
2�
2�	�a��6�6�8�8�	�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	�	�	s�8�<�<�Set[TLineNo]c�&�t|d��dS)z�Get the executable lines in this file.

        Your plug-in must determine which lines in the file were possibly
        executable.  This method returns a set of those line numbers.

        Returns a set of line numbers.

        �linesNr
r5s r r_zFileReporter.lines�s��	�D�'�*�*�*�*�*r"c��t��S)aGet the excluded executable lines in this file.

        Your plug-in can use any method it likes to allow the user to exclude
        executable lines from consideration.

        Returns a set of line numbers.

        The base implementation returns the empty set.

        ��setr5s r �excluded_lineszFileReporter.excluded_lines��
���u�u�r"r_�Iterable[TLineNo]c� �t|��S)aYTranslate recorded lines into reported lines.

        Some file formats will want to report lines slightly differently than
        they are recorded.  For example, Python records the last line of a
        multi-line statement, but reports are nicer if they mention the first
        line.

        Your plug-in can optionally define this method to perform these kinds
        of adjustment.

        `lines` is a sequence of integers, the recorded line numbers.

        Returns a set of integers, the adjusted line numbers.

        The base implementation returns the numbers unchanged.

        ra)rr_s  r �translate_lineszFileReporter.translate_lines�s��$�5�z�z�r"�	Set[TArc]c��t��S)a�Get the executable arcs in this file.

        To support branch coverage, your plug-in needs to be able to indicate
        possible execution paths, as a set of line number pairs.  Each pair is
        a `(prev, next)` pair indicating that execution can transition from the
        `prev` line number to the `next` line number.

        Returns a set of pairs of line numbers.  The default implementation
        returns an empty set.

        rar5s r �arcszFileReporter.arcs�s
���u�u�r"c��t��S)a&Get the lines excused from branch coverage in this file.

        Your plug-in can use any method it likes to allow the user to exclude
        lines from consideration of branch coverage.

        Returns a set of line numbers.

        The base implementation returns the empty set.

        rar5s r �no_branch_lineszFileReporter.no_branch_lines�rdr"rj�Iterable[TArc]c� �t|��S)a
Translate recorded arcs into reported arcs.

        Similar to :meth:`translate_lines`, but for arcs.  `arcs` is a set of
        line number pairs.

        Returns a set of line number pairs.

        The default implementation returns `arcs` unchanged.

        ra)rrjs  r �translate_arcszFileReporter.translate_arcs�s���4�y�y�r"�Dict[TLineNo, int]c��iS)a�Get a count of exits from that each line.

        To determine which lines are branches, coverage.py looks for lines that
        have more than one exit.  This function creates a dict mapping each
        executable line number to a count of how many exits it has.

        To be honest, this feels wrong, and should be refactored.  Let me know
        if you attempt to implement this method in your plug-in...

        rr5s r �exit_countszFileReporter.exit_counts�r7r"N�startr�end�
executed_arcs�Optional[Iterable[TArc]]c��d|�d|��S)a�Provide an English sentence describing a missing arc.

        The `start` and `end` arguments are the line numbers of the missing
        arc. Negative numbers indicate entering or exiting code objects.

        The `executed_arcs` argument is a set of line number pairs, the arcs
        that were executed in this file.

        By default, this simply returns the string "Line {start} didn't jump
        to {end}".

        zLine z didn't jump to line r)rrsrtrus    r �missing_arc_descriptionz$FileReporter.missing_arc_description�s��$9�u�8�8�3�8�8�8r"rc#�jK�|������D]	}d|fgV��
dS)aqGenerate a series of tokenized lines, one for each line in `source`.

        These tokens are used for syntax-colored reports.

        Each line is a list of pairs, each pair is a token::

            [("key", "def"), ("ws", " "), ("nam", "hello"), ("op", "("), ... ]

        Each pair has a token class, and the token text.  The token classes
        are:

        * ``"com"``: a comment
        * ``"key"``: a keyword
        * ``"nam"``: a name, or identifier
        * ``"num"``: a number
        * ``"op"``: an operator
        * ``"str"``: a string literal
        * ``"ws"``: some white space
        * ``"txt"``: some other kind of text

        If you concatenate all the token texts, and then join them with
        newlines, you should have your original source back.

        The default implementation simply returns each line tagged as
        ``"txt"``.

        �txtN)r\�
splitlines)r�lines  r �source_token_lineszFileReporter.source_token_linessJ����8�K�K�M�M�,�,�.�.�	"�	"�D��4�=�/�!�!�!�!�	"�	"r"�otherrrc�L�t|t��o|j|jkS�N��
isinstancerOr�rr~s  r �__eq__zFileReporter.__eq__"s ���%��.�.�R�4�=�E�N�3R�Rr"c�L�t|t��o|j|jkSr�r�r�s  r �__lt__zFileReporter.__lt__%s ���%��.�.�Q�4�=�5�>�3Q�Qr")rrrr0rM)rr])r_rerr])rrh)rjrmrrh)rrpr�)rsrrtrrurvrr)rr)r~rrr)r8r9r:r;rQrTrVr\r_rcrgrjrlrorrrxr}r�r��__hash__rr"r rOrO[sa������
�
�!�!�!�!�O�O�O�O�	6�	6�	6�	6�����	+�	+�	+�	+���������(����������������"37�	9�9�9�9�9�("�"�"�"�>S�S�S�S�R�R�R�R��H�H�Hr"rO)r;�
__future__r�	functools�typesr�typingrrrrr	r
r�coverager�
coverage.miscr�coverage.typesrrrrrr>rA�total_orderingrOrr"r �<module>r�s���m�m�^#�"�"�"�"�"�����������C�C�C�C�C�C�C�C�C�C�C�C�C�C�C�C�C�C�������-�-�-�-�-�-�J�J�J�J�J�J�J�J�J�J�J�J�}�}�}�}�}�}�}�}�@%�%�%�%�%�%�%�%�
T�T�T�T�T�#�T�T�T�n��M�M�M�M�M�%�M�M���M�M�Mr"

Hacked By AnonymousFox1.0, Coded By AnonymousFox