1 # Add origin tags to the index
11 Return general information about the plugin.
13 The information returned is a dict with various keywords:
16 the last modified timestamp of this data source. This will be used
17 to see if we need to update the database or not. A timestamp of 0
18 means that this data source is either missing or always up to date.
20 an array of dicts { name: name, desc: description }, one for every
21 numeric value indexed by this data source.
23 Note that this method can be called before init. The idea is that, if
24 the timestamp shows that this plugin is currently not needed, then the
25 long initialisation can just be skipped.
27 file = apt.apt_pkg.config.find_file("Dir::Cache::pkgcache")
28 if not os.path.exists(file):
29 return dict(timestamp=0)
30 return dict(timestamp=os.path.getmtime(file))
32 def init(self, info, progress):
34 If needed, perform long initialisation tasks here.
36 info is a dictionary with useful information. Currently it contains
39 "values": a dict mapping index mnemonics to index numbers
41 The progress indicator can be used to report progress.
47 Return documentation information for this data source.
49 The documentation information is a dictionary with these keys:
50 name: the name for this data source
51 shortDesc: a short description
52 fullDoc: the full description as a chapter in ReST format
56 shortDesc="Origin information",
58 The Origin data source indexes origin information
62 def index(self, document, pkg):
64 Update the document with the information from this data source.
66 document is the document to update
67 pkg is the python-apt Package object for this package
72 if not ver.downloadable:
73 document.add_term("XOL" + "notdownloadable")
74 for origin in ver.origins:
75 document.add_term("XOA" + origin.archive)
76 document.add_term("XOC" + origin.component)
77 document.add_term("XOL" + origin.label)
78 document.add_term("XOO" + origin.origin)
79 document.add_term("XOS" + origin.site)
81 # FIXME: this doesn't really belong in this file, but we can put it in
82 # here until we get a display_name/display_summary plugin which
83 # is being prepared in the experimental-fastlist branch.
85 # we need this to work around xapian oddness
86 document.add_term(pkg.name.replace('-', '_'))
88 def indexDeb822(self, document, pkg):
90 Update the document with the information from this data source.
92 This is alternative to index, and it is used when indexing with package
93 data taken from a custom Packages file.
95 document is the document to update
96 pkg is the Deb822 object for this package
98 # NOTHING here, does not make sense for non-downloadable data
104 Create and return the plugin object.
106 return OriginPlugin()