pywincffi.core package¶
Submodules¶
pywincffi.core.checks module¶
Checks¶
Provides functions that are responsible for internal type checks.
-
class
pywincffi.core.checks.
Enums
¶ Bases:
enum.Enum
-
NON_ZERO
= <Enums.NON_ZERO: 1>¶
-
PYFILE
= <Enums.PYFILE: 3>¶
-
UTF8
= <Enums.UTF8: 2>¶
-
-
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
. This argument also supports a special value,pywincffi.core.checks.Enums.HANDLE
, which will check to ensurevalue
is a handle object. - 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
pywincffi.core.config module¶
Configuration¶
Simple module for loading pywincffi’s configuration, intended
for internal use. A configuration file which is reasonable for
every day use ships with pywincffi but can be overridden at
runtime by dropping a file named pywincffi.ini
in the
current working directory or the current users’s home directory.
-
class
pywincffi.core.config.
Configuration
[source]¶ Bases:
ConfigParser.RawConfigParser
Class responsible for loading and retrieving data from the configuration files. This is used by a few parts of pywincffi to control various aspects of execution.
-
FILES
= ('/home/docs/checkouts/readthedocs.org/user_builds/pywincffi/checkouts/0.3.0/pywincffi/core/pywincffi.ini', '/home/docs/pywincffi.ini', 'pywincffi.ini')¶
-
LOGGER_LEVEL_MAPPINGS
= {'info': 20, 'warning': 30, 'critical': 50, 'error': 40, 'debug': 10, 'notset': 0}¶
-
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 provides functions to configure the logger at runtime.
-
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.