Joel Uckelman on Wed, 29 Dec 2004 11:55:41 -0600 (CST)


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

[nimh-dev] formats


I will soon have some code which translates mh-formats into Python, so I've
been thinking about how we want to interact with formats generally. What we
need are 1) a way to load a format, and 2) a way to instantiate the format
using a message and return that as a string:

class Format:
  def __init__(self, filename):
  def exec(msg):
    """Returns the format instantiated to the message passed."""
  def _parsemhformat():
    """Parse the raw mh-format string."""

__init__ will load the format file and figure out whether it's an mh-format
and so needs parsing into Python, or is Python already. Then all you'd have
to do in, say scan, is:

format = Format('scan.default')
for m in msglist:
  print format.exec(m)

Does that seem reasonable? Any suggestions?

_______________________________________________
nimh-dev mailing list
nimh-dev@xxxxxxxxxxx
http://lists.ellipsis.cx/mailman/listinfo/nimh-dev