4
AXI_ALIASES = os.environ.get("AXI_ALIASES", "/etc/apt-xapian-index/aliases/:/usr/share/apt-xapian-index/aliases/")
6
def read_db(progress=None):
9
for d in AXI_ALIASES.split(":"):
10
if not os.path.isdir(d): continue
11
for f in os.listdir(d):
12
if f[0] == '.': continue
13
fname = os.path.join(d, f)
14
ts = os.path.getmtime(fname)
17
if progress: progress.verbose("Reading aliases from %s..." % fname)
18
for line in open(fname):
20
# Skip comments and empty lines
21
if not line or line[0][0] == '#': continue
26
def __init__(self, maxts, db):
32
Return general information about the plugin.
34
The information returned is a dict with various keywords:
37
the last modified timestamp of this data source. This will be used
38
to see if we need to update the database or not. A timestamp of 0
39
means that this data source is either missing or always up to date.
41
an array of dicts { name: name, desc: description }, one for every
42
numeric value indexed by this data source.
44
Note that this method can be called before init. The idea is that, if
45
the timestamp shows that this plugin is currently not needed, then the
46
long initialisation can just be skipped.
48
return dict(timestamp = self.maxts)
50
def init(self, info, progress):
52
If needed, perform long initialisation tasks here.
54
info is a dictionary with useful information. Currently it contains
57
"values": a dict mapping index mnemonics to index numbers
59
The progress indicator can be used to report progress.
63
def send_extra_info(self, db=None, **kw):
65
Receive extra parameters from the indexer.
67
This may be called more than once, but after init().
69
We are using this to get the database instance
74
db.add_synonym(row[0], a)
78
Return documentation information for this data source.
80
The documentation information is a dictionary with these keys:
81
name: the name for this data source
82
shortDesc: a short description
83
fullDoc: the full description as a chapter in ReST format
86
name = "Package aliases",
87
shortDesc = "aliases for well known programs",
89
The Aliases data source does not change documents in the index, but
90
adds synonims to the database. Synonims allow to obtain good
91
results while looking for well-know software names, even if such
92
software does not exist in Debian.
96
def index(self, document, pkg):
98
Update the document with the information from this data source.
100
document is the document to update
101
pkg is the python-apt Package object for this package
105
def indexDeb822(self, document, pkg):
107
Update the document with the information from this data source.
109
This is alternative to index, and it is used when indexing with package
110
data taken from a custom Packages file.
112
document is the document to update
113
pkg is the Deb822 object for this package
117
def init(progress=None, **kw):
119
Create and return the plugin object.
121
maxts, db = read_db(progress)
122
if not db: return None
123
return Aliases(maxts, db)