blob: 33e1e8f73c2982ba1a9668274c5c3ef5d5dc2a0c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
# R overlay --
# Copyright 2006-2012 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
import uuid
class DependencyResolverListener ( object ):
def __init__ ( self ):
"""
A DependencyResolverListener listens on events sent by the dep resolver.
It has no access to the resolver, use DependencyResolverChannel for that.
"""
# the identifier must be unique and should not be changed after adding
# the listener to the dep resolver
self.ident = id ( self )
# the event mask is a bit vector used to determine whether
# the listener accepts or ignores a specific notification
self.event_mask = 0
# --- end of __init__ (...) ---
def accepts ( self, event_type ):
"""Returns whether this listener modules accepts the given event type.
This can be used to prevent calculations if no module listens to the
specific event.
arguments:
* event_type --
"""
return bool ( self.mask & event_type )
# --- end of accepts (...) ---
def notify ( self, event_type, dep_env=None, pkg_env=None, **extra ):
"""Notify this listener about an event.
arguments:
* event_type --
* dep_env --
* pkg_env --
* @kw extra --
"""
# stub only
pass
# --- end of notify (...) ---
class DependencyResolverChannel ( object ):
def __init__ ( self, main_resolver ):
"""Initializes a DependencyResolverChannel which can be used to
communicate with the dep resolver.
arguments:
* main_resolver -- dep resolver to connect to; setting this to None
results in automatic assignment when registering
with the first dep resolver.
"""
#super ( DependencyResolverChannel, self ) . __init__ ()
# channel identifiers must be unique even when the channel has been
# deleted (id does not guarantee that)
self.ident = uuid.uuid4()
self._depres_master = main_resolver
# --- end of __init__ (...) ---
def set_resolver ( self, resolver, channel_queue=None, **extra ):
"""comment todo."""
self._depres_master = resolver
# --- end of set_resolver (...) ---
def close ( self ):
"""Closes this channel."""
self._depres_master.channel_closed ( self.ident )
del self._depres_master
# --- end of close (...) ---
def enabled ( self ):
"""Returns True if this channel is enabled, else False."""
return True
# --- end of enabled (...) ---
|