CADWRDeltaModeling/pyhecdss

Support yield and context manager to support usage of DSSFile handle

dwr-psandhu opened this issue · 1 comments

Description

Enable use of DSSFile objects 'with' statement. This allows code like

with DSSFile('somefile.dss') as dh:
  do_something(dh)

dh will be cleaned up at the end of such statements to not leave open file handles that block other file usage at that time

Also look at generator (yield) to return the entire list of selection so that users can lazily load and process data from a dss
file

E.g.

rlist = pyhecdss.get_rts(filename,'/some/pattern/path////')
for data in rlist:
  process(data)

Currently rlist loads the data and all into the rlist var. This will become lazily loaded and will be more performant if user has an exception or wants to abort processing list

Fixed.