HOME


Mini Shell 1.0
Redirecting to https://devs.lapieza.net/iniciar-sesion Redirecting to https://devs.lapieza.net/iniciar-sesion.
DIR: /lib/python3/dist-packages/debianbts/__pycache__/
Upload File :
Current File : //lib/python3/dist-packages/debianbts/__pycache__/debianbts.cpython-311.pyc
�

�ˑc$F���dZddlmZddlZddlZddlZddlmZddlZddl	Z	ddl
mZmZddl
mZddlmZe	je��ZdZej�e��r
eejd	<d
ZdZdZd
Zdddddddd�ZGd�d��ZdLd�Z	dMdNd"�ZdOd&�Z dPd)�Z!dQd,�Z"dRd/�Z#ed0ed1d2�Z$dSd5�Z%dTd7�Z&dUd9�Z'dVd;�Z(dWd?�Z)dXdB�Z*dYdG�Z+dZdJ�Z,d[dK�Z-dS)\z�
Query Debian's Bug Tracking System (BTS).

This module provides a layer between Python and Debian's BTS. It provides
methods to query the BTS using the BTS' SOAP interface, and the Bugreport class
which represents a bugreport from the BTS.
�)�annotationsN)�datetime)�Any�Iterable)�
SoapClient)�SimpleXMLElementz/etc/ssl/ca-debian�SSL_CERT_DIRz(https://bugs.debian.org/cgi-bin/soap.cgizDebbugs/SOAP/V1zhttps://bugs.debian.org/i��������)�critical�grave�serious�	important�normal�minor�wishlistc�Z�eZdZdZdd�Zdd�Zdd	�Zdd
�Zdd�Zdd�Z	dd�Z
dd�Zdd�ZdS)�	Bugreporta�Represents a bugreport from Debian's Bug Tracking System.

    A bugreport object provides all attributes provided by the SOAP interface.
    Most of the attributes are strings, the others are marked.

    Attributes
    ----------
    bug_num : int
        The bugnumber
    severity : str
        Severity of the bugreport
    tags : list[str]
        Tags of the bugreport
    subject : str
        The subject/title of the bugreport
    originator : str
        Submitter of the bugreport
    mergedwith : list[int]
        List of bugnumbers this bug was merged with
    package : str
        Package of the bugreport
    source : str
        Source package of the bugreport
    date : datetime
        Date of bug creation
    log_modified : datetime
        Date of update of the bugreport
    done : boolean
        Is the bug fixed or not
    done_by : str | None
        Name and Email or None
    archived : bool
        Is the bug archived or not
    unarchived : bool
        Was the bug unarchived or not
    fixed_versions : list[str]
        List of versions, can be empty even if bug is fixed
    found_versions : list[str]
        List of version numbers where bug was found
    forwarded : str
        A URL or email address
    blocks: list[int]
        List of bugnumbers this bug blocks
    blockedby : list[int]
        List of bugnumbers which block this bug
    pending : str
        Either 'pending' or 'done'
    msgid : str
        Message ID of the bugreport
    owner : str
        Who took responsibility for fixing this bug
    location : str
        Either 'db-h' or 'archive'
    affects : list[str]
        List of Packagenames
    summary : str
        Arbitrary text
    �return�Nonec�j�|||||||||||||||||||||||||dS�N�)�selfs �5/usr/lib/python3/dist-packages/debianbts/debianbts.py�__init__zBugreport.__init__rs������������������ ����"������&��&����!��������#��������������strc�x�d�d�|j���D����}|dzS)N�
c3�*K�|]\}}|�d|��V��dS)z: Nr)�.0�key�values   r �	<genexpr>z$Bugreport.__str__.<locals>.<genexpr>�sE����
�
�",�#�u�s���e���
�
�
�
�
�
r")�join�__dict__�items)r�ss  r �__str__zBugreport.__str__�sJ���I�I�
�
�04�
�0C�0C�0E�0E�
�
�
�
�
���4�x�r"�other�boolc�V�|���|���kS)a�Compare a bugreport with another.

        The more open and urgent a bug is, the greater the bug is:

            outstanding > resolved > archived

            critical > grave > serious > important > normal > minor > wishlist.

        Openness always beats urgency, eg an archived bug is *always* smaller
        than an outstanding bug.

        This sorting is useful for displaying bugreports in a list and sorting
        them in a useful way.

        ��
_get_value�rr0s  r �__lt__zBugreport.__lt__�s%�� ��� � �5�#3�#3�#5�#5�5�5r"c�.�|�|��Sr)�__gt__r5s  r �__le__zBugreport.__le__�����;�;�u�%�%�%�%r"c�V�|���|���kSrr3r5s  r r8zBugreport.__gt__�s#����� � �5�#3�#3�#5�#5�5�5r"c�.�|�|��Sr)r6r5s  r �__ge__zBugreport.__ge__�r:r"�objectc��t|t��stS|���|���kSr)�
isinstancer�NotImplementedr4r5s  r �__eq__zBugreport.__eq__�s;���%��+�+�	"�!�!���� � �E�$4�$4�$6�$6�6�6r"c�f�t|t��stS|�|��Sr)r@rrArBr5s  r �__ne__zBugreport.__ne__�s/���%��+�+�	"�!�!��;�;�u�%�%�%�%r"�intc�\�|jrd}n|jrd}nd}|t|jz
}|S)Nr�
�)�archived�done�
SEVERITIES�severity)r�vals  r r4zBugreport._get_value�sA���=�	��C�C�
�Y�	��C�C��C��z�$�-�(�(���
r"N)rr)rr#)r0rrr1)r0r>rr1)rrE)
�__name__�
__module__�__qualname__�__doc__r!r/r6r9r8r=rBrDr4rr"r rr6s�������9�9�v����D����6�6�6�6�$&�&�&�&�6�6�6�6�&�&�&�&�7�7�7�7�
&�&�&�&�
�����r"r�nrs�!int | list[int] | tuple[int, ...]r�list[Bugreport]c��t|ttf��s|g}nt|��}t��}g}t	dt|��t��D]�}|||tz�}td��}td||��|�	d|��}|d���
��pgD]>}|�
��d}	|�t|	�����?��|S)a
Returns a list of Bugreport objects.

    Given a list of bug numbers this method returns a list of Bugreport
    objects.

    Parameters
    ----------
    nrs
        The bugnumbers

    Returns
    -------
    list[Bugreport]
        list of Bugreport objects

    rz<get_status></get_status>�arg0�
get_status�	s-gensym3r)
r@�list�tuple�_build_soap_client�range�len�
BATCH_SIZEr�_build_int_array_el�call�children�append�
_parse_status)
rR�numbers�soap_client�bugs�i�slice_�	method_el�reply�bug_item_el�bug_els
          r rWrW�s��(�c�D�%�=�)�)���%����s�)�)��%�&�&�K�
�D�
�1�c�'�l�l�J�
/�
/�	/�	/����1�z�>�)�*��%�%@�A�A�	��F�I�v�6�6�6�� � ��y�9�9�� �5��-�-�6�6�8�8�>�B�	/�	/�K� �)�)�+�+�A�.�F��K�K�
�f�-�-�.�.�.�.�	/��Kr"�emailr#�tags�"None | list[str] | tuple[str, ...]�dict[str, list[int]]c��|�g}td|g|�R�}|d��}i}|����d��}|rk|jdkr`|���pgD]H}t|d����}|d��}d�|���pgD��||<�InP|���pgD]9}|���}d	�|���pgD��||<�:|S)
a3Get buglists by usertags.

    Parameters
    ----------
    email
    tags
        If tags are given the dictionary is limited to the matching tags, if no
        tags are given all available tags are returned.

    Returns
    -------
    dict[str, list[int]]
        a mapping of usertag -> buglist

    N�get_usertagrX�xsi:typezapachens:Mapr(r)c�,�g|]}t|����Sr�rE�r'�bugs  r �
<listcomp>zget_usertag.<locals>.<listcomp>���L�L�L��C��H�H�L�L�Lr"c�,�g|]}t|����Srrurvs  r rxzget_usertag.<locals>.<listcomp>ryr")�_soap_client_call�
attributes�getr)rar#�get_name)	rmrnrj�map_el�mapping�	type_attr�
usertag_el�tag�
buglist_els	         r rrrr�sG��&�|����m�U�:�T�:�:�:�E�
�U�;�
�
�F��G�
�!�!�#�#�'�'�
�3�3�I��M�Y�_��6�6� �/�/�+�+�1�r�	M�	M�J��j�j��'�'�(�(�C�#��G�,�,�J�L�L�
�0C�0C�0E�0E�0K��L�L�L�G�C�L�L�	M�
!�/�/�+�+�1�r�	M�	M�J��%�%�'�'�C�L�L�
�0C�0C�0E�0E�0K��L�L�L�G�C�L�L��Nr"�nrrE�>list[dict[str, str | list[Any] | int | email.message.Message]]c��td|��}|d��}g}|���D�]}i}t|d����}t|d����}t|d����}g}	tj�tjj���}
|
�	|�
����|
�	d��|
�	|�
����|
���}||||	|d�}|�|����|S)	a�Get Buglogs.

    A buglog is a dictionary with the following mappings:
        * "header" => string
        * "body" => string
        * "attachments" => list
        * "msg_num" => int
        * "message" => email.message.Message

    Parameters
    ----------
    nr
        the bugnumber

    Returns
    -------
    list[dict[str, str | list[Any] | int | email.message.Message]]
        list of buglogs

    �get_bug_log�
soapenc:Array�header�body�msg_num)�policys

)r�r�r��attachments�message)
r{ra�_parse_string_elrErm�
feedparser�BytesFeedParserr��SMTP�feed�encode�closerb)r�rj�items_el�buglogs�	buglog_el�buglogr�r�r�r��mail_parserr�s            r r�r�!sN��.
�m�R�0�0�E��u�_�%�%�H��G��&�&�(�(���	�KM��!�)�)�H�"5�"5�6�6���	�	�&� 1� 1�2�2���i�i�	�*�*�+�+��!#���&�6�6��<�$�7�
�
��	��������)�)�)�����!�!�!���������'�'�'��#�#�%�%�����&��
�
��	���v������Nr"�amount�	list[int]c�x�td|��}|d��}d�|���pgD��S)a9Returns the newest bugs.

    This method can be used to query the BTS for the n newest bugs.

    Parameters
    ----------
    amount
        the number of desired bugs. E.g. if `amount` is 10 the method will
        return the 10 latest bugs.

    Returns
    -------
    list[int]
        the bugnumbers

    �newest_bugsr�c�,�g|]}t|����Srru�r'�item_els  r rxznewest_bugs.<locals>.<listcomp>j���B�B�B�W�C��L�L�B�B�Br")r{ra)r�rjr�s   r r�r�WsG��"
�m�V�4�4�E��u�_�%�%�H�B�B��(9�(9�(;�(;�(A�r�B�B�B�Br"�kwargs�str | int | list[int]c��g}|���D]\}}|�||g���td��}t|��D][\}}dt	|��z}t|ttf��rt|||���E|�	||���\t��}|�d|��}	|	d��}
d�|
���pgD��S)a�Get list of bugs matching certain criteria.

    The conditions are defined by the keyword arguments.

    Arguments
    ---------
    kwargs
        Possible keywords are:
            * "package": bugs for the given package
            * "submitter": bugs from the submitter
            * "maint": bugs belonging to a maintainer
            * "src": bugs belonging to a source package
            * "severity": bugs with a certain severity
            * "status": can be either "done", "forwarded", or "open"
            * "tag": see http://www.debian.org/Bugs/Developer#tags for
              available tags
            * "owner": bugs which are assigned to `owner`
            * "bugs": takes single int or list of bugnumbers, filters the list
              according to given criteria
            * "correspondent": bugs where `correspondent` has sent a mail to
            * "archive": takes a string: "0" (unarchived), "1" (archived) or
              "both" (un- and archived). if omitted, only returns un-archived
              bugs.

    Returns
    -------
    list[int]
        the bugnumbers

    Examples
    --------
        >>> get_bugs(package='gtk-qt-engine', severity='normal')
        [12345, 23456]

    z<get_bugs></get_bugs>�arg�get_bugsr�c�,�g|]}t|����Srrur�s  r rxzget_bugs.<locals>.<listcomp>�r�r")
r-�extendr�	enumerater#r@rYrZr_�marshallr[r`ra)r��args�k�vri�arg_n�kv�arg_namererjr�s           r r�r�ms��P�D����������1����Q��F�����
!�!8�9�9�I��t�_�_�-�-�	��r��3�u�:�:�%���b�4��-�(�(�	-���)�R�8�8�8�8����x��,�,�,�,�$�&�&�K����Z��3�3�E��u�_�%�%�H�B�B��(9�(9�(;�(;�(A�r�B�B�B�Br"rlrc
�v�t��}dD])}t||t||�������*tjt|d������|_tjt|d������|_d�t|d�����	��D��|_
t|d����|_|jrt|d����nd|_
t|d����|_t|d	����|_t!|d
����|_d�t|d�����	��D��|_d
�t|d�����	��D��|_d�t|d�����	��D��|_d�|d�����pgD��|_d�|d�����pgD��|_d�t|d�����	d��D��}d�|D��|_|S)z�Return a bugreport object from a given status xml element

    Parameters
    ----------
    bug_el
        a status XML element

    Returns
    -------
    Bugreport
        a Bugreport object

    )�
originator�subject�msgid�packagerL�owner�summary�location�source�pending�	forwarded�date�log_modifiedc��g|]}|��Srr)r'r�s  r rxz!_parse_status.<locals>.<listcomp>�s��;�;�;���;�;�;r"rnrJNrI�
unarchived�bug_numc�,�g|]}t|����Srru�r'rgs  r rxz!_parse_status.<locals>.<listcomp>�s��H�H�H��c�!�f�f�H�H�Hr"�
mergedwithc�,�g|]}t|����Srrur�s  r rxz!_parse_status.<locals>.<listcomp>�s��F�F�F��S��V�V�F�F�Fr"�	blockedbyc�,�g|]}t|����Srrur�s  r rxz!_parse_status.<locals>.<listcomp>�s��@�@�@�Q�#�a�&�&�@�@�@r"�blocksc�,�g|]}t|����Sr�r#�r'�els  r rxz!_parse_status.<locals>.<listcomp>��+�������B�����r"�found_versionsc�,�g|]}t|����Srr�r�s  r rxz!_parse_status.<locals>.<listcomp>�r�r"�fixed_versionsc��g|]}|�|��Srr)r'�_fs  r rxz!_parse_status.<locals>.<listcomp>�s��D�D�D�b��D�r�D�D�Dr"�affects�,c�6�g|]}|�����Sr)�strip)r'�as  r rxz!_parse_status.<locals>.<listcomp>�s ��.�.�.��1�7�7�9�9�.�.�.r")r�setattrr�r�utcfromtimestamp�floatr�r�r#�splitrn�_parse_boolrJ�done_byrIr�rEr�r�r�r�rar�r�r�)rlrw�fieldr�s    r rcrc�s����+�+�C��
=�
=��	��U�,�V�V�E�]�]�;�;�<�<�<�<��(��v�v�f�~�~�)>�)>�?�?�C�H��0��v�v�n�7M�7M�1N�1N�O�O�C��;�;�s�6�6�&�>�>�2�2�8�8�:�:�;�;�;�C�H��6�6�&�>�>�*�*�C�H�69�h�H�"�6�6�&�>�>�2�2�2�D�C�K��v�v�j�1�1�2�2�C�L� ����!5�!5�6�6�C�N��f�f�Y�'�'�(�(�C�K�H�H�c�&�&��*>�*>�&?�&?�&E�&E�&G�&G�H�H�H�C�N�F�F�S����)<�)<�%=�%=�%C�%C�%E�%E�F�F�F�C�M�@�@�#�f�f�X�&6�&6�"7�"7�"=�"=�"?�"?�@�@�@�C�J��� �&�!1�2�2�;�;�=�=�C�����C���� �&�!1�2�2�;�;�=�=�C�����C��E�D�C���y� 1� 1�2�2�8�8��=�=�D�D�D�G�.�.�g�.�.�.�C�K��Jr"��soap)r��action�	namespace�soap_ns�	proxy_argrc��|td<dS)z�Set proxy for SOAP client.

    You must use this method after import to set the proxy.

    Parameters
    ----------
    proxy_arg

    �proxyN��_soap_client_kwargs)r�s r �set_soap_proxyr��s��$-��� � � r"�urlc��|td<dS)z�Set location URL for SOAP client

    You may use this method after import to override the default URL.

    Parameters
    ----------
    url
        default URL

    r�Nr�)r�s r �set_soap_locationr��s��'*��
�#�#�#r"�dict[str, str]c��tS)zlReturns SOAP client kwargs.

    Returns
    -------
    dict[str, str]
        the SOAP client kwargs

    r�rr"r �get_soap_client_kwargsr�
s
���r"rc�$�tdit��S)z�Factory method that creates a SoapClient.

    For thread-safety we create SoapClients on demand instead of using a
    module-level one.

    Returns
    -------
    SoapClient
        a SoapClient instance

    r)rr�rr"r r[r[s���,�,�+�,�,�,r"r��
Iterable[Any]�list[tuple[str, Any]]c��g}t|��D],\}}|�dt|��z|f���-|S)aqConvert arguments to be consumed by a SoapClient method

    Parameters
    ----------
    *args
        any argument

    Returns
    -------
    list[tuple[str, Any]]
        the converted arguments

    Examples
    --------
    Soap client required a list of named arguments:

        >>> _convert_soap_method_args('a', 1)
        [('arg0', 'a'), ('arg1', 1)]

    r�)r�rbr#)r��	soap_argsr�r�s    r �_convert_soap_method_argsr�(sO��*�I���o�o�4�4�
��s����%�#�e�*�*�,�c�2�3�3�3�3��r"�method_namerc�V�t��}t|�}t||��|�S)z�Wrapper to call SoapClient method

    Parameters
    ----------
    method_name
        the method name
    *args

    Returns
    -------
    Any

    )r[r��getattr)r�r�rer�s    r r{r{Cs0��%�&�&�K�)�4�0�I�,�7�;��,�,�i�8�8r"�el_name�parent�list_�	list[Any]c�T�|�|��}|�dd��|�dd��|�ddt|��d�d���|D];}|�d	t|����}|�dd
���<|S)z�Build Array as child of parent.

    More specifically: Build a soapenc:Array made of ints called `el_name` as a
    child of `parent`.

    Parameters
    ----------
    el_name
    parent
    list

    Returns
    -------
    SimpleXMLElement

    z
xmlns:soapencz)http://schemas.xmlsoap.org/soap/encoding/rsr�zsoapenc:arrayTypezxsd:int[�d�]�itemzxsd:int)�	add_child�
add_attributer]r#)r�r�r�r�rr�s      r r_r_Ws���*
�	�	�'�	"�	"�B�����D�������Z��1�1�1����(�*D�S��Z�Z�*D�*D�*D�*D�E�E�E��5�5���,�,�v�s�4�y�y�1�1�����j�)�4�4�4�4�
�Ir"r�r1c�L�t|��}|���dvS)z�Parse a boolean value from a XML element.

    Parameters
    ----------
    el
        the element to parse

    Returns
    -------
    bool
        the parsed value

    )r��0)r#r�)r�r)s  r r�r�xs"��
��G�G�E��{�{�}�}�	�)�)r"c���t|��}|����d��}|r6|jdkr+t	j|��}|�dd���}|S)z�Read a string element, maybe encoded in base64.

    Parameters
    ----------
    el
        the element to parse

    Returns
    -------
    str
        the parsed value

    rszxsd:base64Binaryzutf-8�replace)�errors)r#r|r}r)�base64�	b64decode�decode)r�r)�el_type�tmps    r r�r��si��
��G�G�E��m�m�o�o�!�!�*�-�-�G��6�7�=�$6�6�6���u�%�%���
�
�7�9�
�5�5���Lr")rRrSrrTr)rmr#rnrorrp)r�rErr�)r�rErr�)r�r�rr�)rlrrr)r�r#rr)r�r#rr)rr�)rr)r�r�rr�)r�r#r�rrr)r�r#r�rr�r�rr)r�rrr1)r�rrr#).rQ�
__future__rr	�email.feedparserrm�email.policyr�os�logging�typingrr�pysimplesoap.clientr�pysimplesoap.simplexmlr�	getLoggerrN�logger�ca_path�path�isdir�environ�URL�NS�BTS_URLr^rKrrWrrr�r�r�rcr�r�r�r�r[r�r{r_r�r�rr"r �<module>rs�����#�"�"�"�"�"�
�
�
�
���������������	�	�	�	����� � � � � � � � �*�*�*�*�*�*�3�3�3�3�3�3�
��	�8�	$�	$�����7�=�=����)�!(�B�J�~��
1����
$��
�
��
����
����
�T�T�T�T�T�T�T�T�n'�'�'�'�X04�'�'�'�'�'�T3�3�3�3�lC�C�C�C�,:C�:C�:C�:C�z=�=�=�=�B����	���
-�
-�
-�
-�*�*�*�*�	�	�	�	�-�-�-�-�����69�9�9�9�(����B*�*�*�*�$�����r"