pywincffi.core package¶
Submodules¶
pywincffi.core.checks module¶
Checks¶
Provides functions that are responsible for internal type checks.
-
pywincffi.core.checks.
error_check
(function, code=None, expected=None)[source]¶ Checks the results of a return code against an expected result. If a code is not provided we’ll use
ffi.getwinerror()
to retrieve the code.Parameters: Raises: pywincffi.exceptions.WindowsAPIError – Raised if we receive an unexpected result from a Windows API call
-
pywincffi.core.checks.
input_check
(name, value, allowed_types=None, allowed_values=None)[source]¶ A small wrapper around
isinstance()
. This is mainly meant to be used inside of other functions to pre-validate input rater than using assertions. It’s better to fail early with bad input so more reasonable error message can be provided instead of from somewhere deep in cffi or Windows.Parameters: - name (str) – The name of the input being checked. This is provided so error messages make more sense and can be attributed to specific input arguments.
- value – The value we’re performing the type check on.
- allowed_types – The allowed type or types for
value
. - allowed_values (tuple) – A tuple of allowed values. When provided
value
must be in this tuple otherwiseInputError
will be raised.
Raises: - pywincffi.exceptions.InputError – Raised if
value
is not an instance ofallowed_types
- TypeError – Raised if
allowed_values
is provided and not a tuple.
pywincffi.core.dist module¶
Distribution¶
Module responsible for building the pywincffi distribution
in setup.py
. This module is meant to serve two
purposes. The first is to serve as the main means of loading
the pywincffi library:
>>> from pywincffi.core import dist
>>> ffi, lib = dist.load()
The second is to facilitate a means of building a static library. This is used by the setup.py during the install process to build and install pywincffi as well as a wheel for distribution.
pywincffi.core.logger module¶
Logger¶
This module contains pywincffi’s logger and functions to retrieve new child loggers.
-
pywincffi.core.logger.
get_logger
(name)[source]¶ Returns an instance of
logging.Logger
as a child of pywincffi’s main logger.Parameters: name (str) – The name of the child logger to return. For example, if you provide foo for the name the resulting name will be pywincffi.foo. Raises: ValueError – Raised if name
starts with a dot.Return type: logging.Logger
pywincffi.core.typesbase module¶
Types Base¶
Provides the base types on top of which user visible types will be built.
-
class
pywincffi.core.typesbase.
CFFICDataWrapper
(cdecl, ffi)[source]¶ Bases:
object
Base class for exposing Python types and interfaces to pywincffi users:
- Wraps a CFFI cdata object in self._cdata.
- Delegates attribute getting/setting to self._cdata, supporting structs.
- Delegates item getting/setting to self._cdata, supporting arrays.
Attribute access is not delegated to the wrapped object if the class itself contains such an attribute and that attribute is a descriptor; this is in place to support @property in sub-classes.
Parameters: - cdecl (str) – C type specification as used in ff.new(cdecl)
- ffi (cffi.api.FFI) – FFI instance used to create wrapped cdata object.