Ë
    Bp±j’  ã                   óÄ   — d Z ddlZddlZddlmZ ddlmZ dZ ej                  dej                  «      Z	de
defd	„Zdefd
„Zedk(  r ej                   e«       «       yy)a“  Check that Pine Script files don't exceed the 64 plot/plotchar call limit.

TradingView enforces a maximum of 64 plot() + plotchar() outputs per
indicator/strategy. Exceeding this causes silent truncation of data exports.

Exits 1 and prints the offending file + count if the limit is exceeded.
Usage: python3 tools/check_pine_plot_budget.py [file ...]
  Defaults to strategies/*.pine if no args given.
é    N)Úglob)ÚPathé@   z:\bplot(?:char|shape|arrow|bar|candle)?\s*\(|\bbgcolor\s*\(ÚpathÚreturnc                 ó  — t        | «      j                  dd¬«      }g }|j                  «       D ](  }|j                  t	        j
                  dd|«      «       Œ* dj                  |«      }t        t        j                  |«      «      S )Nzutf-8Úreplace)ÚencodingÚerrorsz//.*Ú Ú
)
r   Ú	read_textÚ
splitlinesÚappendÚreÚsubÚjoinÚlenÚPLOT_REÚfindall)r   ÚtextÚlinesÚlineÚcleans        úm/Users/jameslopez/projects/TradingBot25/.worktrees/mlp-comparable-measurement/tools/check_pine_plot_budget.pyÚcount_plot_callsr      sl   € Ü�‹:×Ñ¨¸ÐÓC€Dà€EØ—‘Ö!ˆØ�‰”R—V‘V˜G R¨Ó.Õ/ð "à�I‰I�eÓ€EÜŒw�‰˜uÓ%Ó&Ð&ó    c                  óÂ  — t         j                  dd  xs t        t        d«      «      } | st	        dt         j
                  ¬«       yd}| D ]{  }t        |«      j                  «       sŒt        |«      }|t        kD  r&t	        d|› �«       t	        d|› d	t        › �«       d
}ŒWt        |z
  }t	        d|› d|› dt        › d|› d�	«       Œ} |rt	        dt        › d�«       yy)Né   zstrategies/*.pinezNo Pine files found.)Úfiler   Fu   â�Œ  z    u-    plot/plotchar calls â€” exceeds TV limit of Tu   âœ…  z  (Ú/z plots, z remaining)zA
Fix: remove or combine plot() / plotchar() calls to stay within Ú.)
ÚsysÚargvÚsortedr   ÚprintÚstderrr   Úis_filer   Ú
PLOT_LIMIT)ÚtargetsÚover_budgetr   ÚcountÚ	remainings        r   Úmainr.   $   sà   € Ü�h‰h�q�rˆlÒ?œf¤TÐ*=Ó%>Ó?€GÙÜÐ$¬3¯:©:Õ6Øà€KÛˆÜ�D‹z×!Ñ!Ô#ØÜ  Ó&ˆØ”:ÒÜ�E˜$˜�.Ô!Ü�D˜˜ÐLÌZÈLÐYÔZØ‰Kä" UÑ*ˆIÜ�E˜$˜˜s 5 '¨¬:¨,°h¸y¸kÈÐUÕVð ñ ÜÐRÔS]ÐR^Ð^_Ð`ÔaØàr   Ú__main__)Ú__doc__r   r#   r   Úpathlibr   r)   ÚcompileÚ	MULTILINEr   ÚstrÚintr   r.   Ú__name__Úexit© r   r   Ú<module>r9      sw   ðñó 
Û 
Ý Ý à€
ð ˆ"�*‰*ØAØ‡L�Ló€ð'˜3ð ' 3ó 'ðˆcó ð4 ˆzÒØ€C‡H�H‰T‹VÕð r   