
    -i7*                        U d dl mZ d dlmZmZ d dlmZmZ d dlm	Z	m
Z
 ddlT ddlmZ ddlmZ d	Zd
Z G d d          ZdZdZdZdZedz   Zg dxZZ e ej                              Z G d d          Z G d d          Z G d d          Zdd dd d  e            dd d d ddZe e!d<    G d de           Z"ddd e#d!e#d"e#d#e$d$d%f
d&Z%d' Z&d%S )(    )environ)choicechoices)UnionList)postget   )*)_logger)Metadata)DColorDStyleDFormatDOptionsoptionsall_optionsdefault_optionsstylesz	models.pyc                   "    e Zd ZU dZdZeed<   dS )_FindPilzINot important for you, just makes things easier for me on the back-end ;)TfoundN)__name__
__module____qualname____doc__r   bool__annotations__     M/var/www/html/speakWrite/venv/lib/python3.11/site-packages/dicebear/models.pyr   r   .   s(         SSE4r    r   abcdef
0123456789   zhttps://api.dicebear.com/9.xz/{}/schema.jsonfliprotatescaleradiussizebackgroundColorbackgroundTypebackgroundRotation
translateX
translateYrandomizeIdsc                       e Zd ZdZddeeee         f         fdZedefd            Z	e	Z
d Zd Zd	 Zd
 Zd Zedd            ZdS )r   z*
    Base class for DAvatar's colors.
    transparent	html_codec                    g }g }t          |t                    r*|                    dd                              d          }n0t          |t                    rt          d |D                       r|}|D ]{}|                    dd          }t          |          dk    st          d |D                       r"|dk    rt          t          |                    |	                    |           |d
                    |          | _        d	S )
a  
        Colors used in this package. This uses HTML/hex color codes!

        :param html_code: :py:class:`str` :: the html color code to use as color. This can be a list of strings if `backgroundType` has been set to "gradientLinear". (default: transparent)
        :type html_code: str
        :raise dicebear.errors.IncorrectColor: if the given html_code is an invalid hex color
          ,c              3   @   K   | ]}t          |t                    V  d S N)
isinstancestr.0xs     r!   	<genexpr>z"DColor.__init__.<locals>.<genexpr>_   s,      0W0WAs1C1C0W0W0W0W0W0Wr    #   c              3   8   K   | ]}|t           t          z   vV  d S r9   )ASCII_LOWERCASEDIGITSr<   s     r!   r?   z"DColor.__init__.<locals>.<genexpr>c   s,      %X%Xaa&0H&I%X%X%X%X%X%Xr    r2   N)r:   r;   replacesplitlistalllenanyIncorrectColorappendjoin
_html_code)selfr3   	code_listhex_listcodes        r!   __init__zDColor.__init__S   s    	i%% 	"!))#r2288==II	4(( 	"S0W0WY0W0W0W-W-W 	"!I 	" 	"D<<R((DD		Q#%X%XSW%X%X%X"X"X^bfs^s^s$SYY///OOD!!!!"xx11r    returnc                 *    t          | j                  S )z9Returns the validated and formatted html/hex color codes.)r;   rN   rO   s    r!   r3   zDColor.html_codeh   s     4?###r    c                 *    t          | j                  S r9   r;   r3   rV   s    r!   __str__zDColor.__str__o       4>"""r    c                 *    t          | j                  S r9   rX   rV   s    r!   __repr__zDColor.__repr__r   rZ   r    c                 *    t          | j                  S r9   )hashr3   rV   s    r!   __hash__zDColor.__hash__u   s    DN###r    c                 b    t          |t                    r| j        |j        k    S | j        |k    S r9   r:   r   r3   rO   others     r!   __eq__zDColor.__eq__x   0    eV$$ 	5>U_44~&&r    c                 b    t          |t                    r| j        |j        k    S | j        |k    S r9   ra   rb   s     r!   __ne__zDColor.__ne__}   re   r    c                  ~    t          d                    t          t          t          z   d                              S )z^
        Get a random html code.

        :return: :py:class:`dicebear.models.DColor`
        r6   rA   )k)r   rM   r   rC   rD   r   r    r!   randomzDColor.random   s0     bgggo&>!DDDEEFFFr    N)r2   )rT   r   )r   r   r   r   r   r;   r   rS   propertyr3   hex_coderY   r\   r_   rd   rg   staticmethodrj   r   r    r!   r   r   N   s         2 2%T#Y"7 2 2 2 2* $3 $ $ $ X$ H# # ## # #$ $ $' ' '
' ' '
 G G G \G G Gr    r   c                   l   e Zd ZdZexZZed         Zed         Zed         Z	ed         Z
ed         Zed         Zed         Zed	         Zed
         Zed         Zed         Zed         Zed         Zed         Zed         Zed         Zed         Zed         Zed         Zed         Zed         Zed         Zed         Zed         Zed         Zed         Z ed         Z!ed         Z"ed         Z#ed         Z$ed          Z%d! Z&e'd"e(d#e)fd$            Z*e'd#e(fd%            Z+e'd&e(d#e(fd'            Z,d(S ))r   z
    All possible styles for the avatars. Visit https://dicebear.com/styles to see what they look like.

    - Note: Only works with attributes!
    r   r
               rA         	   
                                                            r$   c                      t          d          )z%Only use `.attribute` to use a style.z!DStyle should not be initialized.NotImplementedErrorrV   s    r!   rS   zDStyle.__init__   s    !"EFFFr    stylerT   c                 R   | t           vrt          d|  d          	 t          t                              |           t
                                                    S # t          $ r>}t          t          t          |                    t          |          d          d}~ww xY w)z
        Returns a dict with the JSON schema (all properties) of the given avatar style.

        :param style: :py:class:`str` :: the avatar style to get the JSON schema of
        :type style: str
        :return: :py:class:`dict`
        "z" is not a valid avatar style.)timeout)	exceptionerrorN)r   
ValueErrorr	   YformatTIMEOUTjson	Exception	HTTPErrorr;   type)r   es     r!   
get_schemazDStyle.get_schema   s     FFFFGGG	Jqxx888==??? 	J 	J 	J#d1gg,,QHHIII	Js   ?A 
B&(9B!!B&c                  *    t          t                    S )zF
        Get a random style.

        :return: a random style
        )r   r   r   r    r!   rj   zDStyle.random   s     f~~r    	style_strc                     	 t          t          |                                                     dd                    S # t          $ r t          d|            w xY w)z
        Get an avatar style from a string.

        :param style_str: :py:class:`str` :: the string to convert to a DStyle
        :type style_str: str
        -_zInvalid style: )getattrr   lowerrE   AttributeErrorr   )r   s    r!   from_strzDStyle.from_str   sc    	<69??#4#4#<#<S##F#FGGG 	< 	< 	<:y::;;;	<s	   := AN)-r   r   r   r   r   rG   
all_styles
adventureradventurer_neutral	avataaarsavataaars_neutralbig_earsbig_ears_neutral	big_smilebotttsbottts_neutralcroodlescroodles_neutraldylan	fun_emojiglassicons	identiconinitialsloreleilorelei_neutralmicahminiavs
notionistsnotionists_neutral
open_peepspersonas	pixel_artpixel_art_neutralringsshapesthumbs	toon_headrS   rm   r;   dictr   rj   r   r   r    r!   r   r      s        
 D:Jq	Iq	ayHayq	IAYFAYNayHbz2JEr
I2JE2JEr
IbzHRjGRjO2JERjGJJbzHr
Ir
2JEBZFBZFr
IG G G J# J$ J J J \J C    \ 
<C 
<C 
< 
< 
< \
< 
< 
<r    r   c                   `    e Zd ZdZg dxZZdZdZdZdZ	dZ
dZd	Zd
 Zededefd            ZdS )r   zn
    All possible image formats for saving or converting avatars.
    - Note: Only works with attributes!
    )svgwebpavifpngjpgjpegr   r   r   r   r   r   r   r   c                      t          d          )z&Only use `.attribute` to use a format.z"DFormat should not be initialized.r   rV   s    r!   rS   zDFormat.__init__   s    !"FGGGr    
format_strrT   c                 x    t          t          |                                                     dd                    S )z
        Get an avatar format from a string

        :param format_str: :py:class:`str` :: the string to convert to a DFormat
        :type format_str: str
        zdformat.r6   )r   r   r   rE   )r   s    r!   r   zDFormat.from_str   s0     w
 0 0 2 2 : ::r J JKKKr    N)r   r   r   r   rG   all_formatsr   r   r   r   r   r   r   rS   rm   r;   r   r   r    r!   r   r      s         
 ONNND;
CDD
C
CDDH H H LS LS L L L \L L Lr    r   Fd   solidr   c                        e Zd ZU dZi Zeed<   exZZddddd e	            ddddddde
d	ed
edededee	ee	         f         dedededede
f fdZededd fd            Z xZS )r   zC
    The options class for :py:class:`dicebear.avatar.DAvatar`
    emptyFr   r   r   r%   r&   r'   r(   r)   r*   r+   r,   r-   r.   r/   r0   c                2   |||||||||	|
|d}|                      |                                t                                          z
             d| v r!| d         dk    r|                     d           t	                                          |            dS )z
        Go to https://github.com/jvherck/dicebear#base-options to see all info (important for minimum and maximum values for each option!)
        r%   r*   r   N)updateitemsr   popsuperrS   )rO   r&   r'   r(   r)   r*   r+   r,   r-   r.   r/   r0   d	__class__s                r!   rS   zDOptions.__init__  s    & .,"4$$(
 
 	AGGII 5 5 7 77888T>>d6la//HHVr    r   rT   c                     |D ]8}|t           vs||         t           |         k    r|                    |d           9 |             }|                                 |                    |           |S )z.Return a new instance of DOptions from a dict.N)r   r   clearr   )clsr   itemrO   s       r!   	from_dictzDOptions.from_dict7  sr      	" 	"D?**ag9N.N.NdD!!!suu

Ar    )r   r   r   r   r   r   r   r   defaultr   r   intr   r   r;   rS   classmethodr   __classcell__)r   s   @r!   r   r     sC          E4 //Og
 7=vxx%"#"" " " " 	"
 " " " vtF|34" "  " " " " " " " " "H $ :    [    r    r   )_test_file_class	_functionr   rT   Nc                X   t          j        dd                                          dk    rdS | ||t          |                                          d}dddd	}	 t	          d
||d           dS # t
          $ r/}t          j        dt          |          d           Y d}~dS d}~ww xY w)z
    Pings an API to update this package's usage stats. This will be used to analyse Dicebear's usage and improve your overall experience.
    "ENABLE_PYTHON_DICEBEAR_USAGE_STATSr6   trueN)fileclassfunctiontestzpipedream/1zapplication/jsonacbd2023)z
User-AgentzContent-Typez-Keyz,https://eo1p6rm1ydzj8yl.m.pipedream.net/runsrv   )r   headersr   z;Failed to ping the API to update the usage stats. Error: %sT)exc_info)r   r	   r   r;   r   r   r   warning)r   r   r   r   __body	__headersr   s          r!   _stats_increaser   C  s     {7<<BBDDNNE

  ""	 F $* I
n:		
 	
 	
 	
 	
 	
  n n nUWZ[\W]W]hlmmmmmmmmmmns   A0 0
B):$B$$B)c                       fd}|S )z1Decorator to check if package Pillow is installedc                  L    t           j        du r | i |S t                      )NT)r   r   PILError)argskwargsfuncs     r!   wrapperz_pilcheck.<locals>.wrapperb  s/    >T!!4((((jjr    r   )r   r   s   ` r!   	_pilcheckr   _  s#        
 Nr    )'osr   rj   r   r   typingr   r   requestsr   r	   errorsr   metadatar   __all____filename__r   rC   rD   r   Xr   r   r   rG   keysr   r   r   r   r   r   r   r   r;   r   r   r   r   r    r!   <module>r	     s  .        " " " " " " " "                                	         	
"   + 
mhmoo		;G ;G ;G ;G ;G ;G ;G ;G|O< O< O< O< O< O< O< O<dL L L L L L L L> vxx    5 5 5 5 5t 5 5 5p OT n n n3 n n nt nX\ n n n n8    r    