How do I search inside long descriptions

Ryan Schmidt ryandesign at macports.org
Tue Jun 19 02:56:34 PDT 2007


On Jun 19, 2007, at 04:20, Randall Wood wrote:

> On 19 Jun 2007, at 05:08, Ryan Schmidt wrote:
>
>> On Jun 19, 2007, at 02:18, Malcolm Fitzgerald wrote:
>>
>>> On 19/06/2007, at 4:35 PM, paul beard wrote:
>>>
>>>> On Jun 18, 2007, at 11:30 PM, Malcolm Fitzgerald wrote:
>>>>
>>>>> The words "known-good port" represent the blank that I'm trying  
>>>>> to fill. I want to be able to search for text inside the port's  
>>>>> long-description. I'd like to discover the "known-good"  
>>>>> spreadsheets, etc that are in MacPorts. At present I have to go  
>>>>> to the the freebsd ports web site, search there, then see if  
>>>>> any of the ports that I've found are available in MacPorts.
>>>>
>>>> Yeah, I missed that in your question somehow.
>>>>
>>>> Might be worth just dumping a list and seeing if you recognize  
>>>> any, assuming you're familiar with some of the names.
>>>
>>> Well, that's half the problem. I'd like to be able to explore and  
>>> discover new things.
>>
>> In lieu of a MacPorts command to do this, since there isn't one  
>> that I know of, you could grep the entire text of all the  
>> portfiles. This won't work well if the string you're searching for  
>> is a language keyword, MacPorts category, username or other text  
>> that appears in many portfiles, but for example for "spreadsheet"  
>> it gives this:
>>
>> $ grep 'spreadsheet' */*/Portfile
>> gnome/gnumeric/Portfile:description     A spreadsheet with gnome  
>> support.
>> gnome/gnumeric/Portfile:long_description        A spreadsheet with  
>> gnome support.
>> math/oleo/Portfile:description                  Lightweight  
>> spreadsheet program
>> math/oleo/Portfile:     GNU Oleo is a spreadsheet program with the  
>> following features: \
>> math/oleo/Portfile:     Charts generated from spreadsheet data  
>> (interface is not yet stable, \
>> perl/p5-sql-translator/ 
>> Portfile:                                        port:p5-io- 
>> stringy port:p5-spreadsheet-parseexcel \
>> python/py-xlrd/Portfile:description             module to extract  
>> data from Microsoft Excel spreadsheet files
>> python/py-xlrd/Portfile:                        Excel spreadsheet  
>> files.
>> python/py-xlwriter/Portfile:description         python module for  
>> writing Excel spreadsheets
>> python/py-xlwriter/Portfile:                             
>> spreadsheets. It is a port of John McNamara's Perl \
>> python/py-xlwriter/Portfile:                            It allows  
>> writing of Excel spreadsheets without the \
>> textproc/catdoc/Portfile:                converts Excel  
>> spreadsheet into comma-separated value \
>> www/autobench/Portfile:    spreadsheet for analysis/graphing.
>> x11/siag/Portfile:                      It consists of the  
>> spreadsheet Siag, the word processor PW, \
>>
>> Run this in your ports tree directory. If you don't know where  
>> that is, one way to get to it is like this:
>>
>> cd `port dir e`/../..
>>
>> There's probably a better way to do that but that works. Then, if  
>> your grep turns up something interesting, you can of course learn  
>> more about the port with "port info <PORTNAME>".
>
> If you install the Pallet port, it provides a not-really working  
> tool to manage ports, but it does work to search long descriptions,  
> categories, descriptions, as well as port names.

Oh, well that's certainly nice. I was going to say one could also  
cook up a more elaborate script, like this one, which you can put in  
your ~/.bash_profile or comparable:


---------- >8 ---------- SNIP ---------- >8 ----------

port() {
	case "$1" in
		searchlong)
			if [ -z "$2" ]; then
				echo "usage: port searchlong <searchterm>" 1>&2
			else
				SEARCH="$2"
				for PORT in `port echo all`; do
					echo -n .
					FOUND=`port info --long_description ${PORT} | sed s% 
^long_description%${PORT}% | grep "${SEARCH}"`
					if [ ! -z "${FOUND}" ]; then
						echo
						echo ${FOUND}
					fi
				done
			fi
			;;
		*)
			/opt/local/bin/port "$@"
			;;
	esac
}

---------- >8 ---------- SNIP ---------- >8 ----------


But this is not, it must be said, a very fast script. On my system,  
it's only searching a couple or four portfiles a second, and we now  
have over 4000 portfiles. So that puts it at at least 17 minutes to  
search all portfiles. Which is rather awful. But, it does search the  
long_description, and only the long_description, of each portfile.

In fact, I'm getting tired of waiting for it to run, so here's merely  
the incomplete output:

$ port searchlong spreadsheet
........................................................................ 
........................................................................ 
........................................................................ 
.......................................
autobench: Autobench is a simple Perl script for automating the  
process of benchmarking a web server (or for conducting a comparative  
test of two different web servers). The script is a wrapper around  
httperf. Autobench runs httperf a number of times against each host,  
increasing the number of requested connections per second on each  
iteration, and extracts the significant data from the httperf output,  
delivering a CSV or TSV format file which can be imported directly  
into a spreadsheet for analysis/graphing.
........................................................................ 
........................................................................ 
......
catdoc: catdoc is program which reads one or more Microsoft word  
files and outputs text, contained insinde them to standard output.  
Therefore it does same work for .doc files, as unix cat command for  
plain ASCII files. It is now accompanied by xls2csv - program which  
converts Excel spreadsheet into comma-separated value file. Newest  
addition to catdoc suite is catppt - a program, which extracts  
readable text from the PowerPoint files.
........................................................................ 
........................................................................ 
........................................................................ 
........................................................................ 
........................................................................ 
........................................................................ 
........................................................................ 
........................................................................ 
..................................................
gnumeric: A spreadsheet with gnome support.
........................................................................ 
........................................................................ 
........................................................................ 
............................................................^C





More information about the macports-users mailing list