1 |
> Thanks for the replies! I know there are a couple programs out there that |
2 |
> basically already do what I'm looking to do... Unfortunately I wasn't aware |
3 |
> of these pre-existing utilities until after I submitted my project proposal |
4 |
> to my professor. So, I'm looking to implement a better search myself. |
5 |
> Preferably by editing the existing portage code, not writing a separate |
6 |
> program. So if anyone can offer any help regarding the actual implementation |
7 |
> of search in portage, I would greatly appreciate it! |
8 |
|
9 |
Most of the search implementation is in |
10 |
/usr/lib/portage/pym/_emerge/__init__.py in class search. The class's |
11 |
execute() method simply iterates over all packages (and descriptions |
12 |
and package sets) and matches against the searchkey. You might need |
13 |
to look into pym/portage/dbapi/porttree.py for portdbapi as well. |
14 |
|
15 |
If you intend to index and support fast regex lookup, then you need to |
16 |
do some fancy indexing, which I'm not terribly familiar with. You |
17 |
could follow in the steps of eix[1] or other indexed search utilities |
18 |
and design some sort of index layout, which is easier than the |
19 |
following thought. You might consider implementing a suffix trie or |
20 |
similar that has sublinear regexp lookup and marshalling the structure |
21 |
for the index. I couldn't find a python implementation for something |
22 |
like this, but here is a general trie class[2] that you might start |
23 |
with if you go that route. There is a perl module[3], |
24 |
Tie::Hash::Regex, that does that, but properly implementing that in |
25 |
python would be a chore. :) |
26 |
|
27 |
That project sounds interesting and fun. Good luck! |
28 |
|
29 |
Lucian Poston |
30 |
|
31 |
[1] https://projects.gentooexperimental.org/eix/wiki/IndexFileLayout |
32 |
[2] http://www.koders.com/python/fid7B6BC1651A9E8BBA547552FE3F039479A4DECC45.aspx |
33 |
[3] http://search.cpan.org/~davecross/Tie-Hash-Regex-1.02/lib/Tie/Hash/Regex.pm |