1
0
mirror of https://gitlab.com/libvirt/libvirt-python.git synced 2024-10-26 16:25:10 +03:00

generator: Convert list() to set()

tuple() and list() are sequences, while dict() and set() are hash-based,
which is more efficient for contains().

Signed-off-by: Philipp Hahn <hahn@univention.de>
This commit is contained in:
Philipp Hahn 2020-04-23 07:39:04 +02:00 committed by Jano Tomko
parent fe100b90ef
commit 099459096a

View File

@ -246,11 +246,12 @@ def qemu_enum(type, name, value):
functions_failed = [] functions_failed = []
lxc_functions_failed = [] lxc_functions_failed = []
qemu_functions_failed = [] qemu_functions_failed = []
functions_skipped = [
functions_skipped = {
"virConnectListDomains", "virConnectListDomains",
] }
lxc_functions_skipped = [] lxc_functions_skipped = set()
qemu_functions_skipped = [] qemu_functions_skipped = set()
skipped_types = { skipped_types = {
# 'int *': "usually a return type", # 'int *': "usually a return type",
@ -356,7 +357,7 @@ unknown_types = {}
# Class methods which are written by hand in libvirt.c but the Python-level # Class methods which are written by hand in libvirt.c but the Python-level
# code is still automatically generated (so they are not in skip_function()). # code is still automatically generated (so they are not in skip_function()).
skip_impl = ( skip_impl = {
'virConnectGetVersion', 'virConnectGetVersion',
'virConnectGetLibVersion', 'virConnectGetLibVersion',
'virConnectListDomainsID', 'virConnectListDomainsID',
@ -479,22 +480,22 @@ skip_impl = (
'virNetworkPortGetParameters', 'virNetworkPortGetParameters',
'virNetworkPortSetParameters', 'virNetworkPortSetParameters',
'virDomainGetGuestInfo', 'virDomainGetGuestInfo',
) }
lxc_skip_impl = ( lxc_skip_impl = {
'virDomainLxcOpenNamespace', 'virDomainLxcOpenNamespace',
) }
qemu_skip_impl = ( qemu_skip_impl = {
'virDomainQemuMonitorCommand', 'virDomainQemuMonitorCommand',
'virDomainQemuAgentCommand', 'virDomainQemuAgentCommand',
) }
# These are functions which the generator skips completely - no python # These are functions which the generator skips completely - no python
# or C code is generated. Generally should not be used for any more # or C code is generated. Generally should not be used for any more
# functions than those already listed # functions than those already listed
skip_function = ( skip_function = {
'virConnectListDomains', # Python API is called virConnectListDomainsID for unknown reasons 'virConnectListDomains', # Python API is called virConnectListDomainsID for unknown reasons
'virConnSetErrorFunc', # Not used in Python API XXX is this a bug ? 'virConnSetErrorFunc', # Not used in Python API XXX is this a bug ?
'virResetError', # Not used in Python API XXX is this a bug ? 'virResetError', # Not used in Python API XXX is this a bug ?
@ -613,30 +614,30 @@ skip_function = (
'virDomainFSInfoFree', # only useful in C, python code uses list 'virDomainFSInfoFree', # only useful in C, python code uses list
'virDomainIOThreadInfoFree', # only useful in C, python code uses list 'virDomainIOThreadInfoFree', # only useful in C, python code uses list
'virDomainInterfaceFree', # only useful in C, python code uses list 'virDomainInterfaceFree', # only useful in C, python code uses list
) }
lxc_skip_function = ( lxc_skip_function = {
"virDomainLxcEnterNamespace", "virDomainLxcEnterNamespace",
"virDomainLxcEnterSecurityLabel", "virDomainLxcEnterSecurityLabel",
) }
qemu_skip_function = ( qemu_skip_function = {
# "virDomainQemuAttach", # "virDomainQemuAttach",
'virConnectDomainQemuMonitorEventRegister', # overridden in -qemu.py 'virConnectDomainQemuMonitorEventRegister', # overridden in -qemu.py
'virConnectDomainQemuMonitorEventDeregister', # overridden in -qemu.py 'virConnectDomainQemuMonitorEventDeregister', # overridden in -qemu.py
) }
# Generate C code, but skip python impl # Generate C code, but skip python impl
function_skip_python_impl = ( function_skip_python_impl = {
"virStreamFree", # Needed in custom virStream __del__, but free shouldn't "virStreamFree", # Needed in custom virStream __del__, but free shouldn't
# be exposed in bindings # be exposed in bindings
) }
lxc_function_skip_python_impl = () lxc_function_skip_python_impl = set() # type: Set[str]
qemu_function_skip_python_impl = () qemu_function_skip_python_impl = set() # type: Set[str]
function_skip_index_one = ( function_skip_index_one = {
"virDomainRevertToSnapshot", "virDomainRevertToSnapshot",
) }
def print_function_wrapper(module, name, output, export, include): def print_function_wrapper(module, name, output, export, include):
@ -926,7 +927,7 @@ def buildStubs(module, api_xml):
del funcs[function] del funcs[function]
if ret == 0: if ret == 0:
skipped += 1 skipped += 1
funcs_skipped.append(function) funcs_skipped.add(function)
del funcs[function] del funcs[function]
if ret == 1: if ret == 1:
nb_wrap += 1 nb_wrap += 1