0iLddlmZddlZddlZddlZddlZddlZddlZddlm Z ddlm Z ddl m Z ddl mZddl mZddl mZdd lmZdd lmZdd lmZd Ze j.Zd Zdd d!dZdd d"dZdd d"dZd#dZd#dZ d$dZd%dZ ejBd&dZ"d'dZ#ejBd(dZ$ d)dZ%d*dZ&d+dZ' d,dZ( d-dZ)d.dZ* d/d Z+y)0) annotationsN) Generator)Sequence) lang_base) envcontext)PatchesT)UNSET)Prefix) cmd_output)win_exerenv)z --no-savez --no-restorez--no-site-filez --no-environ)argsct||5t|5}ttg|||d|i\}}}ddddddj dS#1swY"xYw#1swY&xYw)Ncwd )in_env_r_code_in_tempfiler _rscript_execrstrip) codeprefixversionrrcli_optsf_outs E/opt/hc_python/lib/python3.12/site-packages/pre_commit/languages/r.py _execute_rrsv  "5d";q O & () ,0 69 3#<  ::d  #<"; s! A& AA&A# A&&A/c,t|||||tS)Nrrrrrr)r_RENV_ACTIVATED_OPTSrrrrrs r_execute_r_in_renvr$(s  &'#% c$t|||||dS)N)z --vanillar!)rr#s r_execute_vanilla_rr'2s  &'# r%c td|||S)Nzcat(renv::settings$r.version())rrrr$envdirrrs r_read_installed_versionr-<s )w  r%c td|||S)Nz cat(as.character(getRversion()))r)r*r+s r_read_executable_versionr/Ds *w  r%c"td|||y)Nz5renv::settings$r.version(as.character(getRversion()))r)r*r+s r_write_current_r_versionr1Ls?w r%ctj|t|}t|||}t |||}|dvrd|S||k7rd|d|Sy)Nr+>NULLzSHooks were installed with an unknown R version. R version for hook repo now set to z#Hooks were installed for R version z', but current R executable has version )renvironment_dirENVIRONMENT_DIRr-r/)rrr,r_version_installationr_version_current_executables r health_checkr9Vs  & &v HF4fg$<fg$ -$$@#A C  #? ?12H1IJ4+, . r%c #BKtj5}tjj |d}t |d5}|j ttj|ddd|dddy#1swYxYw#1swYyxYww)z To avoid quoting and escaping issues, avoid `Rscript [options] -e {expr}` but use `Rscript [options] path/to/file_with_expr.R` zscript.RwN) tempfileTemporaryDirectoryospathjoinopenwrite_inline_r_setuptextwrapdedent)rtmpdirfnamers rrrnsq  $ $ && VZ0 %  GGOHOOD$9: ; ' &   ' &s4B-B.B2 B> BB BBBcVdtjj|dfdtffS)NR_PROFILE_USERz activate.R RENV_PROJECT)r>r?r@r )venvs r get_env_patchrL{s+ 277<<l;<  r%c#Ktj|t|}tt |5ddddy#1swYyxYww)N)rr5r6rrL)rrr,s rrrs5  & &v HF M&) *  + * *s0A A A A A cJ|ddk(s|r|ddS|j|dfS)N-e)r?)entryris_locals r_prefix_if_file_entryrSs4  Qx48QRy E!H%''r%ctjjd}|ytjj |dt dS)NR_HOMERscriptbin)r>environgetr?r@r )r_homes rrrs8 ZZ^^H %F ~ww||FE79+=>>r%c|ddk7r td|ddk(rt|dkDr tdy t|dkDr td y ) zK Allowed entries: # Rscript -e expr # Rscript path/to/file rrVz entry must start with `Rscript`.rOrPz&You can supply at most one expression.zLThe only valid syntax is `Rscript -e {expr}`or `Rscript path/to/hook/script`N) ValueErrorlen)rQs r_entry_validater`sf  Qx9;<< Qx4 u:>EF F  Ua /   r%ctj|}t|t|||}|dgt||S)NrRr)shlexsplitr`rSr")rrQrrRcmdcmd_parts r_cmd_from_hookrgsE ++e CC$S&8DH F <) makedirsshutilcopyr?copytreer@ prefix_dirr'r1r$)rradditional_dependenciesenv_dirr_code_inst_environmentr_code_inst_adds rinstall_environmentrus $$S'2''IGKK$' KK K('2 OOFKK'gv)FG#((+,  8wG GFGLK ( r%cRtjd|g}dj|S)z Some behaviour of R cannot be configured via env variables, but can only be configured via R options once R has started. These are set here. z~ options( install.packages.compile.from.source = "never", pkgType = "binary" ) r)rDrEr@)r with_options rrCrCs2   K 99[ !!r%cRt||||}tj||||S)Nrb)require_serialcolor)rgr run_xargs)rrQr file_argsrRryrzres rrun_hookr}s3 x @C    %  r%)rstrrr rr~r Sequence[str]rr~rrreturnr~) rr~rr rr~rrrr~rr~)r,r~rr rr~rr~)r,r~rr rr~rNone)rr rr~rz str | None)rr~rzGenerator[str])rKr~rr)rr rr~rzGenerator[None])rQ list[str]rr rRboolrr)rr~)rQrrr) rr rQr~rrrRrrztuple[str, ...])rr rr~rqrrr)rr~rr~)rr rQr~rrr|rrRrryrrzrrztuple[int, bytes]), __future__r contextlibr>rcrmr<rDcollections.abcrr pre_commitrpre_commit.envcontextrrr pre_commit.prefixr pre_commit.utilr r r6basic_get_default_versionget_default_versionr"rr$r'r-r/r1r9contextmanagerrrLrrSrr`rgrurCr}rr%rrs_" %$ ,*'$&#99=?   !$ ,9 EH    =?!$,9EH =?!$,9EH #.1 0     ( ( ( (  (? & = = = =  =  =4 4 4 "/4  4 n""!   r%