
    Dh                         d dl Z d dlmZ d dlmZmZmZ  e j                  e      Z	d Z
d Zd Z G d de      Zg d	Zy)
    N)Path)ffivips_libglib_libc                 f    t        | t        t        f      rt        |       j                  d      } | S )zConvert to a byte string.

    Convert a Python unicode string or a pathlib.Path to a utf-8-encoded
    byte string. You must call this on strings you pass to libvips.

    utf-8)
isinstancestrr   encodexs    n/var/www/fastuser/data/www/generator.snapmosaic.io/flask_app/venv/lib/python3.12/site-packages/pyvips/error.py	_to_bytesr      s)     !c4[!FMM'"H    c                     | t         j                  k(  rd} | S t        j                  |       } t        | t              r| j                  d      } | S )zConvert to a unicode string.

    If x is a byte string, assume it is utf-8 and decode to a Python unicode
    string. You must call this on text strings you get back from libvips.

    NULLr   )r   r   stringr	   bytesdecoder   s    r   
_to_stringr      sG     	CHH} H	 JJqMa!AHr   c                 \    t        t        j                  | t        j                              S )zConvert to a unicode string, and auto-free.

    As _to_string(), but also tag x as a pointer to a memory area that must
    be freed with g_free().

    )r   r   gcr   g_freer   s    r   _to_string_copyr   *   s     cffQ011r   c                       e Zd ZdZddZd Zy)ErrorzAn error from vips.

    Attributes:
        message (str): a high-level description of the error
        detail (str): a string with some detailed diagnostics

    Nc                     || _         ||dk(  r1t        t        j                               }t        j                          || _        t        j                  d| j                   | j
                         y )N zError %s %s)messager   r   vips_error_buffervips_error_cleardetailloggerdebug)selfr   r"   s      r   __init__zError.__init__=   sR    >Vr\ : : <=F%%']DLL$++>r   c                 8    | j                    d| j                   S )Nz
  )r   r"   )r%   s    r   __str__zError.__str__F   s    ,,tDKK=11r   )N)__name__
__module____qualname____doc__r&   r(    r   r   r   r   4   s    ?2r   r   )r   r   r   r   )loggingpathlibr   pyvipsr   r   r   	getLoggerr)   r#   r   r   r   	Exceptionr   __all__r-   r   r   <module>r4      sG      * *			8	$"22I 2,r   