8f_ ddlZddlmZddlmZddlmZmZmZm Z ej dkrddlm Z nddl m Z Gdde Z d ed e e d eefd Zd ed eedeedeed eef dZ dd ed eedeeed eefdZedkraddlmZeGddZededddedddedddgZeeedSdS)N)Fraction)ceil)castListOptionalSequence))ProtocolcJeZdZUdZdZeeed<dZeed<dZ eed<dS)Edgez1Any object that defines an edge (such as Layout).Nsizeratio minimum_size) __name__ __module__ __qualname____doc__rrint__annotations__rrw/builddir/build/BUILD/imunify360-venv-2.3.5/opt/imunify360/venv/lib/python3.11/site-packages/pip/_vendor/rich/_ratio.pyr r sI;;D(3-E3NNNL#rr totaledgesreturnc@d|D}t}d|vrdtt||D}|td|Dz }|dkrdt||DS||td|D}|D]$\}}||jz|jkr |j||<n8%|d} |D](\}}t ||jz| zd\} } | ||<)nd|vttt|S) aDivide total space to satisfy size, ratio, and minimum_size, constraints. The returned list of integers should add up to total in most cases, unless it is impossible to satisfy all the constraints. For instance, if there are two edges with a minimum size of 20 each and `total` is 30 then the returned list will be greater than total. In practice, this would mean that a Layout object would clip the rows that would overflow the screen height. Args: total (int): Total number of characters. edges (List[Edge]): Edges within total space. Returns: List[int]: Number of characters for each edge. c g|] }|jpd SN)r).0edges r z!ratio_resolve..%s 3 3 3Tdi4 3 3 3rNc&g|]\}\}}| ||fSr r)r!indexrr"s rr#z!ratio_resolve..,s1   #|d|DM||rc3K|]}|pdV dS)rNr)r!rs r z ratio_resolve..2s&<.5s;D$.2\$#(qtrc3.K|]\}}|jpdVdS)rN)r)r!_r"s rr'z ratio_resolve..;s,KKDDJO!KKKKKKrr) r enumeratezipsumrrdivmodrrr) rrsizes _Fractionflexible_edges remainingportionr%r" remainderrs r ratio_resolver5s" 4 3U 3 3 3EI %--  '0UE1B1B'C'C    C<>"%eU"3"3  ) sKKNKKKKK   *  KE4#t'888#0e 9" ! I- $ $ t"(4:)= )I1"M"Mi#e E %--H S 5 ! !!rratiosmaximumsvaluescTdt||D}t|}|s |ddS|}g}|j}t|||D]U\}} } |rB|dkr._s% L L L{udt"ee L L LrNr)r,r-appendminround) rr6r7r8 total_ratiototal_remainingresultr=rmaximumvalue distributeds r ratio_reducerFQsM Lc&(6K6K L L LFf++K aaayOF ]F!$VXv!>!>w  [1__guU_-D{-R'S'STTK F5;& ' ' ' { *O 5 KK F5MMMM Mrminimumscp|rdt||D}t|}|dks Jd|}g}|j}|dgt|z}n|}t||D]F\}} |dkr$t | t ||z|z } n|} || ||z}|| z}G|S)a<Distribute an integer total in to parts based on ratios. Args: total (int): The total to divide. ratios (List[int]): A list of integer ratios. minimums (List[int]): List of minimum values for each slot. Returns: List[int]: A list of integers guaranteed to sum to total. c g|] \}}|r|nd Sr;r)r!r_mins rr#z$ratio_distribute..s%PPP;5$4&%%QPPPrrzSum of ratios must be > 0)r,r-r=lenmaxr) rr6rGr@rAdistributed_totalr= _minimumsrminimumrEs rratio_distributerPqsQPP#fh:O:OPPPf++K ???7???O#%  %FC#f++%  fi00''w ??gtEO,Ck,Q'R'RSSKK)K{u ;& r__main__) dataclasscFeZdZUdZeeed<dZeed<dZeed<dS)ENrrrr) rrrrrrrrrrrrrTrTsC"hsm"""s crrTnrr )sys fractionsrmathrtypingrrrr version_infor pip._vendor.typing_extensionsr rr5rFrPr dataclassesrRrTresolvedprintr-rrrr_s; 111111111111v6666668:":"Xd^:"S :":":":"z S -1#Y@DS  #YBDH!! !S !-5d3i-@! #Y!!!!H z%%%%%%Y }S11T1a==!!D!Q--4A"OPPH E##h--r