Re: file info feature

"Roger Binns" <[email protected]>
Newsgroups gmane.comp.mobile.bitpim.devel
Message-ID <002101c5f92c$aabeb7b0$e00817ac@rogersqyvr14d3>
> Would an option to enable this information make sense? I am thinking of a
> right click menu checked item like "Enable detail view".

Nah, just have it always displayed.  There is no need for multiple
code paths to maintain.  Anyone already in the filesystem view is
playing with fire so there is no need to be delicate.
 
> I was thinking to use the existing PACKET definitions for decoding files
> rather than defining new ones. 

Yes that is the idea.  There will never be definitions for some files,
but for almost all phone models we already read information directly
from files in a lot of places.

This will greatly speed up development of new definitions (especially
with offline files).

> I have not looked closely as the prototypes compiler, but a requirement
> would be the ability to walk through the fields of the PACKET so that the
> analyzer would not have to be coded for each different packet. The comments
> on each field would be used (if available) to label the contents.

You can just bring up the analyser.  All the code you need is already
there.  You string it together something like this (untested):

def displayfile(filename, theclass):
  buf=prototypes.buffer(self.getfilecontents(filename))
  data=formatdata(buf, theclass)
  frame=analyser.Analyser(parent=..., title=filename, data=data)
  frame.Show(True)

def formatdata(buffer, klass):
  # copied from guiwidgets.logdata (line 105)
  data=("Data - "+`len(data)`+" bytes\n")
  try:
      data+="<#! %s.%s !#>\n" % (klass.__module__, klass.__name__)
  except:
      klass=klass.__class__
      data+="<#! %s.%s !#>\n" % (klass.__module__, klass.__name__)
  return data+common.datatohexstring(data)
 
To turn a string into a class object as in when you got something like
"self.protocolclass.pbgroups":

First look to see if the first item is named "self".  If so then you
set that to be Phone instance from the current phone module.  Then
use getattr for each remaining part and you'll finally have the object
that can be passed directly to displayfile.

If the first item is not "self" then pass the whole string to 
common.getfullname() and use whatever it returns.

> Using XML is OK, is expat an OK parser, there is a python version available,
> it uses the BSD license.

Joe already got XML on his resume (and it looks like some Java programming
as well) :-)  Check out update.py which does XML parsing for the auto update
checker.

I think we'll have to do a fund raising drive to buy him a new underscore
key soon :-)

Roger



-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.