Beispiel #1
0
    def __init__(self, filename=None):
        """Initializes a new Raw object."""
        if filename is None:
            raise NoFileSpecified()
        self.libraw = LibRaw()
        self.data = self.libraw.libraw_init(0)
        self.libraw.libraw_open_file(self.data, filename.encode('ascii'))

        self.options = Options()

        self.image_unpacked = False
        self.thumb_unpacked = False
Beispiel #2
0
def camera_list():
    """
    Return a list of cameras which are supported by the currently linked
    version of LibRaw.

    Returns:
        str array: A list of supported cameras.
    """

    libraw = LibRaw()
    libraw.libraw_cameraList.restype = ctypes.POINTER(
        ctypes.c_char_p * libraw.libraw_cameraCount())
    data_pointer = libraw.libraw_cameraList()
    return [x.decode('ascii') for x in data_pointer.contents]
Beispiel #3
0
    def __init__(self, filename=None):
        """Initializes a new Raw object."""
        if filename is None:
            raise NoFileSpecified()
        self.libraw = LibRaw()
        self.data = self.libraw.libraw_init(0)
        try:  # pragma: no cover
            _fname = os.fsencode(filename)
        except Exception:  # pragma: no cover
            _fname = filename
        self.libraw.libraw_open_file(self.data, _fname)

        self.options = Options()

        self.image_unpacked = False
        self.thumb_unpacked = False
Beispiel #4
0
def discover(path):
    """
    Recursively search for raw files in a given directory.

    Args:
        path (str): A tree to recursively search.
    """
    file_list = []
    libraw = LibRaw()
    raw = libraw.libraw_init(0)

    for root, _, files in os.walk(path):
        for file_name in files:
            file_path = os.path.join(root, file_name).encode('ascii')
            try:
                libraw.libraw_open_file(raw, file_path)
            except FileUnsupported:
                continue
            finally:
                libraw.libraw_recycle(raw)
            file_list.append(file_path)

    libraw.libraw_close(raw)
    return file_list
Beispiel #5
0
def libraw():
    with mock.patch.object(LibRaw, '__init__', mock.Mock(return_value=None)):
        yield LibRaw()