o
    f                     @   s   d Z g dZddlZddlZddlZddlmZ g dZdddZdd	d
Z	dddZ
dd Zdd Zdd ZG dd deZdS )zThis module contains general utility code that is used throughout
the library.

For users of this library, the C{L{log}} function is probably the most
interesting.
)log
appendArgstoBase64
fromBase64autoSubmitHTML    N)	urlencode)z
lxml.etreezxml.etree.cElementTreezxml.etree.ElementTreecElementTreezelementtree.ElementTreeOpenID transaction in progressc                 C   s   d|| f S )Nz
<html>
<head>
  <title>%s</title>
</head>
<body onload="document.forms[0].submit();">
%s
<script>
var elements = document.forms[0].elements;
for (var i = 0; i < elements.length; i++) {
  elements[i].style.display = "none";
}
</script>
</body>
</html>
 )formtitler
   r
   O/var/www/html/humari/django-venv/lib/python3.10/site-packages/openid/oidutil.pyr      s   r   c                 C   s   | du rt } | D ]=}z
t|dddg}W n	 ty   Y qw z
|d W |  S  tttfy3       t d }t	d||f  Y qtd| f )a:  Find a working ElementTree implementation, trying the standard
    places that such a thing might show up.

    >>> ElementTree = importElementTree()

    @param module_names: The names of modules to try to use as
        ElementTree. Defaults to C{L{elementtree_modules}}

    @returns: An ElementTree module
    Nunusedz	<unused/>   zRNot using ElementTree library %r because it failed to parse a trivial document: %szMNo ElementTree library found. You may need to install one. Tried importing %r)
elementtree_modules
__import__ImportErrorXML
SystemExitMemoryErrorAssertionErrorsysexc_infor   )module_namesmod_nameElementTreewhyr
   r
   r   importElementTree)   s*   
r   c                 C   s   t j|  t jd dS )a$  Handle a log message from the OpenID library.

    This implementation writes the string it to C{sys.stderr},
    followed by a newline.

    Currently, the library does not use the second parameter to this
    function, but that may change in the future.

    To install your own logging hook::

      from openid import oidutil

      def myLoggingFunction(message, level):
          ...

      oidutil.log = myLoggingFunction

    @param message: A string containing a debugging message from the
        OpenID library
    @type message: str

    @param level: The severity of the log message. This parameter is
        currently unused, but in the future, the library may indicate
        more important information with a higher level value.
    @type level: int or None

    @returns: Nothing.
    
N)r   stderrwrite)messagelevelr
   r
   r   r   N   s   r   c                 C   s   t |dr| }|  nt|}t|dkr| S d| v r!d}nd}d}|D ]$\}}t|tur6|d}t|turA|d}||f||< |d7 }q'd| |t|f S )a  Append query arguments to a HTTP(s) URL. If the URL already has
    query arguemtns, these arguments will be added, and the existing
    arguments will be preserved. Duplicate arguments will not be
    detected or collapsed (both will appear in the output).

    @param url: The url to which the arguments will be appended
    @type url: str

    @param args: The query arguments to add to the URL. If a
        dictionary is passed, the items will be sorted before
        appending them to the URL. If a sequence of pairs is passed,
        the order of the sequence will be preserved.
    @type args: A dictionary from string to string, or a sequence of
        pairs of strings.

    @returns: The URL with the parameters added
    @rtype: str
    itemsr   ?&zUTF-8r   z%s%s%s)	hasattrr#   sortlistlentypestrencoder   )urlargssepikvr
   r
   r   r   o   s$   




r   c                 C   s   t | dd S )z/Represent string s as base64, omitting newlinesN)binascii
b2a_base64sr
   r
   r   r      s   r   c                 C   s*   zt | W S  t jy   ttd w )Nr   )r4   
a2b_base64Error
ValueErrorr   r6   r
   r
   r   r      s
   r   c                   @   s8   e Zd ZdZdd Zdd Zdd Zdd	 Zd
d ZdS )SymbolzThis class implements an object that compares equal to others
    of the same type that have the same name. These are distict from
    str or unicode objects.
    c                 C   s
   || _ d S Nname)selfr>   r
   r
   r   __init__      
zSymbol.__init__c                 C   s   t | t |u o| j|jkS r<   )r*   r>   r?   otherr
   r
   r   __eq__   s   zSymbol.__eq__c                 C   s
   | |k S r<   r
   rB   r
   r
   r   __ne__   rA   zSymbol.__ne__c                 C   s   t | j| jfS r<   )hash	__class__r>   r?   r
   r
   r   __hash__   s   zSymbol.__hash__c                 C   s   d| j f S )Nz<Symbol %s>r=   rH   r
   r
   r   __repr__   s   zSymbol.__repr__N)	__name__
__module____qualname____doc__r@   rD   rE   rI   rJ   r
   r
   r
   r   r;      s    r;   )r	   r<   )r   )rN   __all__r4   r   urlparseurllibr   r   r   r   r   r   r   r   objectr;   r
   r
   r
   r   <module>   s    


%!0