
    ȯeiC                       U d Z ddlmZ ddlZddlZddlZddlZddlZddlm	Z	m
Z
mZmZ ddlZddlmZmZ ddlmZ ddlmZ ddlmZ dd	lmZ dd
lmZ ddlmZ ddlm Z  e	rddl!m"Z" ddlm#Z# dZ$de%d<    G d d      Z&d(dZ'd)dZ(d)dZ)d)dZ*d)dZ+d*dZ,d+dZ- ej\                  d      Z/d*dZ0d,dZ1d-dZ2d.dZ3d/d Z4d0d!Z5d1d"Z6d2d#Z7d3d$Z8d4d5d%Z9d6d&Z:d7d'Z;y)8z@Allows us to create and absorb changes (aka Deltas) to elements.    )annotationsN)TYPE_CHECKINGAnyFinalcast)LayoutConfigvalidate_width)	DocString)Member)
CachedFunc)gather_metrics)__file__)Secrets)is_mem_address_str)DeltaGenerator)WidthWithoutContent)z
(element, r    CONFUSING_STREAMLIT_SIG_PREFIXESc                  P    e Zd Z ed      efdd	 	 	 	 	 dd       Zedd       Zy)		HelpMixinhelpstretchwidthc                   t               }t        |d       t        |      }t        ||       | j                  j                  d||      S )u	  Display help and other information for a given object.

        Depending on the type of object that is passed in, this displays the
        object's name, type, value, signature, docstring, and member variables,
        methods — as well as the values/docstring of members and methods.

        Parameters
        ----------
        obj : any
            The object whose information should be displayed. If left
            unspecified, this call will display help for Streamlit itself.
        width : "stretch" or int
            The width of the help element. This can be one of the following:

            - ``"stretch"`` (default): The width of the element matches the
              width of the parent container.
            - An integer specifying the width in pixels: The element has a
              fixed width. If the specified width is greater than the width of
              the parent container, the width of the element matches the width
              of the parent container.

        Example
        -------

        Don't remember how to initialize a dataframe? Try this:

        >>> import streamlit as st
        >>> import pandas
        >>>
        >>> st.help(pandas.DataFrame)

        .. output::
            https://doc-string.streamlit.app/
            height: 700px

        Want to quickly check what data type is output by a certain function?
        Try:

        >>> import streamlit as st
        >>>
        >>> x = my_poorly_documented_function()
        >>> st.help(x)

        Want to quickly inspect an object? No sweat:

        >>> class Dog:
        >>>   '''A typical dog.'''
        >>>
        >>>   def __init__(self, breed, color):
        >>>     self.breed = breed
        >>>     self.color = color
        >>>
        >>>   def bark(self):
        >>>     return 'Woof!'
        >>>
        >>>
        >>> fido = Dog("poodle", "white")
        >>>
        >>> st.help(fido)

        .. output::
            https://doc-string1.streamlit.app/
            height: 300px

        And if you're using Magic, you can get help for functions, classes,
        and modules without even typing ``st.help``:

        >>> import streamlit as st
        >>> import pandas
        >>>
        >>> # Get help for Pandas read_csv:
        >>> pandas.read_csv
        >>>
        >>> # Get help for Streamlit itself:
        >>> st

        .. output::
            https://doc-string2.streamlit.app/
            height: 700px
        F)allow_contentr   
doc_string)layout_config)DocStringProtor	   r   	_marshalldg_enqueue)selfobjr   doc_string_protor   s        _/var/www/html/glpi_dashboard/venv/lib/python3.12/site-packages/streamlit/elements/doc_string.pyr   zHelpMixin.help/   sQ    h *+uE2$51"C(ww*-   
 	
    c                    t        d|       S )zGet our DeltaGenerator.r   )r   )r"   s    r%   r    zHelpMixin.dg   s     $d++r&   N)r#   r   r   r   returnr   )r(   r   )__name__
__module____qualname__r   	streamlitr   propertyr     r&   r%   r   r   .   sW    F"[
DM[
[
.A[
	[
 [
z , ,r&   r   c                    t               }||| _        t        |      }|| _        t	        |      }||| _        t        ||      }||| _        | j                  j                  t        |             y)zIConstruct a DocString object.

    See DeltaGenerator.help for docs.
    N)_get_variable_namename_get_type_as_strtype_get_docstringr   
_get_valuevaluemembersextend_get_members)r$   r#   var_nameobj_typeobj_docs	obj_values         r%   r   r      s{    
 "#H ($H$c"H&.#3)I!*##L$56r&   c                f    t        | dd       }|rt        d|      S t        dt        | dd             S )Nr+   str
str | Noner)   )getattrr   )r#   r1   s     r%   	_get_namerB      s:     3-DE4  
 gc:t<==r&   c                    t        | dd       S )Nr*   )rA   r#   s    r%   _get_modulerE      s    3d++r&   c                   t        j                  |       st        |       sy d}	 t        t        j                  |             }d}t        j                  t              5  | j                  dk(  }d d d        |r1t        D ](  }|j                  |      s|j                  |d      } |S  |S # t
        $ r d}Y ut        $ r Y y w xY w# 1 sw Y   YxY w)N z(...)Fzstreamlit.delta_generator()inspectisclasscallabler?   	signature
ValueError	TypeError
contextlibsuppressAttributeErrorr*   r   
startswithreplace)r#   sigis_delta_genprefixs       r%   _get_signaturerW      s    ??3
C'##C() L			^	, E~~)DDE 6 	F~~f%kk&#.J	
 J%   E Es#   B+ C+C8CCCc                .   t        j                  |       }|lt        |       }|t        urY|t        j                  urGt        j
                  |       s2t        j                  |       s|t        urt        j                  |      }|r|j                         S y N)	rI   getdocr3   types
ModuleType
isfunctionismethodr   strip)r#   r   r;   s      r%   r4   r4      s    $J 9 D  0 00&&s+$$S)
* 1J!!r&   c                 2    t               } | yt        |       S )zTry to get the name of the variable in the current line, as set by the user.

    For example:
    foo = bar.Baz(123)
    st.help(foo)

    The name is "foo"
    N) _get_current_line_of_code_as_str _get_variable_name_from_code_str)codes    r%   r0   r0      s     ,-D|+D11r&   c                8   t        j                  |       }t        |d      st        |d      s| j                  d      S t	        |      }|sy t        |      t         j                  u r;t        |j                        t         j                  u r2|j                  j                  S t        |      t         j                  u ry | j                  d      }t        |      dkD  }|j                  }|r|j                  dz
  }||   }d }n|d   }t        |dd	      }||| S )
Nr   )command_namewrite,
   r   end_col_offset)astparse_is_stcommandremovesuffix_get_stcommand_argr3   	NamedExprtargetNameidConstantsplitlen
col_offsetlinenorA   )	rc   treearg_node
code_linesis_multilinestart_offsetfirst_lineno
first_line
end_offsets	            r%   rb   rb     s
   99T?D* F3M7=
   %%!$'H  H~&  CHH,??%%% 
h3<<	'
 D!Jz?Q&L&&L*-

  ]
X'7<
l:..r&   z[\n\r]+c                     t               } | y | j                  }|sy dj                  |      }t        j                  t
        d|j                               S )NrG   )_get_scriptrunner_framecode_contextjoinresub	_NEWLINESr_   )scriptrunner_framer   code_as_strings      r%   ra   ra   K  sS    02!
 %22L
 WW\*N66)R!5!5!788r&   c                     d } d }t        j                         D ]*  }|j                   y |j                  t        k(  r| } |S |} , |S rY   )rI   stackr   filenameSCRIPTRUNNER_FILENAME)
prev_framer   frames      r%   r   r   b  sb    J  
 %>>22!+  

 r&   c                    | j                   d   j                  }t        |t        j                        syt        |j                  dd      |k(  xs t        |j                  dd      |k(  S )z:Checks whether the AST in tree is a call for command_name.r   Frt   Nattr)bodyr6   
isinstancerl   CallrA   func)rz   re   	root_nodes      r%   rn   rn   y  s^    		!""Ii* 		d+|; 	> 		-=r&   c                    | j                   d   j                  }|j                  rt        d|j                  d         S y)z8Gets the argument node for the st command in tree (AST).r   zast.exprN)r   r6   argsr   )rz   r   s     r%   rp   rp     s7     		!""I~~J	q 122r&   c                j    t        j                  |       ryt        t        |       j                        S )Nclass)rI   rJ   r?   r3   r)   rD   s    r%   r2   r2     s&    stCy!!""r&   c                6    | sy| j                  d      \  }}}|S )NrG   rh   )	partition)textleft_s      r%   _get_first_liner     s!    %JD!QKr&   c                t    t        j                  |       ryt        j                  |       ryt        |       ryy)N      ri   r   )rI   ismodulerJ   rK   )r6   s    r%   _get_weightr     s/    ur&   c                    t        |       }||S t        |       }|r| }nt        |       }t        |      }t        |      }t	        |      xs d}|r|r	| d| | n| | }||k(  rd }|S )NrG   .)_get_human_readable_valuerB   r3   rE   rW   )r#   r:   r=   r1   name_objmodulerT   s          r%   r5   r5     s    )#.I S>D 9""F

"
(bC/5vhavcU+dVC5>	H 	r&   c                
   t        | t              ry t        j                  |       s t        j                  |       st        |       ry t        |       }t        | t              rt        |      S t        |      ry t        |      S rY   )
r   r   rI   rJ   r   rK   reprr?   _shortenr   )r6   	value_strs     r%   r   r     si    %! u!1!1%!8HUOUI% 	"")$Ir&   c                R    | j                         } t        |       |kD  r| d | dz   S | S )Nz...)r_   rw   )slengths     r%   r   r     s-    		A!$Q&1Wf:7a7r&   c                    t        | dd       }|syt        j                  |      D ]9  }t        ||d       }|t        |t              st        j
                  |      s9 y y)N	__class__FT)rA   rI   getmror   r-   isgetsetdescriptor)r#   	attr_name	obj_classparent_class
class_attrs        r%   _is_computed_propertyr     sh    [$/I  y1 \9d;
 j(+w/I/I*/U r&   c                L   g }t        |       D ]  }|j                  d      r	 t        | |      }|r(t        | j                  |      }d}d}t        |      }d }nAt        | |      }	t        |	      }t        |	      }
t        |	      }|
t        |	      }d }nd }|
}|dk(  rt               }||_        ||_        |t        |      |_        |||_        |j!                  ||f        |r#t#        |d       }|D cg c]  \  }}|	 c}}S g S # t        $ r Y w xY wc c}}w )Nr   r-   r   r   c                *    | d   | d   j                   fS )Nr   ri   )r1   )xs    r%   <lambda>z_get_members.<locals>.<lambda>4  s    AaD!A$))CT r&   )key)dirrR   r   rA   r   r4   r   r   r2   rQ   MemberProtor1   r3   r   r   r6   appendsorted)r#   members_for_sortingr   is_computed_valueparent_attrmember_typeweightmember_docsmember_value
attr_valuehuman_readable_valuemembersorted_membersr   ms                  r%   r9   r9     sR   X 05	$	 5c9 E %cmmY?(,[9#$S)4
$Z0'@'L$.z:'/"0"<K#'L"&K#7L ("!" / <F#'FL""FF#34a05d  39TU,-da--I5  	 		0 .s   A7D>D 	DD)r$   r   r#   r   r(   None)r#   objectr(   r@   )r(   r@   )rc   r?   r(   r@   )r(   zinspect.FrameInfo | None)rz   r   re   r?   r(   bool)rz   z
ast.Moduler(   zast.expr | None)r#   r   r(   r?   )r   r?   r(   r?   )r6   r   r(   int)r#   r   r:   r@   r(   r@   )r6   r   r(   r@   )i,  )r   r?   r   r   r(   r?   )r#   r   r   r?   r(   r   )r#   r   r(   zlist[MemberProto])<__doc__
__future__r   rl   rO   rI   r   r[   typingr   r   r   r   r,   #streamlit.elements.lib.layout_utilsr   r	   streamlit.proto.DocString_pb2r
   r   r   r   %streamlit.runtime.caching.cache_utilsr   streamlit.runtime.metrics_utilr   ,streamlit.runtime.scriptrunner.script_runnerr   r   streamlit.runtime.secretsr   streamlit.string_utilr   streamlit.delta_generatorr   r   r   __annotations__r   r   rB   rE   rW   r4   r0   rb   compiler   ra   r   rn   rp   r2   r   r   r5   r   r   r   r9   r.   r&   r%   <module>r      s    G " 
   	  2 2  L E ? < 9 . 48G +:  % 9b, b,J7.>,:42"A/H BJJz"	9.. #@.8
*9r&   