[BioPython] getting rid of UserDict part two ...

Andreas Kuntzagk andreas.kuntzagk at mdc-berlin.de
Tue Jun 24 15:40:53 EDT 2003


Hi,

As promised, I looked into Parser.py and hopefully found what went
wrong. I believe the tests are working (but I did that before...) 
Here is the patch against cvs. 

Andreas 
-------------- next part --------------
Index: Martel/Parser.py
===================================================================
RCS file: /home/repository/biopython/biopython/Martel/Parser.py,v
retrieving revision 1.10
diff -r1.10 Parser.py
132,133c132,137
<     for item in taglist:
<         tag, l, r, subtags = item
---
>     # bind functions to local names for a slight speedup
>     characters   = cont_handler.characters
>     startElement = cont_handler.startElement
>     endElement   = cont_handler.endElement
> 
>     for tag, l, r, subtags in taglist:
135a140
>         assert begin <= l, "begin = %d and l = %d" % (begin, l)
137,140c142
<             cont_handler.characters(s[begin:l])
<         else:
<             # Some integrity checking
<             assert begin == l, "begin = %d and l = %d" % (begin, l)
---
>             characters(s[begin:l])
142,150c144,150
<         if tag[0] == ">":
<             if tag == ">ignore":
<                 # Named groups doesn't create ">ignore" tags, so pass them on
<                 # to the ContentHandler.  Unnamed groups still need a name so
<                 # mxTextTools can create subtags for them.  I named them
<                 # ">ignore" - don't create events for them.
<                 pass
< 
<             elif tag[:2] == ">G":
---
>         if tag.startswith(">"):
>             # Named groups doesn't create ">ignore" tags, so pass them on
>             # to the ContentHandler.  Unnamed groups still need a name so
>             # mxTextTools can create subtags for them.  I named them
>             # ">ignore" - don't create events for them.
>             if not tag == ">ignore":
>                 assert tag.startswith(">G"),"Unknown special tag %s" % repr(tag)
153,156c153,154
<                 cont_handler.startElement(realtag, attrs)
< 
<             else:
<                 raise AssertionError("Unknown special tag %s" % repr(tag))
---
>                 startElement(realtag, attrs)
>         
159c157
<             cont_handler.startElement(tag, _attribute_list)
---
>             startElement(tag, _attribute_list)
165c163
<             cont_handler.characters(s[l:r])
---
>             characters(s[l:r])
168,171c166,167
<         if tag[0] == ">":
<             if tag == ">ignore":
<                 pass
<             elif tag[:2] == ">G":
---
>         if tag.startswith(">"):
>             if tag.startswith(">G"):
173,175c169
<                 cont_handler.endElement(realtag)
<             else:
<                 raise AssertionError("Unknown special tag %s" % repr(tag))
---
>                 endElement(realtag)
177c171
<             cont_handler.endElement(tag)
---
>             endElement(tag)
182c176
<         cont_handler.characters(s[begin:end])
---
>         characters(s[begin:end])
202,203c196
<     for item in taglist:
<         tag, l, r, subtags = item
---
>     for tag, l, r, subtags in taglist:
206,211c199,201
<         if begin < l:
<             if save_stack:
<                 cont_handler._save_text += s[begin:l]
<         else:
<             # Some integrity checking
<             assert begin == l, "begin = %d and l = %d" % (begin, l)
---
>         assert begin <= l, "begin = %d and l = %d" % (begin, l)
>         if begin < l and save_stack:
>             cont_handler._save_text += s[begin:l]


More information about the BioPython mailing list