pywincffi.core package¶
Submodules¶
pywincffi.core.checks module¶
Checks¶
Provides functions that are responsible for internal type checks.
-
class
pywincffi.core.checks.
CheckMapping
(kind, cname, nullable)¶ Bases:
tuple
-
cname
¶ Alias for field number 1
-
kind
¶ Alias for field number 0
-
nullable
¶ Alias for field number 2
-
-
class
pywincffi.core.checks.
Enums
¶ Bases:
enum.Enum
-
HANDLE
= <Enums.HANDLE: 2>¶
-
NON_ZERO
= <Enums.NON_ZERO: 1>¶
-
OVERLAPPED
= <Enums.OVERLAPPED: 4>¶
-
PYFILE
= <Enums.PYFILE: 5>¶
-
UTF8
= <Enums.UTF8: 3>¶
-
-
pywincffi.core.checks.
error_check
(api_function, code=None, expected=0)[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: - api_function (str) – The Windows API function being called.
- code (int) – An explicit code to compare against. This can be used
instead of asking
ffi.getwinerrro()
to retrieve a code. - expected (int) – The code we expect to have as a result of a successful
call. This can also be passed
pywincffi.core.checks.Enums.NON_ZERO
ifcode
can be anything but zero.
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.1.1/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