bionlplab / bioc

Data structures and code to read/write BioC XML and Json.
MIT License
29 stars 11 forks source link

Can't use 'with' with BioCXMLDocumentReader #11

Closed jakelever closed 3 years ago

jakelever commented 4 years ago

Hi, the new release has stopped the use of BioCXMLDocumentReader using a 'with' statement. It looks like the __enter__ and __exit__ methods were removed in commit 8174c1dcd3502a81a82dea2781e1a7997c3fd117. The documentation still suggests that you can do it that way. It'd be really useful if this could be reintroduced.

Here's a short bit of example code that gives the error below it.

import bioc
with bioc.BioCXMLDocumentReader('test.bioc.xml') as reader:
        pass
Traceback (most recent call last):
  File "itertest.py", line 3, in <module>
    with bioc.BioCXMLDocumentReader('test.bioc.xml') as reader:
AttributeError: __enter__
yfpeng commented 3 years ago

Thank you. I have changed the README.