B eð]S!ã@s°ddlmZmZddlmZddlmZddlmZddl Z ddl Z ddl Z ddl Z ddl mZmZddlmZmZmZmZdd lmZmZmZdd lmZGd d „d eƒZdS) é)Úunicode_literalsÚprint_function)ÚCounter)Úcontextmanager)ÚProcessNé)ÚtableÚrow)ÚwrapÚ supports_ansiÚ can_renderÚ locale_escape)ÚMESSAGESÚCOLORSÚICONS)Úcolorc @seZdZd&d d „Zed d „ƒZd'dd„Zd(dd„Zd)dd„Zd*dd„Z d+dd„Z d,dd„Z dd„Z dd„Z ed-d d!„ƒZd.d"d#„Zd/d$d%„ZdS)0ÚPrinterTFNéPrõ⠙⠹⠸⠼⠴⠦⠧⠇â ú|/-\ÚWASABIc Cs²t d | ¡d¡} t d | ¡d¡} tƒ|_|o4| |_||_tƒoH| |_| pR| |_ | |_ ||_ ||_ t tƒ|_t tƒ|_|rŒ|j |¡|rœ|j |¡t|ƒr¨|n||_dS)aInitialize the command-line printer. pretty (bool): Pretty-print output (colors, icons). no_print (bool): Don't actually print, just return. colors (dict): Add or overwrite color values, name mapped to value. icons (dict): Add or overwrite icons. Name mapped to unicode icon. line_max (int): Maximum line length (for divider). indent (int): Number of spaces to use for indentation. animation (unicode): Steps of loading animation for loading() method. animation_ascii (unicode): Alternative animation for ASCII terminals. hide_animation (bool): Don't display animation, e.g. for logs. ignore_warnings (bool): Do not output messages of type MESSAGE.WARN. env_prefix (unicode): Prefix for environment variables, e.g. WASABI_LOG_FRIENDLY. RETURNS (Printer): The initialized printer. z{}_LOG_FRIENDLYFz {}_NO_PRETTYN)ÚosÚgetenvÚformatrÚ_countsÚprettyÚno_printr Ú show_colorÚhide_animationÚignore_warningsÚline_maxÚindentÚdictrÚcolorsrÚiconsÚupdater Úanim)Úselfrrr#r$r r!Z animationZanimation_asciirrZ env_prefixZenv_log_friendlyZ env_no_pretty©r(ú2/tmp/pip-install-b8evvk6i/wasabi/wasabi/printer.pyÚ__init__s"      zPrinter.__init__cCs|jS)z•Get the counts of how often the special printers were fired, e.g. MESSAGES.GOOD. Can be used to print an overview like "X warnings". )r)r'r(r(r)ÚcountsCszPrinter.countsÚcCs|j||tj|||dS)zPrint a success message.)ÚstyleÚshowÚspacedÚexits)Ú_get_msgrÚGOOD)r'ÚtitleÚtextr.r/r0r(r(r)ÚgoodJsz Printer.goodcCs|j||tj|||dS)zPrint an error message.)r-r.r/r0)r1rZFAIL)r'r3r4r.r/r0r(r(r)ÚfailPsz Printer.failcCs|j||tj|||dS)zPrint a warning message.)r-r.r/r0)r1rÚWARN)r'r3r4r.r/r0r(r(r)ÚwarnVsz Printer.warncCs|j||tj|||dS)zPrint an error message.)r-r.r/r0)r1rÚINFO)r'r3r4r.r/r0r(r(r)Úinfo\sz Printer.infoc CsØ|sdS|jr^|j |¡}|j |¡}|r>td ||¡ƒ ¡}|jrPt||d}t ||j d}|rxd |t ||j d¡}|dk s„|rŽd |¡}|j s |s t |ƒ|dk rÆt j ¡t j ¡t  |¡|j sÐ|rÔ|SdS)a'Print a message. title (unicode): The main text to print. text (unicode): Optional additional text to print. color (unicode / int): Foreground color. icon (unicode): Name of icon to add. spaced (unicode): Whether to add newlines around the output. show (bool): Whether to print or not. Can be used to only output messages under certain condition, e.g. if --verbose flag is set. no_print (bool): Don't actually print, just return. exits (int): Perform a system exit. Nz{} {})Zfg)r!z{} {}z {} )rr#Úgetr$r rÚstriprÚ_colorr r!rÚprintÚsysÚstdoutÚflushÚstderrÚexit) r'r3r4rÚiconr/r.rr0r(r(r)r4bs,          z Printer.textú=cCsÈt|ƒdkrtd |¡ƒ‚|jr²|j |¡}|rDtd ||¡ƒ ¡}|tt |j t|ƒƒdƒd}|rtd |¡nd}t dj||dd d }t|ƒ|j kr²|||j t|ƒ}|j r¼|St |ƒd S) aiPrint a divider with a headline: ============================ Headline here =========================== text (unicode): Headline text. If empty, only the line is printed. char (unicode): Line character to repeat, e.g. =. show (bool): Whether to print or not. icon (unicode): Optional icon to display with title. rz9Divider chars need to be one character long. Received: {}z{} {}éz {} r,z {deco}{text}{deco})Údecor4T)ZboldN)ÚlenÚ ValueErrorrrr$r;r r<ÚintÚroundr r=rr>)r'r4Úcharr.rDrGr(r(r)Údividers"  "zPrinter.dividercKsN| dd¡}d|kr|j|d<t|f|Ž}|r8| |¡|jrB|St|ƒdS)zäPrint data as a table. data (iterable / dict): The data to render. Either a list of lists (one per row) or a dict for two-column tables. kwargs: Table settings. See tables.table for details. r3Nr!)Úpopr!rrMrr>)r'ÚdataÚkwargsr3r4r(r(r)r­s    z Printer.tablecKs4d|kr|j|d<t|f|Ž}|jr(|St|ƒdS)z‘Print a table row. data (iterable): The individual columns to format. kwargs: Row settings. See tables.row for details. r!N)r!r rr>)r'rOrPr4r(r(r)r ¾s   z Printer.rowú Loading...c cs®|jrdVnœ|jr$t|ƒdVn†tj ¡t|j|fd}| ¡y dVWn:t k rŠ}z|  ¡tj  d¡|‚Wdd}~XYnX|  ¡tj  d¡tj ¡dS)N)ÚtargetÚargsÚ z ) rrr>r?r@rArÚ_spinnerÚstartÚ ExceptionÚ terminateÚwrite)r'r4ÚtÚer(r(r)ÚloadingËs"    zPrinter.loadingcCsBx|jr|tjkrd}|j|d7<|j|||||||dS)NFr)rrDr.r/r0)rrr7rr4)r'r3r4r-r.r/r0r(r(r)r1çs zPrinter._get_msg) TFNNrrrrFFr)r,r,TFN)r,r,TFN)r,r,TFN)r,r,TFN)r,r,NNFTFN)r,rETN)rQ)rQ)NNFN)Ú__name__Ú __module__Ú __qualname__r*Úpropertyr+r5r6r8r:r4rMrr rr\rUr1r(r(r(r)rs> $      %    r)Ú __future__rrÚ collectionsrÚ contextlibrÚmultiprocessingrr]r?r_rÚtablesrr Úutilr r r r rrrrr=Úobjectrr(r(r(r)Ús