
    &=d                     ^    d dl mZ ddlmZ ddlmZ d dlmZ dZ G d de          Z	dd
Z
d	S )    )
HTMLParser   )utils)open_url)	NoNetworkz2https://buildd.debian.org/build.php?arch=%s&pkg=%sc                   4    e Zd Zd Zd Zd Zd	dZd Zd ZdS )
BuilddParserc                 X    t          j        |            i | _        d | _        d| _        d S )NF)r   __init__versionssavedatafound_succeededselfs    7/usr/lib/python3/dist-packages/reportbug/checkbuildd.pyr   zBuilddParser.__init__%   s/    D!!!$    c                 6    | j         | j         |z   | _         d S d S )Nr   )r   datas     r   handle_datazBuilddParser.handle_data.   s$    =$ MD0DMMM %$r   c                     d| _         d S )N r   r   s    r   save_bgnzBuilddParser.save_bgn3   s    r   r   c                 x    | j         }d | _         |s)|'d                    |                                          }|S )N )r   joinsplit)r   moder   s      r   save_endzBuilddParser.save_end6   s;    } 	*(88DJJLL))Dr   c                 >    |dk    r|                                   d S d S )Ntd)r   )r   tagattrss      r   handle_starttagzBuilddParser.handle_starttag=   s#    $;;MMOOOOO ;r   c                     |dk    r5|                                  }|r!d|                                v rd| _        d S d S d S d S )Nr!   
successfulT)r   lowerr   )r   r"   r   s      r   handle_endtagzBuilddParser.handle_endtagA   sW    $;;==??D ,

44'+$$$ ;, ,44r   N)r   )	__name__
__module____qualname__r   r   r   r   r$   r(    r   r   r	   r	   $   ss        % % %1 1 1
       , , , , ,r   r	   Nc                     |st          j                    }	 t          t          || fz  ||          }n# t          $ r Y dS w xY w|sdS t                      }|                    |           |j        S )a  
    Check if a source package was built successfully on a buildd

    The check is not about a specific package version. If `arch` is not
    given and there is evidence that any version of the package once
    built sucessfully on any architecture, this function returns True.

    If `arch` is given, the check is restricted to that architecture.

    Parameters
    ----------
    src_package : str
        name of a source package
    timeout : int
        connection timeout in seconds
    arch : str, optional
        the arch to be checked
    http_proxy : str, optional
        Http proxy url to use for connection

    Returns
    -------
    bool
        True if the connection succeeded and the package was found to
        have built successfully, otherwise False
    F)r   get_archr   
BUILDD_URLr   r	   feedr   )src_packagetimeoutarch
http_proxypageparsers         r   check_builtr7   H   s    6   ~
dK%88*gNN   uu  u^^F
KK!!s   3 
A A)NN)html.parserr   r   r   urlutilsr   reportbug.exceptionsr   r/   r	   r7   r,   r   r   <module>r;      s   0 # " " " " "                  B
!, !, !, !, !,: !, !, !,H)" )" )" )" )" )"r   