o
    iV&                     @   s  d dl mZ d dlZd dlZd dlmZ d dlmZ d dlm	Z	 d dl
mZ ddd	i Zd
ZdZdZ	 dd ZedddZedddZedddZedddZG dd de	ZG dd deZejsdeZG dd deZG dd deZdd Zdd Zdededdedejed d ed d!ed!d"ed"eed#d#ed#i	ZG d$d% d%eed&ZG d'd( d(eeed)Z G d*d+ d+eeed)Z!G d,d- d-eed)Z"G d.d/ d/eed)Z#G d0d1 d1eed)Z$G d2d3 d3eed)Z%ejse&e'ei dS e&e'ee(ei dS )4    )unicode_literalsN)
NATIVE_MAP)six)SimpleModel)re_match_with_spanz-%(x)s{8}-%(x)s{4}-%(x)s{4}-%(x)s{4}-%(x)s{12}xz[a-fA-F0-9]z\w+(\.\w+)*i   i   c                 C   s   d}d}d}| rd| d }n|}|s|d d | d S |d	 d
 | d | d | }d| | d | d d d }|d d | d | S )Nz[ \t]*z[0-9A-Za-z!#$%&'*+.^_`|~-]+z"(?:[^"\\]|\.)*"zN(application|audio|font|example|image|message|model|multipart|text|video|x-(?:z))/()=z(?:|z);?z(;(z)*z)? )strictwith_paramsowstokenquotedString	main_typeparamparamsr   r   \/var/www/html/LicenciasMIG/venv/lib/python3.10/site-packages/spyne/model/primitive/string.py_gen_mime_type_pattern+   s<    r   TF)r   r   c                   @   sX   e Zd ZdZdZejZG dd dej	Z	dd Z
edd Zed	d
 Zedd ZdS )UnicodezpThe type to represent human-readable data. Its native format is `unicode`
    or `str` with given encoding.
    stringc                   @   sD   e Zd ZdZdZ	 edZ	 dZ	 dZ		 dZ
	 dZ	 dZ	 dZdS )zUnicode.AttributeszSCustomizable attributes of the :class:`spyne.model.primitive.Unicode`
        type.r   infNr   )__name__
__module____qualname____doc__min_lendecimalDecimalmax_lenpatternunicode_patternencodingunicode_errorsformatcastr   r   r   r   
AttributesW   s$    
r)   c                 O   s>   t |dksJ t |dkr|d |d< tj| fi |}|S )N   r   r"   )lenr   __new__)clsargskwargsretvalr   r   r   r,   y   s
   zUnicode.__new__c                 C   s:   t | o| jjtjjko| jjtjjko| jjtjjkS N)r   
is_defaultr)   r   r   r"   r#   )r-   r   r   r   r2      s   
zUnicode.is_defaultc                 C   s8   t | |o|d u p| jjt|  ko| jjkS   S r1   )r   validate_stringr)   r   r+   r"   r-   valuer   r   r   r3      s   zUnicode.validate_stringc                 C   s    t | |o|d u pt| j|S r1   )r   validate_nativer   r)   r4   r   r   r   r6      s   
zUnicode.validate_nativeN)r   r   r   r   __type_name__r   	text_typeValuer   r)   r,   staticmethodr2   r3   r6   r   r   r   r   r   O   s    "


r   c                   @   s   e Zd ZdS )StringN)r   r   r   r   r   r   r   r;      s    r;   c                   @   s6   e Zd ZdZdZG dd dejZG dd deZdS )AnyUriz6A special kind of String type designed to hold an uri.anyURIc                   @   s   e Zd ZdZ	 dZdS )zAnyUri.AttributesN)r   r   r   textanchor_classr   r   r   r   r)      s
    r)   c                   @   s"   e Zd ZdZdddZdd ZdS )zAnyUri.Valuea  A special object that is just a better way of carrying the
        information carried with a link.

        :param href: The uri string.
        :param text: The text data that goes with the link. This is a
            ``str`` or a ``unicode`` instance.
        :param content: The structured data that goes with the link. This is an
            `lxml.etree.Element` instance.
        Nc                 C   s   || _ || _|| _d S r1   )hrefr>   content)selfr@   r>   rA   r   r   r   __init__   s   
zAnyUri.Value.__init__c                 C   s   d | j| j| jS )Nz*Uri(href={0!r}, text={1!r}, content={2!r}))r'   r@   r>   rA   )rB   r   r   r   __repr__   s   zAnyUri.Value.__repr__)NN)r   r   r   r   rC   rD   r   r   r   r   r9      s    

r9   N)	r   r   r   r   r7   r;   r)   objectr9   r   r   r   r   r<      s
    r<   c                   @   s   e Zd ZdZdS )ImageUriz8A special kind of String that holds the uri of an image.N)r   r   r   r   r   r   r   r   rF          rF   c                 C   sD   t | |o!|d u p!| jjt|  ko| jjkn  o!t| j|S r1   )r   r3   r)   r   r+   r"   r   r4   r   r   r   _uuid_validate_string   s
   $
rH   c                    s   ddl m   fdd}|S )Nr   )UUIDc                    s.   z di |i W dS  t y   Y dS w )NFTr   )
ValueError)r-   vrI   keyr   r   _uvalid   s   z _Tuuid_validate.<locals>._uvalid)uuidrI   )rM   rN   r   rL   r   _Tuuid_validate   s   rP   hexurnbytesbytes_lefieldsintc                   @   sN   e Zd ZdZdZdZejZG dd de	e
djZedd Zed	d
 ZdS )Uuidz5Unicode subclass for Universially-Unique Identifiers.http://spyne.io/schemarO   c                   @   s   e Zd ZdZdS )zUuid.AttributesN)r   r   r   serialize_asr   r   r   r   r)      rG   r)   r#   c                 C   s   t | jj | |S r1   )_uuid_validater)   rY   r4   r   r   r   r3      s   zUuid.validate_stringc                 C   s   t | |S r1   )r   r6   r4   r   r   r   r6      s   zUuid.validate_nativeN)r   r   r   r   __namespace__r7   rO   rI   r9   r   UUID_PATTERNr)   r:   r3   r6   r   r   r   r   rW      s    
rW   rZ   c                   @      e Zd ZdZdZdZdS )LtreeRA special kind of String type designed to hold the Ltree type from
    Postgresql.rX   ltreeStringNr   r   r   r   r\   r7   r   r   r   r   r_          r_   )r$   c                   @   r^   )
LtreeLarger`   rX   largeLtreeStringNrb   r   r   r   r   rd     rc   rd   c                   @   r^   )MimeTypeStrictzRA special kind of String type designed to hold a mime type as defined
    by IANA.rX   strictMimeTypeStringNrb   r   r   r   r   rf   
  rc   rf   c                   @   r^   )MimeTypezxA special kind of String type designed to hold a forward-compatible
    mime type that can have any string as main type.rX   mimeTypeStringNrb   r   r   r   r   rh     rc   rh   c                   @   r^   )MediaTypeStrictzA special kind of String type designed to hold a mime type as defined
    by IANA followed by arbitrary parameters.

    See: https://tools.ietf.org/html/rfc7231#section-3.1.1.1rX   strictMediaTypeStringNrb   r   r   r   r   rj     s    rj   c                   @   r^   )	MediaTypezA special kind of String type designed to hold a forward-compatible
    media type that can have any string as main type. A media type is
    essentially a mime type plus parameters.

    See: https://tools.ietf.org/html/rfc7231#section-3.1.1.1rX   mediaTypeStringNrb   r   r   r   r   rl   $  s    rl   ))
__future__r   r    rO   spyne.model.primitiver   
spyne.utilr   spyne.model._baser   spyne.model.primitive._baser   r]   LTREE_PATTERNLTREE_OPTIMAL_SIZELTREE_MAXIMUM_SIZEr   MIME_TYPE_PATTERN_STRICTMIME_TYPE_PATTERN_PERMISSIVEMEDIA_TYPE_PATTERN_STRICTMEDIA_TYPE_PATTERN_PERMISSIVEr   r;   PY2r<   rF   rH   rP   binary_typerV   r[   rW   r_   rd   rf   rh   rj   rl   updatestrunicoder   r   r   r   <module>   sp   



K!



