U ã€C^øã@s~ddlmZmZddlZddlZddlZddlZddlZeej dƒrLej j ndZ e pVdZ e   ¡dkZdZGdd„deƒZejd ejd ejd ejd d d dd dd dd ddddddddddi ZejesÄdndejesÒdndejesàdnd ejesîd!nd"iZejdd kZereZeZejZne Ze!ZejZd;d$d%„Z"dd.d/„Z%d?d0d1„Z&d@d3d4„Z'd5d6„Z(d7d8„Z)d9d:„Z*dS)Aé)Úunicode_literalsÚprint_functionNÚencodingÚascii)Úutf8zutf-8ZANSI_COLORS_DISABLEDc@seZdZdZdZdZdZdS)ÚMESSAGESZgoodÚfailÚwarnÚinfoN)Ú__name__Ú __module__Ú __qualname__ÚGOODÚFAILÚWARNÚINFO©rrú//tmp/pip-install-6_kvzl1k/wasabi/wasabi/util.pyrsrééééÚredÚgreenZyellowZblueZpinkéZcyanéZwhiteéZgreyéÚblackéu✔z[+]u✘z[x]uâš z[!]uℹz[i]FcCs„t ||¡}t ||¡}t|||gƒs*|Sg}|r<| d¡|rJ| d¡|r^| d |¡¡|rr| d |¡¡d d |¡|¡S)auColor text by applying ANSI escape sequence. text (unicode): The text to be formatted. fg (unicode / int): Foreground color. String name or 0 - 256 (see COLORS). bg (unicode / int): Background color. String name or 0 - 256 (see COLORS). bold (bool): Format text in bold. underline (bool): Underline text. RETURNS (unicode): The formatted text. Ú1Ú4z38;5;{}z48;5;{}z [{}m{}ú;)ÚCOLORSÚgetÚanyÚappendÚformatÚjoin)ÚtextÚfgÚbgZboldZ underlineZstylesrrrÚcolorAs    r,éPcCs2|d}|t|ƒ}t|ƒ}tj||||dddS)a,Wrap text at given width using textwrap module. text (unicode): The text to wrap. wrap_max (int): Maximum line width, including indentation. Defaults to 80. indent (int): Number of spaces used for indentation. Defaults to 4. RETURNS (unicode): The wrapped text with line breaks. ú F)ÚwidthÚinitial_indentÚsubsequent_indentÚbreak_long_wordsÚbreak_on_hyphens)ÚlenÚ to_stringÚtextwrapÚfill)r)Zwrap_maxÚindentZ wrap_widthrrrÚwrap[s úr9é2ú...cCsHt|ƒ}t|ƒ|kr@t|dƒ}d |d|…||| d…¡S|SdS)a~Wrapper around `repr()` to print shortened and formatted string version. obj: The object to represent. max_len (int): Maximum string length. Longer strings will be cut in the middle so only the beginning and end is displayed, separated by ellipsis. ellipsis (unicode): Ellipsis character(s), e.g. "...". RETURNS (unicode): The formatted representation. rz{} {} {}N)Úreprr4Úintr')ÚobjÚmax_lenZellipsisÚstringZhalfrrrÚ format_reprps    rA©rrc Cs¢g}t d||¡}| ¡D]|\}}}} } |dkrD| |||…¡q|dkrn| t|| | …||dd¡q|dkr| t|||…||dd¡qd |¡S) a«Compare two strings and return a colored diff with red/green background for deletion and insertions. a (unicode): The first string to diff. b (unicode): The second string to diff. fg (unicode / int): Foreground color. String name or 0 - 256 (see COLORS). bg (tuple): Background colors as (insert, delete) tuple of string name or 0 - 256 (see COLORS). RETURNS (unicode): The formatted diff. NÚequalÚinsertr)r*r+ÚdeleterÚ)ÚdifflibZSequenceMatcherZ get_opcodesr&r,r() ÚaÚbr*r+ÚoutputÚmatcherÚopcodeZa0Za1Zb0Zb1rrrÚ diff_stringss ""rMcCs2|rd |¡nd}td ||¡|d}t|ƒ}|S)aGet user input from the command line via raw_input / input. description (unicode): Text to display before prompt. default (unicode or False/None): Default value to display with prompt. indent (int): Indentation in spaces. RETURNS (unicode): User input. z (default: {})rFz{}{}: )r8)r'r9Úinput_)Ú descriptionÚdefaultr8Ú additionalÚpromptZ user_inputrrrÚ get_raw_input˜srSÚreplacecCst|ƒ}| t|¡ d¡}|S)zíMangle non-supported characters, for savages with ASCII terminals. string (unicode): The string to escape. errors (unicode): The str.encode errors setting. Defaults to `"replace"`. RETURNS (unicode): The escaped string. r)r5ÚencodeÚENCODINGÚdecode)r@ÚerrorsrrrÚ locale_escape¦srYcCs,z| t¡WdStk r&YdSXdS)zöCheck if terminal can render unicode characters, e.g. special loading icons. Can be used to display fallbacks for ASCII terminals. string (unicode): The string to render. RETURNS (bool): Whether the terminal can render the text. TFN)rUrVÚUnicodeEncodeError)r@rrrÚ can_render²s  r[cCs8t t¡rdStjdko*tjdkp*dtjk}|s4dSdS)u Returns True if the running system's terminal supports ANSI escape sequences for color, formatting etc. and False otherwise. Inspired by Django's solution – hacky, but an okay approximation. RETURNS (bool): Whether the terminal supports ANSI colors. Fz Pocket PCÚwin32ZANSICONT)ÚosÚgetenvÚENV_ANSI_DISABLEDÚsysÚplatformÚenviron)Zsupported_platformrrrÚ supports_ansiÀs  ÿrccCs*t|tƒs&trt|ƒ d¡}nt|ƒ}|S)zÌMinimal compat helper to make sure text is unicode. Mostly used to convert Paths and other Python objects. text: The text/object to be converted. RETURNS (unicode): The converted string. r)Ú isinstanceÚ basestring_Ú IS_PYTHON_2ÚstrrW)r)rrrr5Òs  r5)NNFF)r-r)r:r;)rrB)Fr)rT)+Ú __future__rrr]r`r6rGÚ itertoolsÚhasattrÚstdoutrZSTDOUT_ENCODINGrVÚlowerZNO_UTF8r_Úobjectrrrrrr#ZICONSÚ version_inforfÚ basestringreÚ raw_inputrNÚ izip_longestÚ zip_longestrgÚinputr,r9rArMrSrYr[rcr5rrrrÚs~ ó    ü