*L iYddlZddlmZddlmZmZmZddlmZd dZ Gdde Z Gdd eZ dd Z d Zd Zy)N) PrettyPrinter) NotEncodablePlotlyJSONEncoder get_module)image_array_to_data_uric t|trd\}}n-t|trd\}}ntdt |zt ||kr|}n"t|d|dgzt|| dz}|dj |Dcgc] }t|c}z|z} dj tj| |d|d zzd|d zz j} | Scc}w) a  Return a string representation for of a list where list is elided if it has more than n elements Parameters ---------- v : list Input list threshold : Maximum number of elements to display Returns ------- str )[])()zInvalid value of type: %sNz...z,   )widthinitial_indentsubsequent_indent) isinstancelisttuple ValueErrortypelenjoinstrtextwrapwrapstrip) v threshold edgeitemsindentr open_char close_chardisp_vev_str v_wrappeds R/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/plotly/utils.py_list_repr_elidedr) s !T ( : Au  ( :4tAw>?? 1va m$w.a n1EE  6":a3q6":; ;j HE  &1*-!VaZ0   eg #;sC) c,eZdZdZdZedZdZy) ElidedWrapperz Helper class that wraps values of certain types and produces a custom __repr__() that may be elided and is suitable for use during pretty printing c.||_||_||_yN)rr!r)selfrrr!s r(__init__zElidedWrapper.__init__9s "ctd}t|ttfr"t |dkDrt|dt sy|rt||j ryt|tryy)NnumpyrTF)rrrrrdictndarrayr)rr2s r( is_wrappablezElidedWrapper.is_wrappable>sX7# a$ 'CFQJz!A$PT?U z!U]]3 3 r0c jtd}t|jttfr.t |j|j |j}|S|rt|j|jr|j}|jd it||j dd|jj}|jd}dd|jzzj|}|jd i||St|jtrlt!|jdkDr:dt#|jdd zd zt#|jd dzd zS|jjS|jjS)Nr2)rr!P)rr linewidthr rr z ... ir )rrrrrr)rr!r4get_printoptionsset_printoptionsr3__repr__splitrrrrepr)r.r2res orig_opts res_liness r(r>zElidedWrapper.__repr__Jsb7# dfftUm ,#$..CJ z$&&%--8..0I #E " " yDNNaSUV &&//#C $I# ++11)r;r0r(r+r+2s% #   #%r0r+ceZdZdZdZdZy)ElidedPrettyPrinterzF PrettyPrinter subclass that elides long lists/arrays/strings cd|jdd|_tj|g|i|y)Nr)poprrr/)r.argskwargss r(r/zElidedPrettyPrinter.__init__us,K5t5d5f5r0c tj|r-t||j|}|j||||||St j|||||||Sr-)r+r5r_formatr)r.valstreamr! allowancecontextlevel elided_vals r(rQzElidedPrettyPrinter._formatys^  % %c *&sDNNFCJ<< FFIwPUV V ((c669gu r0N)rDrErFrGr/rQr;r0r(rJrJps6r0rJc#Kt|tsy||f|jD]/\}}t|tst|||fzD]}|1yw)a General, node-yielding generator. Yields (node, path) tuples when it finds values that are dict instances. A path is a sequence of hashable values that can be used as either keys to a mapping (dict) or indices to a sequence (list). A path is always wrt to some object. Given an object, a path explains how to get from the top level of that object to a nested value in the object. :param (dict) node: Part of a dict to be traversed. :param (tuple[str]) path: Defines the path of the current node. :return: (Generator) Example: >>> for node, path in node_generator({'a': {'b': 5}}): ... print(node, path) {'a': {'b': 5}} () {'b': 5} ('a',) N)rr3itemsnode_generator)nodepathkeyrRitems r(rZrZsc0 dD ! *JJLS c4 &sDC6M:   s >AAc|D]}||} |S)aR Iteratively get on obj for each key in path. :param (list|dict) obj: The top-level object. :param (tuple[str]|tuple[int]) path: Keys to access parts of obj. :return: (*) Example: >>> figure = {'data': [{'x': [5]}]} >>> path = ('data', 0, 'x') >>> get_by_path(figure, path) [5] r;)objr\r]s r( get_by_pathras! #h Jr0ct|trZt|D]J\}}t|ttfrt |||<+t|t s< t |||<L|St|trt|jt|j}}t||D]f\}}t|ttfrt |||<nt|t r t |||<|j||t |<h|S#t $rYwxYw#t $rYrqsC KK<&R;%F;%|-(B*r0