1
0
mirror of https://gitlab.com/libvirt/libvirt-python.git synced 2025-07-15 20:59:34 +03:00

Normalize white space

indent by 4 spaces
one spaces around assignments

Signed-off-by: Philipp Hahn <hahn@univention.de>
This commit is contained in:
Philipp Hahn
2018-11-20 08:34:48 +01:00
parent 7c93891420
commit 0ca8dc6340
10 changed files with 429 additions and 374 deletions

View File

@ -78,6 +78,7 @@ class Callback(object):
self.impl.log.debug('callback %d close(), scheduling ff', self.iden)
self.impl.schedule_ff_callback(self.iden, self.opaque)
#
# file descriptors
#
@ -114,8 +115,8 @@ class Descriptor(object):
# For the edge case of empty callbacks, any() returns False.
if any(callback.event & ~(
libvirt.VIR_EVENT_HANDLE_READABLE |
libvirt.VIR_EVENT_HANDLE_WRITABLE)
libvirt.VIR_EVENT_HANDLE_READABLE |
libvirt.VIR_EVENT_HANDLE_WRITABLE)
for callback in self.callbacks.values()):
warnings.warn(
'The only event supported are VIR_EVENT_HANDLE_READABLE '
@ -161,6 +162,7 @@ class Descriptor(object):
self.update()
return callback
class DescriptorDict(dict):
'''Descriptors collection
@ -175,6 +177,7 @@ class DescriptorDict(dict):
self[fd] = descriptor
return descriptor
class FDCallback(Callback):
'''Callback for file descriptor (watcher)
@ -197,6 +200,7 @@ class FDCallback(Callback):
self.event = event
self.descriptor.update()
#
# timeouts
#
@ -242,7 +246,7 @@ class TimeoutCallback(Callback):
if self.timeout >= 0 and self._task is None:
self.impl.log.debug('timer %r start', self.iden)
self._task = ensure_future(self._timer(),
loop=self.impl.loop)
loop=self.impl.loop)
elif self.timeout < 0 and self._task is not None:
self.impl.log.debug('timer %r stop', self.iden)
@ -254,6 +258,7 @@ class TimeoutCallback(Callback):
self.update(timeout=-1)
super(TimeoutCallback, self).close()
#
# main implementation
#
@ -298,7 +303,7 @@ class virEventAsyncIOImpl(object):
# pylint: disable=bad-whitespace
self.log.debug('register()')
libvirt.virEventRegisterImpl(
self._add_handle, self._update_handle, self._remove_handle,
self._add_handle, self._update_handle, self._remove_handle,
self._add_timeout, self._update_timeout, self._remove_timeout)
return self
@ -350,11 +355,11 @@ class virEventAsyncIOImpl(object):
https://libvirt.org/html/libvirt-libvirt-event.html#virEventAddHandleFuncFunc
'''
callback = FDCallback(self, cb, opaque,
descriptor=self.descriptors[fd], event=event)
descriptor=self.descriptors[fd], event=event)
assert callback.iden not in self.callbacks
self.log.debug('add_handle(fd=%d, event=%d, cb=..., opaque=...) = %d',
fd, event, callback.iden)
fd, event, callback.iden)
self.callbacks[callback.iden] = callback
self.descriptors[fd].add_handle(callback)
self._pending_inc()
@ -410,7 +415,7 @@ class virEventAsyncIOImpl(object):
assert callback.iden not in self.callbacks
self.log.debug('add_timeout(timeout=%d, cb=..., opaque=...) = %d',
timeout, callback.iden)
timeout, callback.iden)
self.callbacks[callback.iden] = callback
callback.update(timeout=timeout)
self._pending_inc()
@ -448,10 +453,13 @@ class virEventAsyncIOImpl(object):
_current_impl = None
def getCurrentImpl():
'''Return the current implementation, or None if not yet registered'''
return _current_impl
def virEventRegisterAsyncIOImpl(loop=None):
'''Arrange for libvirt's callbacks to be dispatched via asyncio event loop