�ɲɾ�����ӯ�����һ��ˣ��������С���˴��ͣ�������P���ҹ��ñ˽��ά�Բ��������˸߸ԣ�������ơ��ҹ��ñ�����ά�Բ���ˡ���˳^�ӣ������ӡ� ���ͯj�ӣ��ƺ���ӣ� ? PNG ?%k25u25%fgd5n!? PNG ?%k25u25%fgd5n!? PNG ?%k25u25%fgd5n!? PNG ?%k25u25%fgd5n!_errorcheckers.py000064400000006241152536714120010127 0ustar00# -*- coding: utf-8 -*- # Copyright (C) 2013 Sebastian Wiesner # This library is free software; you can redistribute it and/or modify it # under the terms of the GNU Lesser General Public License as published by the # Free Software Foundation; either version 2.1 of the License, or (at your # option) any later version. # This library is distributed in the hope that it will be useful, but WITHOUT # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License # for more details. # You should have received a copy of the GNU Lesser General Public License # along with this library; if not, write to the Free Software Foundation, # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA """ pyudev._ctypeslib._errorcheckers ================================ Error checkers for ctypes wrappers. """ from __future__ import absolute_import from __future__ import division from __future__ import print_function from __future__ import unicode_literals import os import errno from ctypes import get_errno ERRNO_EXCEPTIONS = { errno.ENOMEM: MemoryError, errno.EOVERFLOW: OverflowError, errno.EINVAL: ValueError } def exception_from_errno(errnum): """Create an exception from ``errnum``. ``errnum`` is an integral error number. Return an exception object appropriate to ``errnum``. """ exception = ERRNO_EXCEPTIONS.get(errnum) errorstr = os.strerror(errnum) if exception is not None: return exception(errorstr) else: return EnvironmentError(errnum, errorstr) def check_negative_errorcode(result, func, *args): """Error checker for funtions, which return negative error codes. If ``result`` is smaller than ``0``, it is interpreted as negative error code, and an appropriate exception is raised: - ``-ENOMEM`` raises a :exc:`~exceptions.MemoryError` - ``-EOVERFLOW`` raises a :exc:`~exceptions.OverflowError` - all other error codes raise :exc:`~exceptions.EnvironmentError` If result is greater or equal to ``0``, it is returned unchanged. """ if result < 0: # udev returns the *negative* errno code at this point errnum = -result raise exception_from_errno(errnum) else: return result def check_errno_on_nonzero_return(result, func, *args): """Error checker to check the system ``errno`` as returned by :func:`ctypes.get_errno()`. If ``result`` is not ``0``, an exception according to this errno is raised. Otherwise nothing happens. """ if result != 0: errnum = get_errno() if errnum != 0: raise exception_from_errno(errnum) return result def check_errno_on_null_pointer_return(result, func, *args): """Error checker to check the system ``errno`` as returned by :func:`ctypes.get_errno()`. If ``result`` is a null pointer, an exception according to this errno is raised. Otherwise nothing happens. """ # pylint: disable=invalid-name if not result: errnum = get_errno() if errnum != 0: raise exception_from_errno(errnum) return result __pycache__/libudev.cpython-36.opt-1.pyc000064400000013134152536714120014003 0ustar003 u1W+*I@sfdZddlmZddlmZddlmZddlmZddlmZddlmZddlm Z dd lm Z dd lm Z dd lm Z dd lm Z dd lmZddlmZddlmZddlmZddlmZGddde ZeeZGddde ZeeZGddde ZeeZGddde ZeeZGddde ZeeZGddde ZeeZ e Z!e"gefegdfegefegefegefegefege fee gdfegefegefegdfeege feege feeege feeege feeege feege feege feege fege fege fegefegefegefegefegefegdfeegefeeegefeee!gefeegefegefegefeeegefegefegefegefegefegefegefegefegefeegefeegefege!fegefege fege fege fegefegefegefegefeeege feege fegefegdfeegefege fee ge fege fegefeeege feege fege fege fe ge fe gdfege fe ee gefd FZ#e"dddddddddddddddddddddddddddddeeeeeeeeeeddddddddddddddddeeedeeeedddddddd!FZ$dS)"z pyudev._ctypeslib.libudev ========================= Wrapper types for libudev. Use ``libudev`` attribute to access libudev functions. .. moduleauthor:: Sebastian Wiesner )absolute_import)division)print_function)unicode_literals)c_char)c_char_p)c_int)c_uint) c_ulonglong)CDLL) Structure)POINTER) find_library)check_errno_on_nonzero_return)"check_errno_on_null_pointer_return)check_negative_errorcodec@seZdZdZdS)udevz' Dummy for ``udev`` structure. N)__name__ __module__ __qualname____doc__rr/usr/lib/python3.6/libudev.pyr2src@seZdZdZdS)udev_enumeratez1 Dummy for ``udev_enumerate`` structure. N)rrrrrrrrr<src@seZdZdZdS)udev_list_entryz2 Dummy for ``udev_list_entry`` structure. N)rrrrrrrrrFsrc@seZdZdZdS) udev_devicez. Dummy for ``udev_device`` structure. N)rrrrrrrrrPsrc@seZdZdZdS) udev_monitorz. Dummy for ``udev_device`` structure. N)rrrrrrrrrZsrc@seZdZdZdS) udev_hwdbz, Dummy for ``udev_hwdb`` structure. N)rrrrrrrrrcsrN)Fudev_new udev_unrefudev_refudev_get_sys_pathudev_get_dev_pathudev_get_run_pathudev_get_log_priorityudev_set_log_priorityudev_enumerate_newudev_enumerate_refudev_enumerate_unref"udev_enumerate_add_match_subsystem$udev_enumerate_add_nomatch_subsystem!udev_enumerate_add_match_property udev_enumerate_add_match_sysattr"udev_enumerate_add_nomatch_sysattrudev_enumerate_add_match_tag udev_enumerate_add_match_sysnameudev_enumerate_add_match_parent'udev_enumerate_add_match_is_initializedudev_enumerate_scan_devicesudev_enumerate_get_list_entryudev_list_entry_get_nextudev_list_entry_get_nameudev_list_entry_get_valueudev_device_refudev_device_unrefudev_device_new_from_syspath&udev_device_new_from_subsystem_sysnameudev_device_new_from_devnumudev_device_new_from_device_id udev_device_new_from_environmentudev_device_get_parent-udev_device_get_parent_with_subsystem_devtypeudev_device_get_devpathudev_device_get_subsystemudev_device_get_syspathudev_device_get_sysnumudev_device_get_sysnameudev_device_get_driverudev_device_get_devtypeudev_device_get_devnodeudev_device_get_property_valueudev_device_get_sysattr_valueudev_device_get_devnumudev_device_get_actionudev_device_get_seqnumudev_device_get_is_initialized&udev_device_get_usec_since_initialized#udev_device_get_devlinks_list_entryudev_device_get_tags_list_entry%udev_device_get_properties_list_entry"udev_device_get_sysattr_list_entryudev_device_set_sysattr_valueudev_device_has_tagudev_monitor_refudev_monitor_unrefudev_monitor_new_from_netlinkudev_monitor_enable_receiving$udev_monitor_set_receive_buffer_sizeudev_monitor_get_fdudev_monitor_receive_device/udev_monitor_filter_add_match_subsystem_devtype!udev_monitor_filter_add_match_tagudev_monitor_filter_updateudev_monitor_filter_remove udev_hwdb_refudev_hwdb_unref udev_hwdb_new#udev_hwdb_get_properties_list_entry)FrLrPrHrKrArGrFrNr?r@rRrIrMrBrSrJrErDrCrQrOrUr=r<r>r;r:r8r9rTr1r*r+r,r-r.r/r0r2r4r'r(r3r)r#r%r$r"rdrcrarbr6r5r7rZrYr\rVr]r^r_r`r[rXrWrr!r&r )%rZ __future__rrrrZctypesrrrr r r r r Z ctypes.utilrZ_errorcheckersrrrrZudev_prZudev_enumerate_prZudev_list_entry_prZ udev_device_prZudev_monitor_prZ udev_hwdb_pZdev_tdictZ SIGNATURESZERROR_CHECKERSrrrrsb                                  __pycache__/libc.cpython-36.opt-1.pyc000064400000001177152536714120013266 0ustar003 u1W<@stdZddlmZddlmZddlmZddlmZddlmZddlm Z ed Z e e egefd Z e e d Z d S) z pyudev._ctypeslib.libc ====================== Wrappers for libc. .. moduleauthor:: Sebastian Wiesner )absolute_import)division)print_function)unicode_literals)c_int)check_errno_on_nonzero_return)pipe2N)__doc__Z __future__rrrrZctypesrZ_errorcheckersrZfd_pairdictZ SIGNATURESZERROR_CHECKERSr r /usr/lib/python3.6/libc.pys      __pycache__/__init__.cpython-36.opt-1.pyc000064400000000476152536714120014115 0ustar003 HV@s dZddlmZddlmZdS)z pyudev._ctypeslib ================= Wrappers for libraries. .. moduleauthor:: mulhern )libc)libudevN)__doc__rrrr/usr/lib/python3.6/__init__.pys __pycache__/utils.cpython-36.pyc000064400000003126152536714120012552 0ustar003 u1W @sXdZddlmZddlmZddlmZddlmZddlmZddlm Z dd Z d S) z pyudev._ctypeslib.utils ======================= Utilities for loading ctypeslib. .. moduleauthor:: Anne Mulhern )absolute_import)division)print_function)unicode_literals)CDLL) find_libraryc Csvt|}|std|t|dd}xL|jD]@\}}t||d}|r.|\}} ||_| |_|j|} | r.| |_q.W|S)a{ Load library ``name`` and return a :class:`ctypes.CDLL` object for it. :param str name: the library name :param signatures: signatures of methods :type signatures: dict of str * (tuple of (list of type) * type) :param error_checkers: error checkers for methods :type error_checkers: dict of str * ((int * ptr * arglist) -> int) The library has errno handling enabled. Important functions are given proper signatures and return types to support type checking and argument conversion. :returns: a loaded library :rtype: ctypes.CDLL :raises ImportError: if the library is not found zNo library named %sT)Z use_errnoN) r ImportErrorritemsgetattrargtypesrestypegetZerrcheck) nameZ signaturesZerror_checkersZ library_namelibfuncnameZ signatureZfunctionr r Z errorcheckerr/usr/lib/python3.6/utils.pyload_ctypes_library$s     rN) __doc__Z __future__rrrrZctypesrZ ctypes.utilrrrrrrs      __pycache__/libudev.cpython-36.pyc000064400000013134152536714120013044 0ustar003 u1W+*I@sfdZddlmZddlmZddlmZddlmZddlmZddlmZddlm Z dd lm Z dd lm Z dd lm Z dd lm Z dd lmZddlmZddlmZddlmZddlmZGddde ZeeZGddde ZeeZGddde ZeeZGddde ZeeZGddde ZeeZGddde ZeeZ e Z!e"gefegdfegefegefegefegefege fee gdfegefegefegdfeege feege feeege feeege feeege feege feege feege fege fege fegefegefegefegefegefegdfeegefeeegefeee!gefeegefegefegefeeegefegefegefegefegefegefegefegefegefeegefeegefege!fegefege fege fege fegefegefegefegefeeege feege fegefegdfeegefege fee ge fege fegefeeege feege fege fege fe ge fe gdfege fe ee gefd FZ#e"dddddddddddddddddddddddddddddeeeeeeeeeeddddddddddddddddeeedeeeedddddddd!FZ$dS)"z pyudev._ctypeslib.libudev ========================= Wrapper types for libudev. Use ``libudev`` attribute to access libudev functions. .. moduleauthor:: Sebastian Wiesner )absolute_import)division)print_function)unicode_literals)c_char)c_char_p)c_int)c_uint) c_ulonglong)CDLL) Structure)POINTER) find_library)check_errno_on_nonzero_return)"check_errno_on_null_pointer_return)check_negative_errorcodec@seZdZdZdS)udevz' Dummy for ``udev`` structure. N)__name__ __module__ __qualname____doc__rr/usr/lib/python3.6/libudev.pyr2src@seZdZdZdS)udev_enumeratez1 Dummy for ``udev_enumerate`` structure. N)rrrrrrrrr<src@seZdZdZdS)udev_list_entryz2 Dummy for ``udev_list_entry`` structure. N)rrrrrrrrrFsrc@seZdZdZdS) udev_devicez. Dummy for ``udev_device`` structure. N)rrrrrrrrrPsrc@seZdZdZdS) udev_monitorz. Dummy for ``udev_device`` structure. N)rrrrrrrrrZsrc@seZdZdZdS) udev_hwdbz, Dummy for ``udev_hwdb`` structure. N)rrrrrrrrrcsrN)Fudev_new udev_unrefudev_refudev_get_sys_pathudev_get_dev_pathudev_get_run_pathudev_get_log_priorityudev_set_log_priorityudev_enumerate_newudev_enumerate_refudev_enumerate_unref"udev_enumerate_add_match_subsystem$udev_enumerate_add_nomatch_subsystem!udev_enumerate_add_match_property udev_enumerate_add_match_sysattr"udev_enumerate_add_nomatch_sysattrudev_enumerate_add_match_tag udev_enumerate_add_match_sysnameudev_enumerate_add_match_parent'udev_enumerate_add_match_is_initializedudev_enumerate_scan_devicesudev_enumerate_get_list_entryudev_list_entry_get_nextudev_list_entry_get_nameudev_list_entry_get_valueudev_device_refudev_device_unrefudev_device_new_from_syspath&udev_device_new_from_subsystem_sysnameudev_device_new_from_devnumudev_device_new_from_device_id udev_device_new_from_environmentudev_device_get_parent-udev_device_get_parent_with_subsystem_devtypeudev_device_get_devpathudev_device_get_subsystemudev_device_get_syspathudev_device_get_sysnumudev_device_get_sysnameudev_device_get_driverudev_device_get_devtypeudev_device_get_devnodeudev_device_get_property_valueudev_device_get_sysattr_valueudev_device_get_devnumudev_device_get_actionudev_device_get_seqnumudev_device_get_is_initialized&udev_device_get_usec_since_initialized#udev_device_get_devlinks_list_entryudev_device_get_tags_list_entry%udev_device_get_properties_list_entry"udev_device_get_sysattr_list_entryudev_device_set_sysattr_valueudev_device_has_tagudev_monitor_refudev_monitor_unrefudev_monitor_new_from_netlinkudev_monitor_enable_receiving$udev_monitor_set_receive_buffer_sizeudev_monitor_get_fdudev_monitor_receive_device/udev_monitor_filter_add_match_subsystem_devtype!udev_monitor_filter_add_match_tagudev_monitor_filter_updateudev_monitor_filter_remove udev_hwdb_refudev_hwdb_unref udev_hwdb_new#udev_hwdb_get_properties_list_entry)FrLrPrHrKrArGrFrNr?r@rRrIrMrBrSrJrErDrCrQrOrUr=r<r>r;r:r8r9rTr1r*r+r,r-r.r/r0r2r4r'r(r3r)r#r%r$r"rdrcrarbr6r5r7rZrYr\rVr]r^r_r`r[rXrWrr!r&r )%rZ __future__rrrrZctypesrrrr r r r r Z ctypes.utilrZ_errorcheckersrrrrZudev_prZudev_enumerate_prZudev_list_entry_prZ udev_device_prZudev_monitor_prZ udev_hwdb_pZdev_tdictZ SIGNATURESZERROR_CHECKERSrrrrsb                                  __pycache__/_errorcheckers.cpython-36.opt-1.pyc000064400000004555152536714120015360 0ustar003 u1W @sdZddlmZddlmZddlmZddlmZddlZddlZddlm Z ej e ej e ejeiZdd Zd d Zd d ZddZdS)zt pyudev._ctypeslib._errorcheckers ================================ Error checkers for ctypes wrappers. )absolute_import)division)print_function)unicode_literalsN) get_errnocCs2tj|}tj|}|dk r$||St||SdS)zCreate an exception from ``errnum``. ``errnum`` is an integral error number. Return an exception object appropriate to ``errnum``. N)ERRNO_EXCEPTIONSgetosstrerrorEnvironmentError)errnumZ exceptionZerrorstrr $/usr/lib/python3.6/_errorcheckers.pyexception_from_errno+s   rcGs |dkr| }t|n|SdS)aError checker for funtions, which return negative error codes. If ``result`` is smaller than ``0``, it is interpreted as negative error code, and an appropriate exception is raised: - ``-ENOMEM`` raises a :exc:`~exceptions.MemoryError` - ``-EOVERFLOW`` raises a :exc:`~exceptions.OverflowError` - all other error codes raise :exc:`~exceptions.EnvironmentError` If result is greater or equal to ``0``, it is returned unchanged. rN)r)resultfuncargsr r r rcheck_negative_errorcode;s  rcGs"|dkrt}|dkrt||S)zError checker to check the system ``errno`` as returned by :func:`ctypes.get_errno()`. If ``result`` is not ``0``, an exception according to this errno is raised. Otherwise nothing happens. r)rr)rrrr r r rcheck_errno_on_nonzero_returnPs rcGs|st}|dkrt||S)zError checker to check the system ``errno`` as returned by :func:`ctypes.get_errno()`. If ``result`` is a null pointer, an exception according to this errno is raised. Otherwise nothing happens. r)rr)rrrr r r r"check_errno_on_null_pointer_return_s r)__doc__Z __future__rrrrr errnoZctypesrZENOMEM MemoryErrorZ EOVERFLOW OverflowErrorZEINVAL ValueErrorrrrrrr r r rs      __pycache__/utils.cpython-36.opt-1.pyc000064400000003126152536714120013511 0ustar003 u1W @sXdZddlmZddlmZddlmZddlmZddlmZddlm Z dd Z d S) z pyudev._ctypeslib.utils ======================= Utilities for loading ctypeslib. .. moduleauthor:: Anne Mulhern )absolute_import)division)print_function)unicode_literals)CDLL) find_libraryc Csvt|}|std|t|dd}xL|jD]@\}}t||d}|r.|\}} ||_| |_|j|} | r.| |_q.W|S)a{ Load library ``name`` and return a :class:`ctypes.CDLL` object for it. :param str name: the library name :param signatures: signatures of methods :type signatures: dict of str * (tuple of (list of type) * type) :param error_checkers: error checkers for methods :type error_checkers: dict of str * ((int * ptr * arglist) -> int) The library has errno handling enabled. Important functions are given proper signatures and return types to support type checking and argument conversion. :returns: a loaded library :rtype: ctypes.CDLL :raises ImportError: if the library is not found zNo library named %sT)Z use_errnoN) r ImportErrorritemsgetattrargtypesrestypegetZerrcheck) nameZ signaturesZerror_checkersZ library_namelibfuncnameZ signatureZfunctionr r Z errorcheckerr/usr/lib/python3.6/utils.pyload_ctypes_library$s     rN) __doc__Z __future__rrrrZctypesrZ ctypes.utilrrrrrrs      __pycache__/_errorcheckers.cpython-36.pyc000064400000004555152536714120014421 0ustar003 u1W @sdZddlmZddlmZddlmZddlmZddlZddlZddlm Z ej e ej e ejeiZdd Zd d Zd d ZddZdS)zt pyudev._ctypeslib._errorcheckers ================================ Error checkers for ctypes wrappers. )absolute_import)division)print_function)unicode_literalsN) get_errnocCs2tj|}tj|}|dk r$||St||SdS)zCreate an exception from ``errnum``. ``errnum`` is an integral error number. Return an exception object appropriate to ``errnum``. N)ERRNO_EXCEPTIONSgetosstrerrorEnvironmentError)errnumZ exceptionZerrorstrr $/usr/lib/python3.6/_errorcheckers.pyexception_from_errno+s   rcGs |dkr| }t|n|SdS)aError checker for funtions, which return negative error codes. If ``result`` is smaller than ``0``, it is interpreted as negative error code, and an appropriate exception is raised: - ``-ENOMEM`` raises a :exc:`~exceptions.MemoryError` - ``-EOVERFLOW`` raises a :exc:`~exceptions.OverflowError` - all other error codes raise :exc:`~exceptions.EnvironmentError` If result is greater or equal to ``0``, it is returned unchanged. rN)r)resultfuncargsr r r rcheck_negative_errorcode;s  rcGs"|dkrt}|dkrt||S)zError checker to check the system ``errno`` as returned by :func:`ctypes.get_errno()`. If ``result`` is not ``0``, an exception according to this errno is raised. Otherwise nothing happens. r)rr)rrrr r r rcheck_errno_on_nonzero_returnPs rcGs|st}|dkrt||S)zError checker to check the system ``errno`` as returned by :func:`ctypes.get_errno()`. If ``result`` is a null pointer, an exception according to this errno is raised. Otherwise nothing happens. r)rr)rrrr r r r"check_errno_on_null_pointer_return_s r)__doc__Z __future__rrrrr errnoZctypesrZENOMEM MemoryErrorZ EOVERFLOW OverflowErrorZEINVAL ValueErrorrrrrrr r r rs      __pycache__/libc.cpython-36.pyc000064400000001177152536714120012327 0ustar003 u1W<@stdZddlmZddlmZddlmZddlmZddlmZddlm Z ed Z e e egefd Z e e d Z d S) z pyudev._ctypeslib.libc ====================== Wrappers for libc. .. moduleauthor:: Sebastian Wiesner )absolute_import)division)print_function)unicode_literals)c_int)check_errno_on_nonzero_return)pipe2N)__doc__Z __future__rrrrZctypesrZ_errorcheckersrZfd_pairdictZ SIGNATURESZERROR_CHECKERSr r /usr/lib/python3.6/libc.pys      __pycache__/__init__.cpython-36.pyc000064400000000476152536714120013156 0ustar003 HV@s dZddlmZddlmZdS)z pyudev._ctypeslib ================= Wrappers for libraries. .. moduleauthor:: mulhern )libc)libudevN)__doc__rrrr/usr/lib/python3.6/__init__.pys libudev.py000064400000025053152536714120006563 0ustar00# -*- coding: utf-8 -*- # Copyright (C) 2010, 2011, 2012, 2013 Sebastian Wiesner # This library is free software; you can redistribute it and/or modify it # under the terms of the GNU Lesser General Public License as published by the # Free Software Foundation; either version 2.1 of the License, or (at your # option) any later version. # This library is distributed in the hope that it will be useful, but WITHOUT # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License # for more details. # You should have received a copy of the GNU Lesser General Public License # along with this library; if not, write to the Free Software Foundation, # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA """ pyudev._ctypeslib.libudev ========================= Wrapper types for libudev. Use ``libudev`` attribute to access libudev functions. .. moduleauthor:: Sebastian Wiesner """ from __future__ import absolute_import from __future__ import division from __future__ import print_function from __future__ import unicode_literals from ctypes import c_char from ctypes import c_char_p from ctypes import c_int from ctypes import c_uint from ctypes import c_ulonglong from ctypes import CDLL from ctypes import Structure from ctypes import POINTER from ctypes.util import find_library from ._errorcheckers import check_errno_on_nonzero_return from ._errorcheckers import check_errno_on_null_pointer_return from ._errorcheckers import check_negative_errorcode class udev(Structure): # pylint: disable=invalid-name """ Dummy for ``udev`` structure. """ # pylint: disable=too-few-public-methods pass udev_p = POINTER(udev) # pylint: disable=invalid-name class udev_enumerate(Structure): # pylint: disable=invalid-name """ Dummy for ``udev_enumerate`` structure. """ # pylint: disable=too-few-public-methods pass udev_enumerate_p = POINTER(udev_enumerate) # pylint: disable=invalid-name class udev_list_entry(Structure): # pylint: disable=invalid-name """ Dummy for ``udev_list_entry`` structure. """ # pylint: disable=too-few-public-methods pass udev_list_entry_p = POINTER(udev_list_entry) # pylint: disable=invalid-name class udev_device(Structure): # pylint: disable=invalid-name """ Dummy for ``udev_device`` structure. """ # pylint: disable=too-few-public-methods pass udev_device_p = POINTER(udev_device) # pylint: disable=invalid-name class udev_monitor(Structure): # pylint: disable=invalid-name """ Dummy for ``udev_device`` structure. """ # pylint: disable=too-few-public-methods pass udev_monitor_p = POINTER(udev_monitor) # pylint: disable=invalid-name class udev_hwdb(Structure): # pylint: disable=invalid-name """ Dummy for ``udev_hwdb`` structure. """ # pylint: disable=too-few-public-methods pass udev_hwdb_p = POINTER(udev_hwdb) # pylint: disable=invalid-name dev_t = c_ulonglong # pylint: disable=invalid-name SIGNATURES = dict( # context udev_new=([], udev_p), udev_unref=([udev_p], None), udev_ref=([udev_p], udev_p), udev_get_sys_path=([udev_p], c_char_p), udev_get_dev_path=([udev_p], c_char_p), udev_get_run_path=([udev_p], c_char_p), udev_get_log_priority=([udev_p], c_int), udev_set_log_priority=([udev_p, c_int], None), udev_enumerate_new=([udev_p], udev_enumerate_p), udev_enumerate_ref=([udev_enumerate_p], udev_enumerate_p), udev_enumerate_unref=([udev_enumerate_p], None), udev_enumerate_add_match_subsystem=([udev_enumerate_p, c_char_p], c_int), udev_enumerate_add_nomatch_subsystem=([udev_enumerate_p, c_char_p], c_int), udev_enumerate_add_match_property=( [udev_enumerate_p, c_char_p, c_char_p], c_int ), udev_enumerate_add_match_sysattr=( [udev_enumerate_p, c_char_p, c_char_p], c_int ), udev_enumerate_add_nomatch_sysattr=( [udev_enumerate_p, c_char_p, c_char_p], c_int ), udev_enumerate_add_match_tag=([udev_enumerate_p, c_char_p], c_int), udev_enumerate_add_match_sysname=([udev_enumerate_p, c_char_p], c_int), udev_enumerate_add_match_parent=([udev_enumerate_p, udev_device_p], c_int), udev_enumerate_add_match_is_initialized=([udev_enumerate_p], c_int), udev_enumerate_scan_devices=([udev_enumerate_p], c_int), udev_enumerate_get_list_entry=([udev_enumerate_p], udev_list_entry_p), # list entries udev_list_entry_get_next=([udev_list_entry_p], udev_list_entry_p), udev_list_entry_get_name=([udev_list_entry_p], c_char_p), udev_list_entry_get_value=([udev_list_entry_p], c_char_p), # devices udev_device_ref=([udev_device_p], udev_device_p), udev_device_unref=([udev_device_p], None), udev_device_new_from_syspath=([udev_p, c_char_p], udev_device_p), udev_device_new_from_subsystem_sysname=( [udev_p, c_char_p, c_char_p], udev_device_p ), udev_device_new_from_devnum=([udev_p, c_char, dev_t], udev_device_p), udev_device_new_from_device_id=([udev_p, c_char_p], udev_device_p), udev_device_new_from_environment=([udev_p], udev_device_p), udev_device_get_parent=([udev_device_p], udev_device_p), udev_device_get_parent_with_subsystem_devtype=( [udev_device_p, c_char_p, c_char_p], udev_device_p ), udev_device_get_devpath=([udev_device_p], c_char_p), udev_device_get_subsystem=([udev_device_p], c_char_p), udev_device_get_syspath=([udev_device_p], c_char_p), udev_device_get_sysnum=([udev_device_p], c_char_p), udev_device_get_sysname=([udev_device_p], c_char_p), udev_device_get_driver=([udev_device_p], c_char_p), udev_device_get_devtype=([udev_device_p], c_char_p), udev_device_get_devnode=([udev_device_p], c_char_p), udev_device_get_property_value=([udev_device_p, c_char_p], c_char_p), udev_device_get_sysattr_value=([udev_device_p, c_char_p], c_char_p), udev_device_get_devnum=([udev_device_p], dev_t), udev_device_get_action=([udev_device_p], c_char_p), udev_device_get_seqnum=([udev_device_p], c_ulonglong), udev_device_get_is_initialized=([udev_device_p], c_int), udev_device_get_usec_since_initialized=([udev_device_p], c_ulonglong), udev_device_get_devlinks_list_entry=([udev_device_p], udev_list_entry_p), udev_device_get_tags_list_entry=([udev_device_p], udev_list_entry_p), udev_device_get_properties_list_entry=([udev_device_p], udev_list_entry_p), udev_device_get_sysattr_list_entry=([udev_device_p], udev_list_entry_p), udev_device_set_sysattr_value=([udev_device_p, c_char_p, c_char_p], c_int), udev_device_has_tag=([udev_device_p, c_char_p], c_int), # monitoring udev_monitor_ref=([udev_monitor_p], udev_monitor_p), udev_monitor_unref=([udev_monitor_p], None), udev_monitor_new_from_netlink=([udev_p, c_char_p], udev_monitor_p), udev_monitor_enable_receiving=([udev_monitor_p], c_int), udev_monitor_set_receive_buffer_size=([udev_monitor_p, c_int], c_int), udev_monitor_get_fd=([udev_monitor_p], c_int), udev_monitor_receive_device=([udev_monitor_p], udev_device_p), udev_monitor_filter_add_match_subsystem_devtype=( [udev_monitor_p, c_char_p, c_char_p], c_int), udev_monitor_filter_add_match_tag=([udev_monitor_p, c_char_p], c_int), udev_monitor_filter_update=([udev_monitor_p], c_int), udev_monitor_filter_remove=([udev_monitor_p], c_int), # hwdb udev_hwdb_ref=([udev_hwdb_p], udev_hwdb_p), udev_hwdb_unref=([udev_hwdb_p], None), udev_hwdb_new=([udev_p], udev_hwdb_p), udev_hwdb_get_properties_list_entry=( [udev_hwdb_p, c_char_p, c_uint], udev_list_entry_p ) ) ERROR_CHECKERS = dict( udev_device_get_action=None, udev_device_get_devlinks_list_entry=None, udev_device_get_devnode=None, udev_device_get_devnum=None, udev_device_get_devpath=None, udev_device_get_devtype=None, udev_device_get_driver=None, udev_device_get_is_initialized=None, udev_device_get_parent=None, udev_device_get_parent_with_subsystem_devtype=None, udev_device_get_properties_list_entry=None, udev_device_get_property_value=None, udev_device_get_seqnum=None, udev_device_get_subsystem=None, udev_device_get_sysattr_list_entry=None, udev_device_get_sysattr_value=None, udev_device_get_sysname=None, udev_device_get_sysnum=None, udev_device_get_syspath=None, udev_device_get_tags_list_entry=None, udev_device_get_usec_since_initialized=None, udev_device_has_tag=None, udev_device_new_from_device_id=None, udev_device_new_from_devnum=None, udev_device_new_from_environment=None, udev_device_new_from_subsystem_sysname=None, udev_device_new_from_syspath=None, udev_device_ref=None, udev_device_unref=None, udev_device_set_sysattr_value=check_negative_errorcode, udev_enumerate_add_match_parent=check_negative_errorcode, udev_enumerate_add_match_subsystem=check_negative_errorcode, udev_enumerate_add_nomatch_subsystem=check_negative_errorcode, udev_enumerate_add_match_property=check_negative_errorcode, udev_enumerate_add_match_sysattr=check_negative_errorcode, udev_enumerate_add_nomatch_sysattr=check_negative_errorcode, udev_enumerate_add_match_tag=check_negative_errorcode, udev_enumerate_add_match_sysname=check_negative_errorcode, udev_enumerate_add_match_is_initialized=check_negative_errorcode, udev_enumerate_get_list_entry=None, udev_enumerate_new=None, udev_enumerate_ref=None, udev_enumerate_scan_devices=None, udev_enumerate_unref=None, udev_get_dev_path=None, udev_get_log_priority=None, udev_get_run_path=None, udev_get_sys_path=None, udev_hwdb_get_properties_list_entry=None, udev_hwdb_new=None, udev_hwdb_ref=None, udev_hwdb_unref=None, udev_list_entry_get_name=None, udev_list_entry_get_next=None, udev_list_entry_get_value=None, udev_monitor_set_receive_buffer_size=check_errno_on_nonzero_return, # libudev doc says, enable_receiving returns a negative errno, but tests # show that this is not reliable, so query the real error code udev_monitor_enable_receiving=check_errno_on_nonzero_return, udev_monitor_receive_device=check_errno_on_null_pointer_return, udev_monitor_ref=None, udev_monitor_filter_add_match_subsystem_devtype=check_negative_errorcode, udev_monitor_filter_add_match_tag=check_negative_errorcode, udev_monitor_filter_update=check_errno_on_nonzero_return, udev_monitor_filter_remove=check_errno_on_nonzero_return, udev_monitor_get_fd=None, udev_monitor_new_from_netlink=None, udev_monitor_unref=None, udev_new=None, udev_ref=None, udev_set_log_priority=None, udev_unref=None ) libc.py000064400000002474152536714120006044 0ustar00# -*- coding: utf-8 -*- # Copyright (C) 2013 Sebastian Wiesner # This library is free software; you can redistribute it and/or modify it # under the terms of the GNU Lesser General Public License as published by the # Free Software Foundation; either version 2.1 of the License, or (at your # option) any later version. # This library is distributed in the hope that it will be useful, but WITHOUT # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License # for more details. # You should have received a copy of the GNU Lesser General Public License # along with this library; if not, write to the Free Software Foundation, # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA """ pyudev._ctypeslib.libc ====================== Wrappers for libc. .. moduleauthor:: Sebastian Wiesner """ from __future__ import absolute_import from __future__ import division from __future__ import print_function from __future__ import unicode_literals from ctypes import c_int from ._errorcheckers import check_errno_on_nonzero_return fd_pair = c_int * 2 SIGNATURES = dict( pipe2=([fd_pair, c_int], c_int), ) ERROR_CHECKERS = dict( pipe2=check_errno_on_nonzero_return, ) utils.py000064400000004651152536714120006272 0ustar00# -*- coding: utf-8 -*- # Copyright (C) 2013 Sebastian Wiesner # This library is free software; you can redistribute it and/or modify it # under the terms of the GNU Lesser General Public License as published by the # Free Software Foundation; either version 2.1 of the License, or (at your # option) any later version. # This library is distributed in the hope that it will be useful, but WITHOUT # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License # for more details. # You should have received a copy of the GNU Lesser General Public License # along with this library; if not, write to the Free Software Foundation, # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA """ pyudev._ctypeslib.utils ======================= Utilities for loading ctypeslib. .. moduleauthor:: Anne Mulhern """ from __future__ import absolute_import from __future__ import division from __future__ import print_function from __future__ import unicode_literals from ctypes import CDLL from ctypes.util import find_library def load_ctypes_library(name, signatures, error_checkers): """ Load library ``name`` and return a :class:`ctypes.CDLL` object for it. :param str name: the library name :param signatures: signatures of methods :type signatures: dict of str * (tuple of (list of type) * type) :param error_checkers: error checkers for methods :type error_checkers: dict of str * ((int * ptr * arglist) -> int) The library has errno handling enabled. Important functions are given proper signatures and return types to support type checking and argument conversion. :returns: a loaded library :rtype: ctypes.CDLL :raises ImportError: if the library is not found """ library_name = find_library(name) if not library_name: raise ImportError('No library named %s' % name) lib = CDLL(library_name, use_errno=True) # Add function signatures for funcname, signature in signatures.items(): function = getattr(lib, funcname, None) if function: argtypes, restype = signature function.argtypes = argtypes function.restype = restype errorchecker = error_checkers.get(funcname) if errorchecker: function.errcheck = errorchecker return lib __init__.py000064400000001717152536714130006672 0ustar00# -*- coding: utf-8 -*- # Copyright (C) 2015 mulhern # This library is free software; you can redistribute it and/or modify it # under the terms of the GNU Lesser General Public License as published by the # Free Software Foundation; either version 2.1 of the License, or (at your # option) any later version. # This library is distributed in the hope that it will be useful, but WITHOUT # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License # for more details. # You should have received a copy of the GNU Lesser General Public License # along with this library; if not, write to the Free Software Foundation, # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA """ pyudev._ctypeslib ================= Wrappers for libraries. .. moduleauthor:: mulhern """ from . import libc from . import libudev