
    ,hK                       S r SSKJr  SSKrSSKrSSKrSSKrSSKrSSK	J
r
  SSKJr  SSKJr  SSKJrJrJr  S	S
KJr  \R*                  " S5      r\R.                  r " S S\
5      r " S S\
5      r " S S\
5      r\SS j5       r S     SS jjr\R:                  " S\R<                  \R>                  -  5      r SS jr!SS jr"SS jr#S S jr$\S!S j5       r%g)"z@
Various functionalities to make easier to work with the libpq.
    )annotationsN)
NamedTuple)Path   )abc)
ConnStatusPipelineStatusTransactionStatus   )cachez
psycopg.pqc                  4    \ rS rSr% S\S'   S\S'   S\S'   Srg)	PGnotify   bytesrelnameintbe_pidextra N__name__
__module____qualname____firstlineno____annotations____static_attributes__r       J/var/www/html/Ai_home/venv/lib/python3.13/site-packages/psycopg/pq/misc.pyr   r      s    NKLr   r   c                  \    \ rS rSr% S\S'   S\S'   S\S'   S\S'   S\S'   S\S	'   S
\S'   Srg)ConninfoOption    r   keywordzbytes | Noneenvvarcompiledvallabeldispcharr   dispsizer   Nr   r   r   r   r    r        s(    N	LOMr   r    c                  \    \ rS rSr% S\S'   S\S'   S\S'   S\S'   S\S'   S\S	'   S\S
'   Srg)PGresAttDesc*   r   namer   tableidcolumnidformattypidtyplen	atttypmodr   Nr   r   r   r   r*   r*   *   s%    
KLMKJKNr   r*   c                    [         R                  S:X  aG  [        R                  R	                  S5      =n c  g [        [        U 5      R                  5       5      n U $ [         R                  S:X  a  [        R                  R	                  S5      n U (       d|   SS KnUR                  SS/5      R                  5       R                  5       n[        R                  R                  [        R                  R                  US5      =n 5      (       d  S n U $  U $ [        R                  R	                  S	5      n U $ ! [          a!  n["        R%                  SU5         S nAU $ S nAff = f)
Nwin32z	libpq.dlldarwinzlibpq.dylibr   	pg_configz--libdirz(couldn't use pg_config to find libpq: %spq)sysplatformctypesutilfind_librarystrr   resolve
subprocesscheck_outputstripdecodeospathexistsjoin	Exceptionloggerdebug)libnamesplibdirexs       r   find_libpq_full_pathrN   4   s%   
||w{{//<<GEd7m++-.& N% 
	!++**=9 M'+z)BCIIKRRTww~~"'',,v}2U'UwWW"G N  N ++**40N  MGLL
 NMs   A9D6 6
E! EE!c                R    U(       a  U R                  U5      $ U R                  5       $ )a%  
Return an error message from a `PGconn`, `PGresult`, `PGcancelConn`.

The return value is a `!str` (unlike pq data which is usually `!bytes`):
use the connection encoding if available, otherwise the `!encoding`
parameter as a fallback for decoding. Don't raise exceptions on decoding
errors.
)get_error_message)objencodings     r   error_messagerS   O   s%      /73  *SC<Q<Q<SSr   u  
    ^ (?:
      DEBUG | INFO | HINWEIS | WARNUNG | FEHLER | LOG | FATAL | PANIK  # de
    | DEBUG | INFO | NOTICE | WARNING | ERROR | LOG | FATAL | PANIC  # en
    | DEBUG | INFO | NOTICE | WARNING | ERROR | LOG | FATAL | PANIC  # es
    | DEBUG | INFO | NOTICE | ATTENTION | ERREUR | LOG | FATAL | PANIC  # fr
    | DEBUG | INFO | NOTICE | PERINGATAN | ERROR | LOG | FATAL | PANIK  # id
    | DEBUG | INFO | NOTIFICA | ATTENZIONE | ERRORE | LOG | FATALE | PANICO  # it
    | DEBUG | INFO | NOTICE | WARNING | ERROR | LOG | FATAL | PANIC  # ja
    | 디버그 | 정보 | 알림 | 경고 | 오류 | 로그 | 치명적오류 | 손상  # ko
    | DEBUG | INFORMACJA | UWAGA | OSTRZEŻENIE | BŁĄD | DZIENNIK | KATASTROFALNY | PANIKA  # pl
    | DEPURAÇÃO | INFO | NOTA | AVISO | ERRO | LOG | FATAL | PÂNICO  # pt_BR
    | ОТЛАДКА | ИНФОРМАЦИЯ | ЗАМЕЧАНИЕ | ПРЕДУПРЕЖДЕНИЕ | ОШИБКА | СООБЩЕНИЕ | ВАЖНО | ПАНИКА  # ru
    | DEBUG | INFO | NOTIS | VARNING | FEL | LOGG | FATALT | PANIK  # sv
    | DEBUG | BİLGİ | NOT | UYARI | HATA | LOG | ÖLÜMCÜL\ \(FATAL\) | KRİTİK  # tr
    | НАЛАГОДЖЕННЯ | ІНФОРМАЦІЯ | ПОВІДОМЛЕННЯ | ПОПЕРЕДЖЕННЯ | ПОМИЛКА | ЗАПИСУВАННЯ | ФАТАЛЬНО | ПАНІКА  # uk
    | 调试 | 信息 | 注意 | 警告 | 错误 | 日志 | 致命错误 | 比致命错误还过分的错误  # zh_CN
    ) : \s+
    c                    [         R                  U 5      =n(       a  XR                  5       S   S n U R                  5       $ )z2Strip severity and whitespaces from error message.r   N)PREFIXESmatchspanrA   )msgms     r   strip_severityrZ      s6    NN3q&&(1+- 99;r   c                L    U R                  US5      =n(       a  [        U5      $ g)Nreplacezno error details available)rB   rZ   )rX   rR   smsgs      r   _clean_error_messager^      s&    zz(I..t.d##+r   c                   / nU R                   [        :X  GaU  [        U R                  5      R                  nU R
                  (       a%  US[        U R
                  5      R                   3-  nU R                  R                  S5      (       d+  UR                  SU R                  R                  5       45        U R                  R                  5       =(       d
    [        5       =nS:w  a  UR                  SU45        U R                  U R                  :w  a+  UR                  SU R                  R                  5       45        UR                  SU R                  R                  5       45        O  [        U R                   5      R                  nS
R#                  S U 5       5      =n(       a  SU S3nSU SU 3$ ! [          a    SU R                    S	3n NIf = f)zB
Return summary information on a connection.

Useful for __repr__
z, pipeline=   /host5432portuserdatabasezstatus=z (unkndown) c              3  *   #    U H
  nS U-  v   M     g7f)z%s=%sNr   ).0parts     r   	<genexpr>%connection_summary.<locals>.<genexpr>   s     <ed7T>es   z ()[])statusOKr
   transaction_statusr,   pipeline_statusr	   ra   
startswithappendrB   rc   get_compiled_portrd   dbr   
ValueErrorrF   )pgconnpartsro   rc   spartss        r   connection_summaryr{      s    E}}'(A(ABGG!!N63I3I$J$O$O#PQQF {{%%d++LL&&++"4"4"678KK&&(?,=,??DFJLL&$(;;&))#LL&&++"4"4"678j&))"2"2"456	:.33F <e<==v=fXQvhax    	: v}}o[9F	:s   .F: :GGc                t    [        U S5      u  p[        U S5      u  p#US:  a  US:X  a  U SU 3$ U SU SU 3$ )zg
Return a pretty representation of a PostgreSQL version

For instance: 140002 -> 14.2, 90610 -> 9.6.10
d   
   r   .)divmod)versionpatchmajorminors       r   version_prettyr      sU     GS)NG'3'LE{uz%!!%%))r   c                 j    SSK Jn   U " S5      nU(       a  UR                  (       a  UR                  $ S$ )z0Return the default port compiled with the libpq.r   )get_param_defrc    )psycopg._conninfo_utilsr   r$   )r   infos     r   ru   ru      s(     6 D T]]4==::r   )returnz
str | None)r   )rQ   z,abc.PGconn | abc.PGresult | abc.PGcancelConnrR   r=   r   r=   )rX   r=   r   r=   )rX   r   rR   r=   r   r=   )rx   z
abc.PGconnr   r=   )r   r   r   r=   )r   r=   )&__doc__
__future__r   rC   rer8   loggingctypes.utilr:   typingr   pathlibr   r   r   _enumsr   r	   r
   _compatr   	getLoggerrH   rp   r   r    r*   rN   rS   compileVERBOSE	MULTILINErU   rZ   r^   r{   r   ru   r   r   r   <module>r      s    # 	 	 
      A A 			<	(]]z Z :   6 HJT	5TADTT, ::( JJ-4, !F* ; ;r   