Programming and Scripting :: MyDSL info parser



Quote (roberts @ Jan. 13 2008,01:35)
Also note that I am also now updating a Master List of all extensions.
Use your browser to search it, or download it and use Beaver to search it. Or have fun with grep.


Here's a simple gui that can be used to parse this file, currently by filename, package builder, or extension category.

NOTE: This is a quick test, and should not be considered complete or stable.
The list.txt file must be saved locally
The application must be run from a terminal in order to view any output
Text parsing needs work. The "filename" in particular could be handled better...it will accept Lua string patters, but needs further testing to determine whether certain input could be harmful.

Code Sample
listfile="list.txt"

inputfile=io.open(listfile)
if not inputfile then
 print("can't open "..listfile)
 os.exit(1)
end

data=inputfile:read("*a")
inputfile:close()

function parse_info()
if radio_buttons[1]:value()==1 then searchstring="Location:%s*"..inputs[1]:value()
elseif radio_buttons[2]:value()==1 then searchstring="\nExtension.by:%s*"..inputs[2]:value()
elseif radio_buttons[3]:value()==1 then searchstring="\nTitle:%s*"..inputs[3]:value()
else searchstring=nil
end
if searchstring then
for info in string.gmatch(data,"(Location:.-\n)Location:") do
if string.find(info,searchstring) then
print(info.."\n..........\n")
end
end
end
end

w=fltk:Fl_Window(350,200,"MyDSL Info Search")

radio_labels={"category","extension by","filename"}
radio_buttons={};inputs={}
for i=1,table.getn(radio_labels) do
radio_buttons[i]=fltk:Fl_Radio_Round_Button(10,20*i,100,20,radio_labels[i])
inputs[i]=fltk:Fl_Input(120,20*i,200,20)
end

gobutton=fltk:Fl_Button(10,100,100,20,"go")
gobutton:callback(parse_info)

w:show()
Fl:run()

Hi mikshaw,

I was going to do something here, but I am glad to see that you have started! This could be a replacement to the current box of buttons that I original did.

I was thinking of something along the lines of QBE (Query By Example). Where each field of the info file is displayed as input fields. Then search the list.txt testing each field for corresponding input fields. Display the results in a gui selection list. Then user can scroll results in the GUI and if select Title: field then use its postion -1 to get location. Then easy to feed mydsl-load. Of course, if the use selects something other than title field, display error with help, or iterate backwards to the title field and construct title location to feed mydsl-load.

Finally add a file browser to provide the Load Local feature and we could have a replacment to the existing box-of-buttons currently known as mydsl browser.

If a QBE form is created then it could also be used to create new .info files for those wishing to submit new extensions.

Quote
I was thinking of something along the lines of QBE (Query By Example).

Does murgalua have functional sqlite bindings? I looked at the site but the links to examples and sqlite are broken.

Yes. murgaLua does. I tried importing this into an sqlite db but was only about 90% successful. The comments are full of odd characters that break things. Using blobs might help, but then not sure of search capabilities. Does 750 items warrant using an sql database? It would be easy moving forward. It is the past 10% of the data that is difficult.
I have no experience with or current knowledge of using databases of any kind, but as far as I understand, sqlite is useable in murgaLua.

I've read the QBE explanation 3 times now, and still don't follow it =o)
But I assume it is directed mainly toward the ultimate goal of obtaining the url for a specific extension, which I suppose would be the main purpose of a tool like this. I was just doing it for the sake of figuring out how to grab the text of a specific info file or files, without a solid plan of actually putting that information to any useful purpose.

I'll have to save this thread for further digestion.

Next Page...
original here.