Ë
    Ìi�_  ã                   óÐ  — d dl Zd dlZd dlZd dlZd dlZd dlZd dlZd dlZd dl	Z	d dl
Z
d dlZd dlZd dlZd dlZd dlmZ d dlmZmZmZmZmZmZmZmZmZ d dlZd dlZd dlmZ d dlm Z m!Z!m"Z"m#Z#m$Z$ d dlm%Z% d dl&m'Z'm(Z(m)Z) d dl*m+Z+ d d	l,m-Z- ej\                  d
k(  r	d dl/m0Z0m1Z1 ndZ0dZ1de2de3fd„Z4ejj                   G d„ d«      «       Z6ejj                   G d„ d«      «       Z7e(jp                   G d„ de)«      «       Z9 e'e9«      	 ddde2dee2   de2dee-   deee2ef      f
d„«       Z:ejj                   G d„ d«      «       Z;ejj                   G d„ d«      «       Z<e(jp                   G d„ de)«      «       Z= e'e=«      dede2d e3de2fd!„«       Z>ej~                  dddfd"„«       Z@e@j‚                  de2ddfd#„«       ZBe@j‚                  deddfd$„«       ZBdgde2d%e2d&e3de3fd'„ZCd(e2d)e2ddfd*„ZDde3fd+„ZEejj                   G d,„ d-«      «       ZFe(jp                   G d.„ d/e)«      «       ZG e'eG«      dhde2d%e2de3fd0„«       ZHde2dee2ef   fd1„ZIde2d2ee2ef   de3fd3„ZJd4ee2gef   de2d5eeeKef   fd6„ZLd7e2d8e2de2fd9„ZMde2ddfd:„ZNde2de2fd;„ZOde3fd<„ZPde2de2fd=„ZQde2ddfd>„ZRde2de3fd?„ZSde2de3fd@„ZTde2fdA„ZUd5eKdBe2dCee2   defdD„ZVd5eKdBe2dCee2   defdE„ZWd5eKdBe2dCee2   defdF„ZXd5eKdBe2dCee2   defdG„ZYd5eKdBe2dCee2   defdH„ZZdddBe2dCee2   dIeee2ef      dee[e[f   fdJ„Z\	 dddKe2de2dLeee]e^f      ddfdM„Z_	 dddKe2de2dLeee]ee]e]f   ee]df   f      ddfdN„Z`didOe2dPe2dQe3ddfdR„ZadjdSejÄ                  de2ddfdT„ZcdddUe2dVe2dWee2   ddfdX„ZddY„ ZedZ„ Zfd[„ Zgd\„ Zhejj                   G d]„ d^«      «       Ziejj                   G d_„ d`«      «       Zje(jp                   G da„ dbe)«      «       Zk e'ek«      dee2e2f   fdc„«       Zly)ké    N)ÚPath)	ÚAnyÚCallableÚDictÚListÚNoReturnÚOptionalÚTupleÚTypeÚUnion)Ú
fire_event)ÚSystemCouldNotWriteÚSystemExecutingCmdÚSystemStdOutÚSystemStdErrÚSystemReportReturnCode)ÚDbtInternalError)Úrecord_functionÚRecorderÚRecord)Úconnection_exception_retry)ÚPathSpecÚwin32)ÚWinDLLÚc_boolÚpathÚreturnc                 ó"   — d| vxr
 d| vxr d| vS )Nzdbt/includezdbt/include/global_projectz/plugins/postgres/dbt/include/© ©r   s    úZ/var/www/html/strategist-ai/venv/lib/python3.12/site-packages/dbt_common/clients/system.pyÚ_record_pathr"   )   s+   € ð 	˜TÐ!ò 	9Ø(°Ð4ò	9à,°DÐ8ð	ó    c            
       óf   — e Zd ZU eed<   ee   ed<   eed<   	 d	dedee   dedee   fd„Zde	fd„Z
y)
ÚFindMatchingParamsÚ	root_pathÚrelative_paths_to_searchÚfile_patternNÚignore_specc                 ód   — || _         t        |«      }|j                  «        || _        || _        y ©N)r&   ÚlistÚsortr'   r(   )Úselfr&   r'   r(   r)   Úrpss         r!   Ú__init__zFindMatchingParams.__init__:   s/   € ð #ˆŒÜÐ+Ó,ˆØ�‰Œ
Ø(+ˆÔ%Ø(ˆÕr#   r   c                 ó,   — t        | j                  «      S r+   )r"   r&   ©r.   s    r!   Ú_includezFindMatchingParams._includeG   s   € ô ˜DŸN™NÓ+Ð+r#   r+   )Ú__name__Ú
__module__Ú__qualname__ÚstrÚ__annotations__r   r	   r   r0   Úboolr3   r   r#   r!   r%   r%   2   s[   … àƒNØ" 3™iÓ'ØÓð &*ñ)àð)ð #' s¡)ð)ð ð	)ð
 ˜c‘]ó)ð,˜$ô ,r#   r%   c                   ó(   — e Zd ZU eeeef      ed<   y)ÚFindMatchingResultÚmatchesN)r4   r5   r6   r   r   r7   r   r8   r   r#   r!   r;   r;   M   s   … à�$�s˜C�x‘.Ñ!Ô!r#   r;   c                   ó   — e Zd ZdZeZeZy)ÚFindMatchingRecordz@Record of calls to the directory search function find_matching()N)r4   r5   r6   Ú__doc__r%   Ú
params_clsr;   Ú
result_clsr   r#   r!   r>   r>   R   s   „ áJà#€JØ#�Jr#   r>   r&   r'   r(   r)   c           
      óÐ  — g }t         j                  j                  | «      } t        j                  |«      }t        j                  |t
        j                  «      }|D �]  }t         j                  j                  | |«      }t        j                  |«      }	|	D ]È  \  }
}}|D ]½  }|j                  |«      sŒt         j                  j                  |
|«      }t         j                  j                  ||«      }t         j                  j                  ||«      }t         j                  j                  |«      }|r|j                  |«      rŒ¨|j                  ||||dœ«       Œ¿ ŒÊ �Œ |S )aw  Return file info from paths and patterns.

    Given an absolute `root_path`, a list of relative paths to that
    absolute root path (`relative_paths_to_search`), and a `file_pattern`
    like '*.sql', returns information about the files. For example:

    > find_matching('/root/path', ['models'], '*.sql')

      [ { 'absolute_path': '/root/path/models/model_one.sql',
          'relative_path': 'model_one.sql',
          'searched_path': 'models' },
        { 'absolute_path': '/root/path/models/subdirectory/model_two.sql',
          'relative_path': 'subdirectory/model_two.sql',
          'searched_path': 'models' } ]
    )Úsearched_pathÚabsolute_pathÚrelative_pathÚmodification_time)Úosr   ÚnormpathÚfnmatchÚ	translateÚreÚcompileÚ
IGNORECASEÚjoinÚwalkÚmatchÚrelpathÚgetmtimeÚ
match_fileÚappend)r&   r'   r(   r)   ÚmatchingÚregexÚreobjÚrelative_path_to_searchÚabsolute_path_to_searchÚwalk_resultsÚcurrent_pathÚsubdirectoriesÚlocal_filesÚ
local_filerD   rE   Úrelative_path_to_rootrF   s                     r!   Úfind_matchingr`   Z   s:  € ð, €HÜ—‘× Ñ  Ó+€IÜ×Ñ˜lÓ+€EÜ�J‰J�uœbŸm™mÓ,€Eà#;ó !Ðô #%§'¡'§,¡,¨yÐ:QÓ"RÐÜ—w‘wÐ6Ó7ˆà9Eò 	Ñ5ˆL˜.¨+ð
 *ò �
ð —{‘{ :Ô.Øä "§¡§¡¨\¸:Ó F�Ü "§¡§¡°Ð?VÓ W�Ü(*¯©¯©Ð5LÈmÓ(\Ð%ä$&§G¡G×$4Ñ$4°]Ó$CÐ!á"¨+×*@Ñ*@ÐAVÕ*WØ—O‘Oà-DØ-:Ø-:Ø1Bñ	õñò	ð!ðF €Or#   c                   ó2   — e Zd ZU eed<   dZeed<   defd„Zy)ÚLoadFileParamsr   TÚstripr   c                 ó,   — t        | j                  «      S r+   ©r"   r   r2   s    r!   r3   zLoadFileParams._include    ó   € ô ˜DŸI™IÓ&Ð&r#   N)r4   r5   r6   r7   r8   rc   r9   r3   r   r#   r!   rb   rb   ›   s   … à
ƒIØ€Eˆ4Óð'˜$ô 'r#   rb   c                   ó   — e Zd ZU eed<   y)ÚLoadFileResultÚcontentsN)r4   r5   r6   r7   r8   r   r#   r!   rh   rh   ¦   s   … à„Mr#   rh   c                   ó   — e Zd ZdZeZeZy)ÚLoadFileRecordzRecord of file load operationN)r4   r5   r6   r?   rb   r@   rh   rA   r   r#   r!   rk   rk   «   s   „ á'à€JØ�Jr#   rk   rc   c                 óÀ   — t        | «      } t        | d«      5 }|j                  «       j                  d«      }d d d «       |rj	                  «       }S # 1 sw Y   ŒxY w)NÚrbúutf-8)Úconvert_pathÚopenÚreadÚdecoderc   )r   rc   ÚhandleÚ	to_returns       r!   Úload_file_contentsru   ³   sZ   € ä˜Ó€DÜ	ˆd�DÓ	ð 2˜VØ—K‘K“M×(Ñ(¨Ó1ˆ	÷2ñ Ø—O‘OÓ%ˆ	àÐ÷2ð 2ús   ˜ AÁAc                 ó2   — t        dt        | «      › d�«      ‚)zÛHandle directory creation with threading.

    Make a directory and any intermediate directories that don't already
    exist. This function handles the case where two threads try to create
    a directory at once.
    zCan not create directory from ú )r   Útyper    s    r!   Úmake_directoryry   ¿   s   € ô Ð;¼DÀ»J¸<ÀqÐIÓ
JÐJr#   c                 óò   — t        | «      } t        j                  j                  | «      s	 t        j                  | «       y y # t
        $ r*}|j                  t        j                  k(  rn|‚Y d }~y d }~ww xY wr+   )ro   rG   r   ÚexistsÚmakedirsÚOSErrorÚerrnoÚEEXIST)r   Úes     r!   Ú_r�   Ê   sa   € ä˜Ó€DÜ�7‰7�>‰>˜$Ôð	Ü�K‰K˜Õð  øô
 ò 	Ø�w‰wœ%Ÿ,™,Ò&Øà�ô ûð	ús   ¬A Á	A6Á A1Á1A6c                 ó*   — | j                  dd¬«       y )NT)ÚparentsÚexist_ok)Úmkdirr    s    r!   r�   r�   Ù   s   € à‡J�J�t d€JÕ+r#   ri   Ú	overwritec                 óÂ   — |st         j                  j                  | «      s2t        | «      } t	        | d«      5 }|j                  |«       ddd«       yy# 1 sw Y   yxY w)z¯Make a file with `contents` at `path`.

    Make a file at `path` assuming that the directory it resides in already
    exists. The file is saved with contents `contents`
    ÚwNTF)rG   r   r{   ro   rp   Úwrite)r   ri   r†   Úfhs       r!   Ú	make_filer‹   Þ   sP   € ñ œŸ™Ÿ™ tÔ,Ü˜DÓ!ˆÜ�$˜‹_ð 	 Ø�H‰H�XÔ÷	àà÷		àús   ¹AÁAÚsourceÚ	link_pathc                 ó€   — t        «       st        j                  j                  «       ‚t	        j
                  | |«       y)z6Create a symlink at `link_path` referring to `source`.N)Úsupports_symlinksÚ
dbt_commonÚ
exceptionsÚSymbolicLinkErrorrG   Úsymlink)rŒ   r�   s     r!   Úmake_symlinkr”   í   s+   € äÔä×#Ñ#×5Ñ5Ó7Ð7ä‡J�Jˆv�yÕ!r#   c                  ó(   — t        t        dd «      d uS )Nr“   )ÚgetattrrG   r   r#   r!   r�   r�   ö   s   € Ü”2�y $Ó'¨tÐ3Ð3r#   c                   ó.   — e Zd ZU eed<   eed<   defd„Zy)ÚWriteFileParamsr   ri   r   c                 ó,   — t        | j                  «      S r+   re   r2   s    r!   r3   zWriteFileParams._includeÿ   rf   r#   N)r4   r5   r6   r7   r8   r9   r3   r   r#   r!   r˜   r˜   ú   s   … à
ƒIØƒMð'˜$ô 'r#   r˜   c                   ó   — e Zd ZdZeZdZy)ÚWriteFileRecordz!Record of a file write operation.N)r4   r5   r6   r?   r˜   r@   rA   r   r#   r!   r›   r›     s   „ á+à €JØ�Jr#   r›   c           
      ó¦  — t        | «      } 	 t        t        j                  j	                  | «      «       t        | dd¬«      5 }|j                  t        |«      «       d d d «       y# 1 sw Y   yxY w# t        $ rT}t        j                  dk(  r6t        |dd«      dk(  rd}nd	}t        t        | |t        |«      ¬
«      «       n‚ Y d }~yd }~ww xY w)Nrˆ   rn   ©ÚencodingÚntÚwinerrorr   é   úPath was too longúPath was possibly too long©r   ÚreasonÚexcT)ro   ry   rG   r   Údirnamerp   r‰   r7   Ú	ExceptionÚnamer–   r   r   )r   ri   Úfr¦   r¥   s        r!   Ú
write_filer«     s¿   € ä˜Ó€DðÜ”r—w‘w—‘ tÓ,Ô-Ü�$˜ gÔ.ð 	#°!Ø�G‰G”C˜“MÔ"÷	#ð. ÷/	#ð. ûô+ ò ô �7‰7�dŠ?ô
 �s˜J¨Ó*¨aÒ/Ø,‘à5�ô Ô*°¸VÌÈSËÔRÕSàó Tð ûð+ús6   �6A3 ÁA'ÁA3 Á'A0Á,A3 Á0A3 Á3	CÁ<A
CÃCc                 ó†   — t        | «      } t        | d«      5 }t        j                  |«      cd d d «       S # 1 sw Y   y xY w)NÚr)ro   rp   ÚjsonÚload)r   rª   s     r!   Ú	read_jsonr°   ,  s7   € Ü˜Ó€DÜ	ˆd�C‹ð ˜AÜ�y‰y˜‹|÷÷ ò ús	   ˜7·A Údatac           
      óæ  — t        | «      } 	 t        t        j                  j	                  | «      «       t        | dd¬«      5 }t        j                  ||t        j                  j                  j                  ¬«       d d d «       y# 1 sw Y   yxY w# t        $ rT}t        j                  dk(  r6t        |dd«      dk(  rd	}nd
}t        t!        | |t#        |«      ¬«      «       n‚ Y d }~yd }~ww xY w)Nrˆ   rn   r�   )ÚclsrŸ   r    r   r¡   r¢   r£   r¤   T)ro   ry   rG   r   r§   rp   r®   Údumpr�   Úutilsrž   ÚJSONEncoderr¨   r©   r–   r   r   r7   )r   r±   rª   r¦   r¥   s        r!   Ú
write_jsonr·   2  sÎ   € Ü˜Ó€DðÜ”r—w‘w—‘ tÓ,Ô-Ü�$˜ gÔ.ð 	J°!Ü�I‰I�d˜A¤:×#3Ñ#3×#<Ñ#<×#HÑ#HÕI÷	Jð ÷	Jð ûô ò 	ä�7‰7�dŠ?Ü�s˜J¨Ó*¨aÒ/Ø,‘à5�ÜÔ*°¸VÌÈSËÔRÕSàó Tð ûð	ús6   �6B Á;BÁ>B ÂBÂB ÂB Â	C0ÂA
C+Ã+C0Úfuncr¦   c                 ó¢   — |d   }|j                   t         j                  k(  r-t        j                  |t        j
                  «        | |«       y ‚ )Né   )r~   ÚEACCESrG   ÚchmodÚstatÚS_IWUSR)r¸   r   r¦   Úexception_vals       r!   Ú_windows_rmdir_readonlyrÀ   E  s9   € Ø˜‘F€MØ×ÑœeŸl™lÒ*Ü
�‰�”t—|‘|Ô$ÙˆT�
àr#   Úpath_to_resolveÚ	base_pathc                 ó¶   — t         j                  j                  t         j                  j                  |t         j                  j	                  | «      «      «      S )zÓIf path_to_resolve is a relative path, create an absolute path with base_path as the base.

    If path_to_resolve is an absolute path or a user path (~), just
    resolve it to an absolute path and return.
    )rG   r   ÚabspathrN   Ú
expanduser)rÁ   rÂ   s     r!   Úresolve_path_from_baserÆ   N  s5   € ô �7‰7�?‰?œ2Ÿ7™7Ÿ<™<¨	´2·7±7×3EÑ3EÀoÓ3VÓWÓXÐXr#   c                 ó€   — t        | «      } t        j                  dk(  rt        }nd}t	        j
                  | |¬«       y)zçRecursively deletes a directory.

    Includes an error handler to retry with
    different permissions on Windows. Otherwise, removing directories (eg.
    cloned via git) can cause rmtree to throw a PermissionError exception
    r   N©Úonerror)ro   ÚsysÚplatformrÀ   ÚshutilÚrmtree)r   rÉ   s     r!   ÚrmdirrÎ   W  s2   € ô ˜Ó€DÜ
‡|�|�wÒÜ)‰àˆä
‡M�M�$ Ö(r#   c                 ó¢  — t         j                  j                  | «      } | j                  d«      sJ| j                  d«      r9t         j                  j	                  t        j
                  «       «      d   }|| z   } t         j                  j	                  | «      d   s2t         j                  j                  t        j
                  «       | «      } | S )zVGiven a windows path, prepare it for use by making sure it is absolute and normalized.z\\ú\r   )rG   r   rH   Ú
startswithÚ
splitdriveÚgetcwdrN   )r   Úcurdrives     r!   Ú_win_prepare_pathrÕ   g  s�   € ä�7‰7×Ñ˜DÓ!€Dð �?‰?˜6Ô" t§¡°tÔ'<Ü—7‘7×%Ñ%¤b§i¡i£kÓ2°1Ñ5ˆØ˜$‰ˆô �7‰7×Ñ˜dÓ# AÒ&Ü�w‰w�|‰|œBŸI™I›K¨Ó.ˆà€Kr#   c                  óÄ   — t         j                  dk7  ry	 t        d«      } t	        | d«      syt
        | j                  _        | j                  «       S # t        $ r Y yw xY w)Nr   TÚntdllFÚRtlAreLongPathsEnabled)rÊ   rË   r   r}   Úhasattrr   rØ   Úrestype)Údlls    r!   Ú_supports_long_pathsrÜ   ~  s`   € Ü
‡|�|�wÒØð	Ü˜“/ˆCô �sÐ4Ô5Øä-3ˆ×"Ñ"Ô*Ø×)Ñ)Ó+Ð+øô ò 	Ùð	ús   –A Á	AÁAc                 óª   — t        | «      dk  r| S t        «       r| S d}| j                  |«      r| S t        | «      } | j                  |«      s|| z   } | S )zËHandle path length for windows.

    Convert a path that dbt has, which might be >260 characters long, to one
    that will be writable/readable on Windows.

    On other platforms, this is a no-op.
    éú   z\\?\)ÚlenrÜ   rÑ   rÕ   )r   Úprefixs     r!   ro   ro   “  s[   € ô ˆ4ƒy�3‚ØˆÜÔØˆà€Fà‡��vÔØˆä˜TÓ"€Dð �?‰?˜6Ô"Ø˜‰}ˆØ€Kr#   c                 óD   — t        | «      } t        j                  | «       y r+   )ro   rG   Úremover    s    r!   Úremove_filerã   °  s   € Ü˜Ó€DÜ‡I�Iˆd…Or#   c                 óV   — t        | «      } t        j                  j                  | «      S r+   )ro   rG   r   Úlexistsr    s    r!   Úpath_existsræ   µ  s   € Ü˜Ó€DÜ�7‰7�?‰?˜4Ó Ð r#   c                 óV   — t        | «      } t        j                  j                  | «      S r+   )ro   rG   r   Úislinkr    s    r!   Úpath_is_symlinkré   º  s   € Ü˜Ó€DÜ�7‰7�>‰>˜$ÓÐr#   c                  óT   — t         j                  dk(  ryt         j                  dk(  ryy)Nr   ÚstartÚdarwinrp   zxdg-open)rÊ   rË   r   r#   r!   Úopen_dir_cmdrí   ¿  s%   € ä
‡|�|�wÒØä	�‰˜Ò	!Øð r#   ÚcwdÚcmdc                 ó8  — | j                   t         j                  k(  rd}nZ| j                   t         j                  k(  rd}n:| j                   t         j                  k(  rd}ndj	                  t        | «      «      }t        j                  j                  |||«      ‚)NzDirectory does not existz7Current user cannot access directory, check permissionszNot a directoryzUnknown OSError: {} - cwd)	r~   ÚENOENTr»   ÚENOTDIRÚformatr7   r�   r‘   ÚWorkingDirectoryError©r¦   rî   rï   Úmessages       r!   Ú_handle_posix_cwd_errorr÷   Ë  sp   € Ø
‡y�y”E—L‘LÒ Ø,‰Ø	�‰”e—l‘lÒ	"ØK‰Ø	�‰”e—m‘mÒ	#Ø#‰à-×4Ñ4´S¸³XÓ>ˆÜ
×
Ñ
×
5Ñ
5°c¸3ÀÓ
HÐHr#   c                 óø   — | j                   t         j                  k(  rd}n:| j                   t         j                  k(  rd}ndj                  t	        | «      «      }t
        j                  j                  |||«      ‚)Nz7Could not find command, ensure it is in the user's PATHz/User does not have permissions for this commandzUnknown OSError: {} - cmd)r~   rñ   r»   ró   r7   r�   r‘   ÚExecutableErrorrõ   s       r!   Ú_handle_posix_cmd_errorrú   ×  s[   € Ø
‡y�y”E—L‘LÒ ØK‰Ø	�‰”e—l‘lÒ	"ØC‰à-×4Ñ4´S¸³XÓ>ˆÜ
×
Ñ
×
/Ñ
/°°S¸'Ó
BÐBr#   c                 óZ   — t        | dd«      |k(  rt        | ||«       yt        | ||«       y)a  OSError handling for POSIX systems.

    Some things that could happen to trigger an OSError:
        - cwd could not exist
            - exc.errno == ENOENT
            - exc.filename == cwd
        - cwd could have permissions that prevent the current user moving to it
            - exc.errno == EACCES
            - exc.filename == cwd
        - cwd could exist but not be a directory
            - exc.errno == ENOTDIR
            - exc.filename == cwd
        - cmd[0] could not exist
            - exc.errno == ENOENT
            - exc.filename == None(?)
        - cmd[0] could exist but have permissions that prevents the current
            user from executing it (executable bit not set for the user)
            - exc.errno == EACCES
            - exc.filename == None(?)
    ÚfilenameN)r–   r÷   rú   ©r¦   rî   rï   s      r!   Ú_handle_posix_errorrþ   á  s-   € ô* ˆs�J Ó%¨Ò,Ü  S¨#Õ.ä  S¨#Õ.r#   c                 óV  — t         j                  j                  j                  }| j                  t        j
                  k(  rd}t         j                  j                  }nÂ| j                  t        j                  k(  rd}t         j                  j                  }nˆ| j                  t        j                  k(  rd}t         j                  j                  }nNdj                  t        | «      | j                  t        j                  j                  | j                  d«      «      } ||||«      ‚)NzcCould not find command, ensure it is in the user's PATH and that the user has permissions to run itz.Command was not executable, ensure it is validzUUnable to cd: path does not exist, user does not have permissions, or not a directoryz"Unknown error: {} (errno={}: "{}")z
<Unknown!>)r�   r‘   ÚbaseÚCommandErrorr~   rñ   rù   ÚENOEXECrò   rô   ró   r7   Ú	errorcodeÚget)r¦   rî   rï   r³   rö   s        r!   Ú_handle_windows_errorr  ü  sÞ   € Ü8B×8MÑ8M×8RÑ8R×8_Ñ8_€CØ
‡y�y”E—L‘LÒ ð:ð 	ô ×#Ñ#×3Ñ3‰Ø	�‰”e—m‘mÒ	#ØBˆÜ×#Ñ#×3Ñ3‰Ø	�‰”e—m‘mÒ	#ð/ð 	ô ×#Ñ#×9Ñ9‰à6×=Ñ=Ü�‹H�c—i‘i¤§¡×!4Ñ!4°S·Y±YÀÓ!Mó
ˆñ ˆc�3˜Ó
 Ð r#   c                 ó*  — t        |«      dk(  r*t        j                  j                  j	                  ||«      ‚t
        j                  dk(  rt        | ||«       nt        | ||«       t        j                  j                  dj                  | «      «      ‚)zGInterpret an OSError exception and raise the appropriate dbt exception.r   rŸ   z-Unhandled exception in _interpret_oserror: {})rß   r�   r‘   r   r  rG   r©   r  rþ   r   ró   rý   s      r!   Ú_interpret_oserrorr    sz   € ä
ˆ3ƒx�1‚}Ü×#Ñ#×(Ñ(×5Ñ5°c¸3Ó?Ð?ô 
‡w�w�$‚Ü˜c 3¨Õ,ä˜C  cÔ*ô ×
Ñ
×
0Ñ
0Ø7×>Ñ>¸sÓCóð r#   Úenvc                 ó¤  — t        t        |¬«      «       t        |«      dk(  r*t        j                  j
                  j                  | |«      ‚|}|�/t        j                  j                  «       }|j                  |«       	 t        j                  |d   «      }|r/t        j                  j                  |«      gt        |dd  «      z   }t!        j"                  || t         j$                  t         j$                  |¬«      }|j'                  «       \  }}t        t-        t/        «      ¬«      «       t        t1        t/        «      ¬«      «       j2                  dk7  rLt        t5        |j2                  ¬«      «       t        j                  j7                  | ||j2                  ||«      ‚||fS # t(        $ r}t+        || |«       Y d }~Œ¶d }~ww xY w)N)rï   r   rº   )rî   ÚstdoutÚstderrr  )Úbmsg)Ú
returncode)r   r   rß   r�   r‘   r   r  rG   ÚenvironÚcopyÚupdaterÌ   Úwhichr   rÄ   r,   Ú
subprocessÚPopenÚPIPEÚcommunicater}   r  r   r7   r   r  r   ÚCommandResultError)	rî   rï   r  Úfull_envÚexe_pthÚprocÚoutÚerrr¦   s	            r!   Úrun_cmdr  %  sh  € ÜÔ! cÔ*Ô+Ü
ˆ3ƒx�1‚}Ü×#Ñ#×(Ñ(×5Ñ5°c¸3Ó?Ð?ð €HØ
€Ü—:‘:—?‘?Ó$ˆØ�‰˜Ôð
*Ü—,‘,˜s 1™vÓ&ˆÙÜ—7‘7—?‘? 7Ó+Ð,¬t°C¸¸°G«}Ñ<ˆCÜ×ÑØ�S¤§¡¼¿¹Èhô
ˆð ×#Ñ#Ó%‰ˆˆSô Œ|¤ S£Ô*Ô+ÜŒ|¤ S£Ô*Ô+à‡�˜!ÒÜÔ)°T·_±_ÔEÔFÜ×#Ñ#×6Ñ6°s¸CÀÇÁÐRUÐWZÓ[Ð[à�ˆ8€Oøô ò *Ü˜3  S×)Ñ)ûð*ús   ÂBF/ Æ/	GÆ8G
Ç
GÚurlÚtimeoutc                 óT   — t        j                  t        | ||«      }t        |d«       y )Né   )Ú	functoolsÚpartialÚdownloadr   )r  r   r  Údownload_fns       r!   Údownload_with_retriesr%  G  s$   € ô ×#Ñ#¤H¨c°4¸ÓA€KÜ˜{¨AÕ.r#   c                 ó   — t        |«      }|xs t        t        j                  dd«      «      }t	        j
                  | |¬«      }t        |d«      5 }|j                  d«      D ]  }|j                  |«       Œ 	 d d d «       y # 1 sw Y   y xY w)NÚDBT_HTTP_TIMEOUTé
   )r  Úwbi   )	ro   ÚfloatrG   ÚgetenvÚrequestsr  rp   Úiter_contentr‰   )r  r   r  Úconnection_timeoutÚresponsers   Úblocks          r!   r#  r#  N  s‚   € ô
 ˜Ó€DØ ÒL¤E¬"¯)©)Ð4FÈÓ*KÓ$LÐÜ�|‰|˜CÐ);Ô<€HÜ	ˆd�DÓ	ð  ˜VØ×*Ñ*¨9Ó5ò 	 ˆEØ�L‰L˜Õñ	 ÷ ÷  ñ  ús   Á(BÂBÚ	from_pathÚto_pathÚforcec                 óò   — t        | «      } t        |«      }t        |«      }| |k(  ry t        j                  j	                  |«      r|r|rt        |«       nt        |«       t        j                  | |«       y r+   )	ro   ré   rG   r   r{   rã   rÎ   rÌ   Úmove)r1  r2  r3  Ú
is_symlinks       r!   Úrenamer7  [  s]   € Ü˜YÓ'€IÜ˜7Ó#€GÜ  Ó)€Jà�GÒØä	‡w�w‡~�~�gÔ¡5ÙÜ˜Õ ä�'ŒNä
‡K�K�	˜7Õ#r#   Útarballc                 ó8  — d„ }t        t        d«      r| j                  |d¬«       y| j                  «       }|D ]K  }t        j
                  j                  ||j                  «      } |||«      rŒ7t        j                  ||«      ‚ | j                  ||¬«       y)zÿ
    Fix for CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')

    Uses os.path.commonpath() instead of commonprefix() to prevent path traversal
    via sibling directories with matching prefixes (CVE-2026-1703).
    c                 óê   — t         j                  j                  | «      }t         j                  j                  |«      }	 t         j                  j                  ||g«      }||k(  S # t        $ r Y yw xY w)NF)rG   r   rÄ   Ú
commonpathÚ
ValueError)Ú	directoryÚtargetÚabs_directoryÚ
abs_targetrà   s        r!   Ú_is_within_directoryz*safe_extract.<locals>._is_within_directoryt  sa   € ÜŸ™Ÿ™¨	Ó2ˆÜ—W‘W—_‘_ VÓ,ˆ
ð	Ü—W‘W×'Ñ'¨¸
Ð(CÓDˆFØ˜]Ñ*Ð*øÜò 	áð	ús   Á %A& Á&	A2Á1A2Údata_filterr±   )Úfilter)ÚmembersN)	rÙ   ÚtarfileÚ
extractallÚ
getmembersrG   r   rN   r©   ÚOutsideDestinationError)r8  r   rA  rD  ÚmemberÚmember_paths         r!   Úsafe_extractrK  l  s�   € òô Œw˜Ô&Ø×Ñ˜4¨ÐÕ/à×$Ñ$Ó&ˆØò 	DˆFÜŸ'™'Ÿ,™, t¨V¯[©[Ó9ˆKÙ'¨¨kÕ:Ü×5Ñ5°f¸dÓCÐCð	Dð
 	×Ñ˜4¨ÐÕ1r#   Útar_pathÚdest_dirÚ	rename_toc                 óÄ  — t        | «      } d }t        j                  | d«      5 }t        ||«       t        j
                  j                  |j                  «       «      }d d d «       |rmt        j
                  j                  ||«      }t        j
                  j                  ||«      }t        j                  j                  j                  ||d¬«       y y # 1 sw Y   ŒyxY w)Nzr:gzT)r3  )ro   rE  rp   rK  rG   r   ÚcommonprefixÚgetnamesrN   r�   ÚclientsÚsystemr7  )rL  rM  rN  Útar_dir_namer8  Údownloaded_pathÚdesired_paths          r!   Úuntar_packagerW  ‹  s´   € Ü˜HÓ%€HØ€LÜ	�‰�h Ó	'ð @¨7Ü�W˜hÔ'Ü—w‘w×+Ñ+¨G×,<Ñ,<Ó,>Ó?ˆ÷@ñ ÜŸ'™'Ÿ,™, x°Ó>ˆÜ—w‘w—|‘| H¨iÓ8ˆÜ×Ñ×!Ñ!×(Ñ(¨¸,ÈdÐ(ÕSð ÷@ð @ús   ¤:CÃCc                 óÊ   — | t         j                  u st         j                  dk7  r‚ t        j                  |t        j
                  t        j                  z  «        | |«       y)a*  Define an error handler to pass to shutil.rmtree.

    On Windows, when a file is marked read-only as git likes to do, rmtree will
    fail. To handle that, on errors try to make the file writable.
    We want to retry most operations here, but listdir is one that we know will
    be useless.
    rŸ   N)rG   Úlistdirr©   r¼   r½   ÚS_IREADÚS_IWRITE)r¸   r   Úexc_infos      r!   Úchmod_and_retryr]  —  s?   € ð Œr�z‰zÑœRŸW™W¨š_ØÜ‡H�HˆT”4—<‘<¤$§-¡-Ñ/Ô0áˆ…Jr#   c                 óz   — t         j                  j                  t         j                  j                  | «      «      S r+   )rG   r   ÚnormcaserÄ   r    s    r!   Ú_absnormr`  ¦  s$   € Ü�7‰7×ÑœBŸG™GŸO™O¨DÓ1Ó2Ð2r#   c                 óØ  — t        | «      } t        |«      }t        j                  dk7  rt        j                  | |«      S t        j
                  j                  |«      r³t        | «      t        |«      k(  rt        j                  | |«       yt        j
                  j                  |t        j
                  j                  | j                  d«      «      «      }t        j
                  j                  |«      rt        dj                  |«      «      ‚	 t        j                  | |«       y# t        $ r¶ t        j
                  j                  | «      rit        |dz   «      j!                  t        | dz   «      «      rt        dj                  | |«      «      ‚t        j"                  | |d¬«       t%        | «       Y yt        j&                  | |«       t        j(                  | «       Y yw xY w)	a…  A re-implementation of shutil.move for windows fun.

    A re-implementation of shutil.move that properly removes the source
    directory on windows when it has read-only files in it and the move is
    between two drives.

    This is almost identical to the real shutil.move, except it, uses our rmtree
    and skips handling non-windows OSes since the existing one works ok there.
    rŸ   Nz/\zPath '{}' already existsrÐ   z-Cannot move a directory '{}' into itself '{}'T)Úsymlinks)ro   rG   r©   rÌ   r5  r   Úisdirr`  r7  rN   ÚbasenameÚrstripr{   ÚEnvironmentErrorró   r}   rÑ   ÚcopytreerÍ   Úcopy2Úunlink)ÚsrcÚdsts     r!   r5  r5  ª  sZ  € ô �sÓ
€CÜ
�sÓ
€CÜ	‡w�w�$‚Ü�{‰{˜3 Ó$Ð$ä	‡w�w‡}�}�SÔÜ�C‹=œH S›MÒ)Ü�I‰I�c˜3ÔØä�g‰g�l‰l˜3¤§¡× 0Ñ 0°·±¸EÓ1BÓ CÓDˆÜ�7‰7�>‰>˜#ÔÜ"Ð#=×#DÑ#DÀSÓ#IÓJÐJðÜ
�	‰	�#�sÕøÜò ä�7‰7�=‰=˜ÔÜ˜˜d™
Ó#×.Ñ.¬x¸¸d¹
Ó/CÔDä&ØC×JÑJÈ3ÐPSÓTóð ô �O‰O˜C ¨tÕ4Ü�3ŽKä�L‰L˜˜cÔ"Ü�I‰I�cŽNðús   ÄD* Ä*BG)Æ;+G)Ç(G)c                 óN   — t        | «      } t        j                  | t        ¬«      S )zxRecursively remove the path.

    On permissions errors on windows, try to remove the read-only flag and try again.
    rÈ   )ro   rÌ   rÍ   r]  r    s    r!   rÍ   rÍ   Ó  s   € ô
 ˜Ó€DÜ�=‰=˜¤Ô7Ð7r#   c                   ó   — e Zd Zy)ÚGetEnvParamsN)r4   r5   r6   r   r#   r!   rn  rn  Ü  s   „ àr#   rn  c                   ó"   — e Zd ZU eeef   ed<   y)ÚGetEnvResultr  N)r4   r5   r6   r   r7   r8   r   r#   r!   rp  rp  á  s   … à	ˆc�3ˆh‰Ôr#   rp  c                   ó   — e Zd ZeZeZy)ÚGetEnvRecordN)r4   r5   r6   rn  r@   rp  rA   r   r#   r!   rr  rr  æ  s   „ à€JØ�Jr#   rr  c                  ó4   — t        t        j                  «      S r+   )ÚdictrG   r  r   r#   r!   Úget_envru  ì  s   € ä”—
‘
ÓÐr#   r+   )T)r   N)Ú F)rv  )F)ú.)mÚdbt_common.exceptions.baser�   Údataclassesr~   rI   r!  r®   rG   Úos.pathrK   rÌ   r½   r  rÊ   rE  Úpathlibr   Útypingr   r   r   r   r   r	   r
   r   r   Údbt_common.exceptionsr,  Údbt_common.events.functionsr   Údbt_common.events.typesr   r   r   r   r   r   Údbt_common.recordr   r   r   Údbt_common.utils.connectionr   Úpathspecr   rË   Úctypesr   r   r7   r9   r"   Ú	dataclassr%   r;   Úregister_record_typer>   r`   rb   rh   rk   ru   Úsingledispatchry   Úregisterr�   r‹   r”   r�   r˜   r›   r«   r°   r·   r}   rÀ   rÆ   rÎ   rÕ   rÜ   ro   rã   ræ   ré   rí   r÷   rú   rþ   r  r  Úbytesr  r*  Útupler%  r#  r7  ÚTarFilerK  rW  r]  r`  r5  rÍ   rn  rp  rr  ru  r   r#   r!   ú<module>r‹     s¬  ðÛ !Û Û Û Û Û Û 	Û Û 	Û Û Û Û 
Û Ý ß T× TÕ Tã Û Ý 2÷õ õ 3ß ?Ñ ?Ý Bå à‡<�<�7Òß%Ð%à€FØ€Fð�sð ˜tó ð ×Ñ÷,ð ,ó ð,ð4 ×Ñ÷"ð "ó ð"ð 
×Ñô$˜ó $ó ð$ñ Ð#Ó$ð
 '+ñ	=Øð=à" 3™ið=ð ð=ð ˜(Ñ#ð	=ð
 
ˆ$ˆs�Cˆx‰.Ñò=ó %ð=ð@ ×Ñ÷'ð 'ó ð'ð ×Ñ÷ð ó ðð 
×Ñô �Vó  ó ð ñ �Ó ñ˜Sð ¨ð ¸ò ó !ðð ×ÑóKó ðKð ×ÑðˆCð �Dò ó ðð ×Ñð,ˆDð ,�Tò ,ó ð,ñ�Cð  3ð ¸ð Èó ð"˜ð "¨ð "°ó "ð4˜4ó 4ð ×Ñ÷'ð 'ó ð'ð 
×Ñô�fó ó ðñ �Ó!ñ�Sð  Cð °ò ó "ðð<�Cð ˜D  c ™Nó ð�Sð   S¨# X¡ð °4ó ð& (¨C¨5°#¨:Ñ"6ð ¸cð ÈÈcÐSZÐ\_ÐN_ÑH`ó ðY¨Cð Y¸Cð YÀCó Yð)�ð )˜ó )ð ˜Cð  Có ð.,˜dó ,ð*�sð ˜só ð:�cð ˜dó ð
!�cð !˜dó !ð
 ˜#ð   $ó  ð
	�có 	ð	I ð 	I¨sð 	I¸¸c¹ð 	IÀxó 	IðC ð C¨sð C¸¸c¹ð CÀxó Cð/˜Wð /¨3ð /°T¸#±Yð /À8ó /ð6!˜wð !¨Sð !°t¸C±yð !ÀXó !ð0˜Gð ¨#ð °D¸±Ið À(ó ñ"�ð ˜4 ™9ð ¨8°D¸¸c¸±NÑ+Cð ÈuÐUZÐ\aÐUaÑObó ðF CGñ/Ø	ð/Øð/Ø"*¨5°¸°Ñ+>Ñ"?ð/à	ó/ð PTñ
 Ø	ð
 à
ð
 ð �e˜E 5¨°¨Ñ#6¸¸eÀT¸kÑ8JÐJÑKÑLð
 ð 
ó	
 ñ$�cð $ Cð $°ð $Àó $ñ"2˜'Ÿ/™/ð 2°ð 2¸tó 2ñ>	T˜Cð 	T¨3ð 	T¸8ÀC¹=ð 	TÐTXó 	Tòò3ò&òR8ð ×Ñ÷	ð 	ó ð	ð ×Ñ÷ð ó ðð 
×Ñô�6ó ó ðñ
 �Óð��c˜3�h‘ò ó ñr#   