[Biopython-dev] Martel changes
adalke at mindspring.com
Wed Dec 12 05:21:59 EST 2001
I'm doing some work with Martel again. Cayte asked
earlier about a way to simplify working with Martel
callbacks. I outlined a possible simplification.
I've implemented it. It's called 'SimpleFields'.
You can take a look at it at
It supports both callback and iterative styles.
(See the module docstring for examples of each.)
I'm going to add it to CVS as soon as I think up
better names than 'SimpleFields' and 'groups'.
(Although I do like 'LAX' :)
Is anyone using the iterator facility in Martel?
I would like to change the API. Currently you pass
it the factory function which produces SAX handlers.
I would rather just pass it a SAX handler, and
trust the handler to reset itself properly with the
startDocument/endDocument methods. (Those which
don't can easily be wrapped.)
The problem with the current API is when the handler
needs parameters then you need to create something
which passed those parameters to each instance. It's
ugly, and it's common... I think. I also don't like
that the object is created for every record instead
of reusing the existing one.
I don't think anyone uses this feature, so I'll go
ahead and change it unless someone gives me a good
Finally, I'm adding some common patterns to the top-level
Martel/__init__.py. These are for things like 'Word'
def Word(name = None, attrs = None):
exp = Re(r"\w+")
if name is None:
if attrs is not None:
return Group(name, exp, attrs)
The idea is to make it easier to specify, say, a list
of words on line
format = Word("species") + Whitespace() + \
Word("count") + Whitespace() + \
Has anyone started building up a collection of those
common patterns? I've got Integer, SignedInteger, Float,
Word, and Whitespace. I'll probably add Spaces (for
only " "), NonSpaces (up to a " ").
Comments on any of these?
dalke at dalkescientific.com
More information about the Biopython-dev