[Tutor] How linux software centers make “search” operation?

Steven D'Aprano steve at pearwood.info
Thu Mar 12 02:21:27 CET 2015


On Thu, Mar 12, 2015 at 01:21:40AM +0200, metis wisdom wrote:
> Hello, I want to develop a software center in Ubuntu similar to Ubuntu
> software center. In ubuntu software center, when we type a keyword and hits
> enter button, it displays us the related results. For example, when i
> searched for "eclipse" keyword, 5 result are listed in ubuntu software
> center.
> 
> I want to do the similar functionality in my software center.

What is your software center?

I don't even know what a software center is, and I don't use Ubuntu. 
This is not an Ubuntu help forum, why do you think we can answer these 
questions?


> I tried to solve this problem by making search in apt package manager using
> bash command(apt search package_name), but it gives all packages as result,
> approximately more than 100 packages.

That's not "all packages", there are thousands of packages in Ubuntu.

If you expect only five results, but get 100, then you are probably not 
using apt search correctly. You should ask some experts on apt, or on an 
Ubuntu mailing list, or just read the man pages:

    man apt

Have you tried using aptitude instead of apt? It might be better for 
you.

Or maybe the Ununtu software center applies additional filtering to the 
list. I have no idea, you say you have analysed the source code so you 
should have a better idea than we do. But my guess is that it calls apt 
with your search terms, then filters the results somehow. Maybe by only 
returning the packages with Eclipse in the name, not the description? 
But I'm only guessing, because I haven't used apt in any detail.


> How ubuntu software center and other software centers search a keyword?
> Where do they search the keyword and retrieve results? Source code of
> ubuntu software center is so complex and i cannot find what i need. Any
> guide will be appreciated. Thanks in advance.

Just because we program in Python doesn't mean we understand everything 
about all technologies. You probably know more about Ubuntu software 
center than we do. Some of us are Windows users, or Red Hat/Centos, or 
Mac users -- we're not experts on Ubuntu or Ubuntu software.


> I analysed all source code of ubuntu software center. These codes includes
> so many technologies that it is very hard to understand it. IN order to
> understand these codes, i have to learn many technologies , it may take at
> least one month,maybe this time may not be enough.

Life is hard, and technology is complex. There are no magic short-cuts 
to understanding.


> After i spent so many
> times learning these technologies, what if these technologies does not
> solve my problem?

What is your problem? What exactly are you trying to do, and how is it 
related to Python?


> I know only python, i am not familiar with os library
> etc, and i have a limited time, please guide me. I need to build a simple
> software center, not a sophisticated one.



-- 
Steve


More information about the Tutor mailing list