13
dict(idx="XRD", qp="reldep:", type="bool",
14
desc="Relation: depends",
15
ldesc="Depends: relationship, package names only"),
16
dict(idx="XRR", qp="relrec:", type="bool",
17
desc="Relation: recommends",
18
ldesc="Recommends: relationship, package names only"),
19
dict(idx="XRS", qp="relsug:", type="bool",
20
desc="Relation: suggests",
21
ldesc="Suggests: relationship, package names only"),
22
dict(idx="XRE", qp="relenh:", type="bool",
23
desc="Relation: ehnances",
24
ldesc="Enhances: relationship, package names only"),
25
dict(idx="XRP", qp="relpre:", type="bool",
26
desc="Relation: pre-depends",
27
ldesc="Pre-Depends: relationship, package names only"),
28
dict(idx="XRB", qp="relbre:", type="bool",
29
desc="Relation: breaks",
30
ldesc="Breaks: relationship, package names only"),
31
dict(idx="XRC", qp="relcon:", type="bool",
32
desc="Relation: conflicts",
33
ldesc="Conflicts: relationship, package names only"),
35
self.prefixes = [(d["idx"], d["ldesc"][:d["ldesc"].find(":")]) for d in self.prefix_desc]
36
self.re_split = re.compile(r"\s*[|,]\s*")
40
Return general information about the plugin.
42
The information returned is a dict with various keywords:
45
the last modified timestamp of this data source. This will be used
46
to see if we need to update the database or not. A timestamp of 0
47
means that this data source is either missing or always up to date.
49
an array of dicts { name: name, desc: description }, one for every
50
numeric value indexed by this data source.
52
Note that this method can be called before init. The idea is that, if
53
the timestamp shows that this plugin is currently not needed, then the
54
long initialisation can just be skipped.
58
prefixes=self.prefix_desc,
60
if kw.get("system", True):
61
if not HAS_APT: return res
62
file = apt_pkg.config.find_file("Dir::Cache::pkgcache")
63
if not os.path.exists(file):
65
ts = os.path.getmtime(file)
69
res["sources"] = [dict(path=file, desc="APT index")]
73
def init(self, info, progress):
75
If needed, perform long initialisation tasks here.
77
info is a dictionary with useful information. Currently it contains
80
"values": a dict mapping index mnemonics to index numbers
82
The progress indicator can be used to report progress.
88
Return documentation information for this data source.
90
The documentation information is a dictionary with these keys:
91
name: the name for this data source
92
shortDesc: a short description
93
fullDoc: the full description as a chapter in ReST format
96
name = "Package relationships",
97
shortDesc = "Debian package relationships",
99
Indexes one term per relationship declared with other packages. All
100
relationship terms have prefixes starting with XR plus an extra
101
prefix letter per relationship type.
103
Terms are built using only the package names in the relationship
104
fields: versioning and boolean operators are ignored.
108
def _index_rel(self, pfx, val, doc):
110
Extract all package names from @val and index them as terms with prefix
113
for name in self.re_split.split(val):
114
doc.add_term(pfx + name.split(None, 1)[0])
116
def index(self, document, pkg):
118
Update the document with the information from this data source.
120
document is the document to update
121
pkg is the python-apt Package object for this package
124
if ver is None: return
126
if rec is None: return
127
for pfx, field in self.prefixes:
128
val = rec.get(field, None)
129
if val is None: continue
130
self._index_rel(pfx, val, document)
132
def indexDeb822(self, document, pkg):
134
Update the document with the information from this data source.
136
This is alternative to index, and it is used when indexing with package
137
data taken from a custom Packages file.
139
document is the document to update
140
pkg is the Deb822 object for this package
142
for pfx, field in self.prefixes:
143
val = pkg.get(field, None)
144
if val is None: continue
145
self._index_rel(pfx, val, document)
149
Create and return the plugin object.