Re: Inital Deb Filter
- From: "Kevin Kubasik" <kevin kubasik net>
- To: "Joe Shaw" <joeshaw novell com>
- Cc: "dashboard-hackers gnome org" <dashboard-hackers gnome org>
- Subject: Re: Inital Deb Filter
- Date: Wed, 19 Apr 2006 07:54:17 -0400
Ok, here is the fixed FilterDeb.cs I'll wait to hear from you on the UI stuff.
Cheers,
Kevin Kubasik
On 4/18/06, Kevin Kubasik <kevin kubasik net> wrote:
> <SNIP>
> > > //
> <SNIP>
> > > Description = StringFu.FileLengthToString( Convert.ToInt64 ( hit["fixme:size"]+"00"));
> >
> > First, it looks like your search and replace to add spaces was
> > backwards. :) But more importantly, what's with adding two zeros to the
> > end of a numeric string? If the size is off by 100x, that's a bug, and
> > we shouldn't be working around it.
>
> Ok, Its just how dpkg-deb outputs it (in kb's)
> >
> > > if(my_hit.FileInfo.Extension == ".rpm" && my_hit["dc:description"] != null){
> > > string[] temp= new string[my_query.Text.Count];
> > > my_query.Text.CopyTo(temp,0);
> > >
> > > details.AddLabelPair("Description:",
> > > SnippetFu.GetSnippet(temp , new StringReader(my_hit["dc:description"])),3,1);
> > > return details;
> > > }
> >
> > I think what you're trying to do here is ellipsize the text of the
> > description, which might be quite long, correct? If so, this is the
> > wrong way to do it, because it calls into the daemon's private
> > assemblies. (A lot of stuff marked "public" should probably be marked
> > "internal" in there.) What you want is to create a label and then call
> > beagle-search's WidgetFu.EllipsizeLabel().
> >
>
> Forgive my ignorance, but what exactly is a Ellipsizing? I just wanted
> to get only the parts of the description that contained the words
> searched for.
>
> The whitespace changes are easy, and i'll take care of those. Do we
> just wanna scrap the UI tile?
>
> --
> Cheers,
> Kevin Kubasik
> http://blog.kubasik.net/
>
--
Cheers,
Kevin Kubasik
http://blog.kubasik.net/
//
// FilterDeb.cs: Extracts basic information from .deb archives
//
// Written By: Kevin Kubasik <kevin kubasik net>
//
using System;
using System.IO;
using System.Diagnostics;
using Beagle.Daemon;
using Beagle.Util;
namespace Beagle.Filters {
public class FilterDeb : Beagle.Daemon.Filter {
public FilterDeb (){
AddSupportedFlavor ( FilterFlavor.NewFromMimeType ("application/x-deb"));
SnippetMode = true;
}
protected override void DoPullProperties (){
SafeProcess pc = new SafeProcess ();
pc.Arguments = new string [] { "dpkg-deb", "-I", FileInfo.FullName};
pc.RedirectStandardOutput = true;
try {
pc.Start ();
} catch (SafeProcessException e) {
Log.Warn ( e.Message );
Error ();
return;
}
StreamReader pout = new StreamReader ( pc.StandardOutput );
string str = null;
string[] tokens = null;
string strMetaTag = null;
char[] splits = { ',' , '|' };
string[] list = null;
while ((str = pout.ReadLine ()) != null) {
strMetaTag = null;
tokens = str.Split ( ':' );
if ( tokens.Length <= 1 )
continue;
switch ( tokens[0].Trim() ) {
case "Package":
AddProp ( "dc:title" , tokens[1] );
break;
case "Maintainer":
list = tokens[1].Split( '<' );
AddProp ( "dc:author" , list[0] );
AddProp ( "fixme:author_email" , list[1].Replace ( '>' , ' ' ));
break;
case "Version":
AddUnsearched ( "fixme:version" , tokens[1] );
break;
case "Section":
AddUnsearched ( "fixme:section" , tokens[1] );
break;
case "Architecture":
AddUnsearched ( "fixme:arch" , tokens[1] );
break;
case "Depends":
list = tokens[1].Split( splits );
foreach ( string s in list )
AddUnsearched ( "fixme:dep" , s );
break;
case "Recommends":
list = tokens[1].Split (splits);
foreach(string s in list)
AddUnsearched ("fixme:recommend",s);
break;
case "Conflicts":
list = tokens[1].Split (splits);
foreach(string s in list)
AddUnsearched ("fixme:conflict" , s);
break;
case "Replaces":
list = tokens[1].Split (splits);
foreach(string s in list)
AddUnsearched ("fixme:replace" , s);
break;
case "Provides":
list = tokens[1].Split (splits);
foreach(string s in list)
AddUnsearched ("fixme:provide" , s);
break;
case "Installed-Size":
AddUnsearched ("fixme:size" , tokens[1] + "00" );
break;
case "Description":
AppendText (tokens[1]);
AppendStructuralBreak ();
while ((str = pout.ReadLine ()) != null) {
if(str.Trim() == ".")
AppendStructuralBreak ();
else
AppendText (str);
}
break;
}
}
pout.Close ();
pc.Close ();
Finished ();
}
private void AddProp (string strMetaTag, string prop)
{
AddProperty (Beagle.Property.New (strMetaTag, prop.Trim()));
}
private void AddKeyword (string strMetaTag, string word)
{
AddProperty (Beagle.Property.NewKeyword (strMetaTag, word.Trim()));
}
private void AddUnsearched (string strMetaTag, string val)
{
AddProperty (Beagle.Property.NewUnsearched (strMetaTag, val.Trim()));
}
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]