File tree Expand file tree Collapse file tree 2 files changed +11
-12
lines changed
Expand file tree Collapse file tree 2 files changed +11
-12
lines changed Original file line number Diff line number Diff line change 3232from neo .io .baseio import BaseIO
3333from neo .core import Block , Segment , AnalogSignal
3434
35- try :
36- import stfio
37- except ImportError as err :
38- HAS_STFIO = False
39- STFIO_ERR = err
40- else :
41- HAS_STFIO = True
42- STFIO_ERR = None
43-
4435
4536class StimfitIO (BaseIO ):
4637 """
@@ -99,8 +90,9 @@ def __init__(self, filename=None):
9990 Arguments:
10091 filename : Either a filename or a stfio Recording object
10192 """
102- if not HAS_STFIO :
103- raise STFIO_ERR
93+ # We need this module, so try importing now so that it fails on
94+ # instantiation rather than read_block
95+ import stfio # noqa
10496
10597 BaseIO .__init__ (self )
10698
@@ -112,6 +104,7 @@ def __init__(self, filename=None):
112104 self .filename = None
113105
114106 def read_block (self , lazy = False ):
107+ import stfio
115108 assert not lazy , 'Do not support lazy'
116109
117110 if self .filename is not None :
Original file line number Diff line number Diff line change 88import unittest
99
1010from neo .io import StimfitIO
11- from neo .io .stimfitio import HAS_STFIO
1211from neo .test .iotest .common_io_test import BaseTestIO
1312
13+ try :
14+ import stfio
15+ except Exception :
16+ HAS_STFIO = False
17+ else :
18+ HAS_STFIO = True
19+
1420
1521@unittest .skipIf (sys .version_info [0 ] > 2 , "not Python 3 compatible" )
1622@unittest .skipUnless (HAS_STFIO , "requires stfio" )
You can’t perform that action at this time.
0 commit comments