U ʗRe%F@sBddlZddlZddlmZddlmZddlmZddlm Z m Z m Z m Z ddl mZmZmZddlmZdd lmZmZdd lmZe rdd lmZdd lmZed kZGdddeZGdddeZddddddddddddddddd d d!d"d#d$d%d&d'd(d)d*d+d,d-d.d/d0d1d2d3d4d5d6d7d8d9d:d;dd?d@dAdBdCdCdDdEdFdGdHdIdJdKdLdMdNdOdPdQdRdSdTdUdVdWdXdYdZd[d\d]d^d_d`dadbdcdcdddddedfdgdhdidjdkdldmdndodpdqdrdsdtdudvdwdxdydzd{d|d}d~d~ddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddۜZGdd݄de Z!e"dej#Z$eGddde Z%e&edddZ'deee(edddZ)e*dkr>ddl+m,Z,ddl-m.Z.dd lmZe,Z+e.dddZ-e-j/dddde-j/dddde-j/ddde-j/ddde-j/ddde0dde1DZ2e2D]\Z3Z4de4krqedde4dZ5e3d kre-6e5e3ede4dn2ee3Z7e-6e5e&e3ede4de7j8e7j9qe+:e-dS(N) rgb_to_hls)IntEnum) lru_cache) TYPE_CHECKING NamedTupleOptionalTuple)EIGHT_BIT_PALETTESTANDARD_PALETTEWINDOWS_PALETTE) ColorTriplet)Result rich_repr)DEFAULT_TERMINAL_THEME) TerminalThemeTextWindowsc@s.eZdZdZdZdZdZdZedddZ d S) ColorSystemz1One of the 3 color system supported by terminals.r returncCs d|jS)Nz ColorSystem.nameselfr/builddir/build/BUILDROOT/alt-python38-pip-22.2.1-2.el8.x86_64/opt/alt/python38/lib/python3.8/site-packages/pip/_vendor/rich/color.py__repr__szColorSystem.__repr__N) __name__ __module__ __qualname____doc__STANDARD EIGHT_BIT TRUECOLORWINDOWSstrr!rrrr rs rc@s2eZdZdZdZdZdZdZdZe ddd Z d S) ColorTypez$Type of color stored in Color class.rr rrrrcCs d|jS)Nz ColorType.rrrrr r!*szColorType.__repr__N) r"r#r$r%DEFAULTr&r'r(r)r*r!rrrr r+!sr+rrr  !()$%&'/+,-.0123X}789^;<>?@GBCDELIJQrNOPpSUzW[_`bcjefghilnotuvx{~)blackredgreenyellowbluemagentacyanwhite bright_black bright_red bright_green bright_yellow bright_bluebright_magenta bright_cyan bright_whitegrey0gray0 navy_blue dark_blueblue3blue1 dark_greendeep_sky_blue4 dodger_blue3 dodger_blue2green4 spring_green4 turquoise4deep_sky_blue3 dodger_blue1green3 spring_green3 dark_cyanlight_sea_greendeep_sky_blue2deep_sky_blue1 spring_green2cyan3dark_turquoise turquoise2green1 spring_green1medium_spring_greencyan2cyan1dark_red deep_pink4purple4purple3 blue_violetorange4grey37gray37medium_purple4 slate_blue3 royal_blue1 chartreuse4dark_sea_green4pale_turquoise4 steel_blue steel_blue3cornflower_blue chartreuse3 cadet_blue sky_blue3 steel_blue1 pale_green3 sea_green3 aquamarine3medium_turquoise chartreuse2 sea_green2 sea_green1 aquamarine1dark_slate_gray2 dark_magenta dark_violetpurple light_pink4plum4medium_purple3 slate_blue1yellow4wheat4grey53gray53light_slate_greylight_slate_gray medium_purplelight_slate_bluedark_olive_green3dark_sea_greenlight_sky_blue3 sky_blue2dark_sea_green3dark_slate_gray3 sky_blue1 chartreuse1 light_green pale_green1dark_slate_gray1red3medium_violet_redmagenta3 dark_orange3 indian_red hot_pink3medium_orchid3 medium_orchidmedium_purple2dark_goldenrod light_salmon3 rosy_browngrey63gray63medium_purple1gold3 dark_khaki navajo_white3grey69gray69light_steel_blue3light_steel_blueyellow3dark_sea_green2 light_cyan3light_sky_blue1 green_yellowdark_olive_green2dark_sea_green1pale_turquoise1 deep_pink3magenta2 hot_pink2orchidmedium_orchid1orange3 light_pink3pink3plum3violetlight_goldenrod3tan misty_rose3thistle3plum2khaki3light_goldenrod2 light_yellow3grey84gray84light_steel_blue1yellow2dark_olive_green1 honeydew2 light_cyan1red1 deep_pink2 deep_pink1magenta1 orange_red1 indian_red1hot_pink dark_orangesalmon1 light_coralpale_violet_red1orchid2orchid1orange1 sandy_brown light_salmon1 light_pink1pink1plum1gold1 navajo_white1 misty_rose1thistle1yellow1light_goldenrod1khaki1wheat1 cornsilk1grey100gray100grey3gray3grey7gray7grey11gray11grey15gray15grey19gray19grey23gray23grey27gray27grey30gray30grey35gray35grey39gray39grey42gray42grey46gray46grey50gray50grey54gray54grey58gray58grey62gray62grey66gray66grey70gray70grey74gray74grey78gray78grey82gray82grey85gray85grey89gray89grey93gray93c@seZdZdZdS)ColorParseErrorzThe color could not be parsed.N)r"r#r$r%rrrr rsrz?^ \#([0-9a-f]{6})$| color\(([0-9]{1,3})\)$| rgb\(([\d\s,]+)\)$ c@sZeZdZUdZeed<eed<dZee ed<dZ ee ed<ddd d Z e dd d Zeedd dZeedddZeedddZd0edee dddZee ddddZedddddZeeeeddd d!Zeddd"d#Zeed$d%edd&d'd(Zed$d%d1eeed)fd*d+d,Zed$d%edd-d.d/Z dS)2ColorzTerminal color definition.rtypeNnumbertripletrrcCsHddlm}ddlm}|d|jd|jjdd||dfd S) z)Dispays the actual color if Rich printed.r )Stylerz)stylertextrassemblerrlower)rrrrrr __rich__8s   zColor.__rich__ccs0|jV|jVd|jdfVd|jdfVdS)Nrr)rrrrrrrr __rich_repr__CszColor.__rich_repr__cCs |jtjkrtjStt|jS)z+Get the native color system for this color.)rr+r,rr&intrrrr systemIs z Color.systemcCs|jtjtjfkS)z7Check if the color is ultimately defined by the system.)rrr'r(rrrr is_system_definedPszColor.is_system_definedcCs |jtjkS)z&Check if the color is a default color.)rr+r,rrrr is_defaultUszColor.is_defaultTr)theme foregroundrcCs|dkr t}|jtjkr,|jdk s&t|jS|jtjkrP|jdk sFtt|jS|jtj krv|jdk sjt|j |jS|jtj kr|jdk stt |jS|jdkst|r|j S|jSdS)aGet an equivalent color triplet for this color. Args: theme (TerminalTheme, optional): Optional terminal theme, or None to use default. Defaults to None. foreground (bool, optional): True for a foreground color, or False for background. Defaults to True. Returns: ColorTriplet: A color triplet containing RGB components. N)rrr+r(rAssertionErrorr'rr r& ansi_colorsr)r foreground_colorbackground_color)rrrrrr get_truecolorZs        zColor.get_truecolor)rrcCs&|d|d|dkrtjntj|dS)zCreate a Color number from it's 8-bit ansi number. Args: number (int): A number between 0-255 inclusive. Returns: Color: A new Color instance. zcolor(rr8)rrr)r+r&r')clsrrrr from_ansiys  zColor.from_ansir )rrcCs||jtj|dS)zCreate a truecolor RGB color from a triplet of values. Args: triplet (ColorTriplet): A color triplet containing red, green and blue components. Returns: Color: A new color object. )rrr)hexr+r()rrrrr from_triplets zColor.from_triplet)rrrrcCs|tt|t|t|S)a@Create a truecolor from three color components in the range(0->255). Args: red (float): Red component in range 0-255. green (float): Green component in range 0-255. blue (float): Blue component in range 0-255. Returns: Color: A new color object. )rr r)rrrrrrr from_rgbs zColor.from_rgbcCs|dtjdS)zqGet a Color instance representing the default color. Returns: Color: Default color. default)rr)r+r,)rrrr rsz Color.defaulti)maxsize)rrcCs|}|}|dkr&||tjdSt|}|dk rV|||dkrJtjntj|dSt |}|dkrvt |d| \}}}|rt t |dddt |dd dt |d d d}||tj|d S|rt |} | d krt d |||| dkrtjntj| dS|d} t| dkr8t d|| \} } } t t | t | t | }tdd|Ds|t d|||tj|d SdS)zParse a color definition.r)rNr8)rrz is not a valid colorrrrr.)rrzcolor number must be <= 255 in ,rzexpected three components in css|]}|dkVqdS)rNr).0 componentrrr szColor.parse..z#color components must be <= 255 in )rstripr+r,ANSI_COLOR_NAMESgetr&r'RE_COLORmatchrgroupsr rr(splitlenall)rroriginal_color color_number color_matchcolor_24color_8 color_rgbrr componentsrrrrrr parsesV     z Color.parse.)rrc Cs$|j}|tjkr|rdndfS|tjkrh|j}|dk s:t|dkrFdnd\}}t|r\||n||fS|tjkr|j}|dk st|dkrdnd\}}t|r||n||fS|tjkr|jdk st|rdndd t|jfS|j dk st|j \}}}|rdndd t|t|t|fSdS) z)Get the ANSI escape codes for this color.3949Nr0)rCrF)R\384852) rr+r,r)rrr*r&r'r) rr_typerforebackrrrrrr get_ansi_codess&       zColor.get_ansi_codes)rrc Cs|jtj|fkr|S|tjkr|jtjkr|jdk s8t|jj \}}}t |||\}}}|dkrt |d}|dkrzd} n|dkrd} nd|} t |j tj| dSdd t |d d t |d t |d } t |j tj| dS|tjkrP|jtjkr|jdk st|j} n|jdk s&ttt|j} t| } t |j tj| dS|tjkr|jtjkr|jdk szt|j} n>|jdk st|jdkrt |j tj|jdStt|j} t| } t |j tj| dS|S) z7Downgrade a color system to a system with fewer colors.Ng?g9@rr8r>r)rrHg@r.)rr+r,rr'rr(rr normalizedrroundrrr&rr r r rr)r ) rrrrr_hlsgrayr rrrr downgradesH .     zColor.downgrade)NT)T)!r"r#r$r%r*__annotations__r+rrrrr rrrpropertyrrboolrrr classmethodrrfloatrrrrrrr%rrrr r+sF     3r) hex_colorrcCsNt|dkstdtt|dddt|dddt|ddd}|S)z+Parse six hex characters in to RGB triplet.r.zmust be 6 charactersrrr8r)r rr r)r+rrrr parse_rgb_hex4sr,?)color1color2 cross_faderc CsT|\}}}|\}}}tt||||t||||t||||} | S)z"Blend one RGB color in to another.)r r) r.r/r0r1g1b1r2g2b2 new_colorrrr blend_rgb=s  r8__main__)Console)TableFT) show_footer show_edgeellipsis)widthoverflowNumberrightr)justifyrNamer)rHexrRGBrccs|]\}}||fVqdS)Nr)rkvrrr rZsrZgreyz zon ")r-);platformrecolorsysrenumr functoolsrtypingrrrr _palettesr r r color_tripletr reprrrterminal_themerrrrrr)rr+r ExceptionrcompileVERBOSErrr*r,r*r8r"consoler:tabler; add_columnsorteditemscolorsr rZ color_celladd_rowrrrgbprintrrrr sR         p            "