1
0
mirror of https://gitlab.com/libvirt/libvirt-python.git synced 2025-12-13 00:23:49 +03:00
Commit Graph

1075 Commits

Author SHA1 Message Date
Daniel P. Berrangé
2035a5e2f1 Avoid use of thread function deprecated in 3.9
PyEval_ThreadsInitialized was deprecated in 3.9, with deletion targetted
for 3.11. Furthermore since 3.7 it is guaranteed that threads are always
initialized by Py_Initialize(), so checking it is redundant.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2020-11-12 13:30:23 +00:00
Daniel P. Berrangé
4a6f381bd9 Add unit tests for openAuth method
Validate that the type hinting is working as expected

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2020-11-06 10:35:05 +00:00
Jiri Denemark
2822e23156 Post-release version bump to 6.10.0
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2020-11-02 11:19:00 +01:00
Daniel P. Berrangé
3a4d51e266 gitlab: optimize CI job dependencies
Allow more parallelization by giving explicit dependencies between jobs.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
v6.9.0
2020-10-06 12:34:38 +00:00
Daniel P. Berrangé
1f44167510 tests: start basic unit tests for more APIs
To prevent regressions, especially with generated code, we need to have
test coverage of more APIs. This starts off with coverage for object
creation for all object types supported by the test driver
currently. This exercises constructors which have been broken several
times in the past.

Related https://gitlab.com/libvirt/libvirt-python/-/issues/4
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2020-10-06 12:25:14 +01:00
Daniel P. Berrangé
613411502d fix constructor param name for virDomainSnapshot / virDomainCheckpoint
Fixes 7f021c21d6
Resolves https://gitlab.com/libvirt/libvirt-python/-/issues/4

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2020-10-06 11:15:48 +01:00
Jiri Denemark
379a65bd68 Post-release version bump to 6.9.0
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2020-10-01 09:54:11 +02:00
Philipp Hahn
22bfd4bcab generator: Work around type change
a variable should not change its type.

Signed-off-by: Philipp Hahn <hahn@univention.de>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
v6.8.0
2020-09-01 13:26:01 +00:00
Philipp Hahn
d30d872251 generator: Add PEP 484 type annotations
Signed-off-by: Philipp Hahn <hahn@univention.de>
2020-09-01 13:26:01 +00:00
Philipp Hahn
62d99b6dad generator: Merge common code of print_function_wrapper
Signed-off-by: Philipp Hahn <hahn@univention.de>
2020-09-01 13:26:01 +00:00
Philipp Hahn
7f021c21d6 generator: Merge code for __init__ genration
Signed-off-by: Philipp Hahn <hahn@univention.de>
2020-09-01 13:26:01 +00:00
Philipp Hahn
5a2c12278a generator: Expand tuple to names in for loop
Assign tuple to multiple loop variables for better readability

Signed-off-by: Philipp Hahn <hahn@univention.de>
2020-09-01 13:26:01 +00:00
Philipp Hahn
f87eba2fee generator: break lines in generated code
to be closes to pep8 which makes reading the generated code easier and
reduces the number of issues found by flake8.

Signed-off-by: Philipp Hahn <hahn@univention.de>
2020-09-01 13:26:01 +00:00
Philipp Hahn
f7bd89c0bd generator: Use empty string instead of None
for better type checking: both are bool()==False, but None is not str.

Signed-off-by: Philipp Hahn <hahn@univention.de>
2020-09-01 13:26:01 +00:00
Philipp Hahn
4df8e83808 generator: Convert to defaultdict()
for nested dictionaries allows to remove the case distinction for
"first" from "all other" cases.

Signed-off-by: Philipp Hahn <hahn@univention.de>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-09-01 13:26:01 +00:00
Philipp Hahn
87e0ca6390 generator: Move funcs_failed into buildStubs()
The variables are local to that funcion

Signed-off-by: Philipp Hahn <hahn@univention.de>
2020-09-01 13:26:01 +00:00
Philipp Hahn
099459096a 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>
2020-09-01 13:26:01 +00:00
Philipp Hahn
fe100b90ef generator: Convert dict() to set()
Python has a native type for set()s.

Signed-off-by: Philipp Hahn <hahn@univention.de>
2020-09-01 13:26:01 +00:00
Philipp Hahn
3bb106d5e5 generator: Simplify boolean condition
no need to compare with None or empty string.

Signed-off-by: Philipp Hahn <hahn@univention.de>
2020-09-01 13:26:01 +00:00
Philipp Hahn
c95a957084 generator: Simplify loop break
Signed-off-by: Philipp Hahn <hahn@univention.de>
2020-09-01 13:26:01 +00:00
Philipp Hahn
9f6638d3b2 generator: Simplify sorting
Use sorted(..., key=...) instead of using explicit list.sort()

Signed-off-by: Philipp Hahn <hahn@univention.de>
2020-09-01 13:26:01 +00:00
Philipp Hahn
3b9ef6ecad generator: Fixed writing cached=None
Signed-off-by: Philipp Hahn <hahn@univention.de>
2020-09-01 13:26:01 +00:00
Philipp Hahn
88e668c64c generator: Store arguments and return as tuple
instead of list.

Signed-off-by: Philipp Hahn <hahn@univention.de>
2020-09-01 13:26:01 +00:00
Philipp Hahn
3f493a3a6b generator: Expand tuple to names in for loop
Assign tuple to multiple loop variables for better readability

Signed-off-by: Philipp Hahn <hahn@univention.de>
2020-09-01 13:26:01 +00:00
Philipp Hahn
fad7bce226 generator: Initialize with empty strings
instead of using None as this has a different type.

Signed-off-by: Philipp Hahn <hahn@univention.de>
2020-09-01 13:26:01 +00:00
Philipp Hahn
5d12443e50 generator: Simplify XML attribute fetching
Use attr.get(key, default) instead.

Also use the empty sting "" as the default value instead of "None": Both
are "False" when used as a bool()ean, but "None" would require an
explicit check for "not None" in many places as str() and None have
different types.

Signed-off-by: Philipp Hahn <hahn@univention.de>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-09-01 13:26:01 +00:00
Philipp Hahn
425901da21 generator: Convert in_function to bool
Signed-off-by: Philipp Hahn <hahn@univention.de>
2020-09-01 13:26:01 +00:00
Philipp Hahn
d560971513 generator: Use string formatting
instead of sting concatenating.

Signed-off-by: Philipp Hahn <hahn@univention.de>
2020-09-01 13:26:01 +00:00
Philipp Hahn
9be847c7ce generator: Use SAX method names
directly instead of using legacy method names from xmllib.

Depends: 3740a5e4c7
Signed-off-by: Philipp Hahn <hahn@univention.de>
2020-09-01 13:26:01 +00:00
Philipp Hahn
90e861ab4a generator: Remove unused SAX content handler methods
getmethodname()
close()
cdata()

Signed-off-by: Philipp Hahn <hahn@univention.de>
2020-09-01 13:26:01 +00:00
Philipp Hahn
06de635ed2 generator: Refactor parser creation
to use closing context manager.

Signed-off-by: Philipp Hahn <hahn@univention.de>
2020-09-01 13:26:01 +00:00
Philipp Hahn
4d06f2b2fb generator: Open file with context manager
Signed-off-by: Philipp Hahn <hahn@univention.de>
2020-09-01 13:26:01 +00:00
Philipp Hahn
8f354ae738 generator: Use splitlines()
instead of hand-coded implementation.

Signed-off-by: Philipp Hahn <hahn@univention.de>
2020-09-01 13:26:01 +00:00
Philipp Hahn
f36643acac generator: Just walk the dict
instead of generating a list first.

Signed-off-by: Philipp Hahn <hahn@univention.de>
2020-09-01 13:26:01 +00:00
Philipp Hahn
ada1554532 generator: Directly get dict length
instead of generating a list and then counting the elements.

Signed-off-by: Philipp Hahn <hahn@univention.de>
2020-09-01 13:26:01 +00:00
Philipp Hahn
280b1d6640 generator: Walk only the values
instead of the keys and then doing a lookup.

Signed-off-by: Philipp Hahn <hahn@univention.de>
2020-09-01 13:26:01 +00:00
Philipp Hahn
89c453db00 generator: Use dict.item() to walk keys and values
which saves a lookup of each key.

Signed-off-by: Philipp Hahn <hahn@univention.de>
2020-09-01 13:26:01 +00:00
Philipp Hahn
659d0b4dfd generator: Check contained in hash
directly instead of explicitly requesting only the keys as a list and
converting that list to another list.
Checking directly for an element to be contained in a hash is much more
efficient as this is done using hashing O(1) instead of walking the list
in half on average O(n).

Signed-off-by: Philipp Hahn <hahn@univention.de>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-09-01 13:26:01 +00:00
Philipp Hahn
a0798b9bbc generator: Initialize function_classes directly
Signed-off-by: Philipp Hahn <hahn@univention.de>
2020-09-01 13:26:01 +00:00
Philipp Hahn
94b30b7fb7 generator: Remove global declarations
for variables with are not assigned.

Signed-off-by: Philipp Hahn <hahn@univention.de>
2020-09-01 13:26:01 +00:00
Philipp Hahn
f4aefad212 generator: Use string concatenation
:%s,\(\w\+\)\s*=\s*\1\s*+,\1 +=,

Signed-off-by: Philipp Hahn <hahn@univention.de>
2020-09-01 13:26:01 +00:00
Philipp Hahn
9e325358de generator: Use increment assignment
:%s,\(\w\+\)\s*=\s*\1\s*+,\1 +=,

Signed-off-by: Philipp Hahn <hahn@univention.de>
2020-09-01 13:26:01 +00:00
Philipp Hahn
03b558b32e generator: Use enumerate()
instead of manual iteration counting.

Signed-off-by: Philipp Hahn <hahn@univention.de>
2020-09-01 13:26:01 +00:00
Philipp Hahn
4b798e3405 generator: Simplify string concatentaion
by using ''.join() instead of concatenating string fragments in a loop,
which is slower as it required re-hashing the string multiple times.

Signed-off-by: Philipp Hahn <hahn@univention.de>
2020-09-01 13:26:01 +00:00
Philipp Hahn
879dae7483 generator: Use more string formatting
Signed-off-by: Philipp Hahn <hahn@univention.de>
2020-09-01 13:26:01 +00:00
Philipp Hahn
928f5a22e6 generator: Merge now identical if-elif-else cases
Commit ca394b9f "generator: Fix parent type" fixed the case for creating
`virStorage*` instances, which require a reference to `virConnect`, so
the special handling for `._conn` is no longer needed.

Commit ee5c856a "Remove legacy libvirtError arguments" removed the
different arguments, so all cases are the same now.

Signed-off-by: Philipp Hahn <hahn@univention.de>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-09-01 13:26:01 +00:00
Philipp Hahn
2679b06d9c generator: Fix return type on failure
to return a negative value instead of None for consistency.

Signed-off-by: Philipp Hahn <hahn@univention.de>
2020-09-01 13:26:01 +00:00
Philipp Hahn
241e89b713 generator: Remove useless sort key
tuples are sorted by first component anyway.

Signed-off-by: Philipp Hahn <hahn@univention.de>
2020-09-01 13:26:01 +00:00
Philipp Hahn
0132c6d2a9 generator: Remove skipped_modules
Unused.

Signed-off-by: Philipp Hahn <hahn@univention.de>
2020-09-01 13:26:01 +00:00
Philipp Hahn
3b85ec54c9 generator: Remove dead variable assignments
Signed-off-by: Philipp Hahn <hahn@univention.de>
2020-09-01 13:26:01 +00:00