
    Dh
                         d dl Z d dlZd dlmZmZmZmZ  e j                  e      Z G d dej                        Z
dgZy)    N)ffivips_libError	_to_bytesc                   R     e Zd ZdZ fdZed        Zed        Zed        Z xZ	S )SourcezAn input connection.

    c                 ,    t         t        |   |       y )N)superr   __init__)selfpointer	__class__s     p/var/www/fastuser/data/www/generator.snapmosaic.io/flask_app/venv/lib/python3.12/site-packages/pyvips/vsource.pyr   zSource.__init__   s    fd$W-    c                     t        j                  |       }|t        j                  k(  rt	        d|        t        |      S )aH  Make a new source from a file descriptor (a small integer).

        Make a new source that is attached to the descriptor. For example::

            source = pyvips.Source.new_from_descriptor(0)

        Makes a descriptor attached to stdin.

        You can pass this source to (for example) :meth:`new_from_source`.

        z$can't create source from descriptor )r   vips_source_new_from_descriptorr   NULLr   r   )
descriptorr   s     r   new_from_descriptorzSource.new_from_descriptor   s=    $ :::Fchh>zlKLLgr   c                     t        j                  t        |             }|t        j                  k(  rt        d|        t        |      S )a  Make a new source from a filename.

        Make a new source that is attached to the named file. For example::

            source = pyvips.Source.new_from_file("myfile.jpg")

        You can pass this source to (for example) :meth:`new_from_source`.

        z"can't create source from filename )r   vips_source_new_from_filer   r   r   r   r   )filenamer   s     r   new_from_filezSource.new_from_file*   sB     44Yx5HIchh<XJGHHgr   c                    t        j                  |       }t        | d      r| j                  n
t	        |       }t        j                  ||      }|t         j                  k(  rt        d      t        |      }| g|_
        |S )az  Make a new source from a memory object.

        Make a new source that is attached to the memory object. For example::

            source = pyvips.Source.new_from_memory("myfile.jpg")

        You can pass this source to (for example) :meth:`new_from_source`.

        The memory object can be anything that supports the Python buffer or
        memoryview protocol.

        nbytesz%can't create input source from memory)r   from_bufferhasattrr   lenr   vips_source_new_from_memoryr   r   r   _references)datastartr   r   sources        r   new_from_memoryzSource.new_from_memory?   sn    " % 'h 7SY66ufEchh?@@ #Vr   )
__name__
__module____qualname____doc__r   staticmethodr   r   r$   __classcell__)r   s   @r   r   r   	   sI    .  .  (  r   r   )loggingpyvipsr   r   r   r   	getLoggerr%   logger
Connectionr   __all__ r   r   <module>r2      sA      2 2			8	$SV Sl *r   