def __init__(self, filename, mode, writeback=False, args=()): """ Create Root-only database >>> db = RooOnlyShelf('mydb.root','c') >>> h1 = ... """ self.__filename = filename from ostap.io.root_file import ROOTCWD, open_mode with ROOTCWD(): ## NB: preserve current directory in ROOT! rfile = ROOT.TFile.Open(filename, open_mode(mode), *args) shelve.Shelf.__init__(self, rfile, writeback)
def __init__( self , filename , mode , writeback = False , args = () ) : """ Create Root-only database >>> db = RooOnlyShelf('mydb.root','c') >>> h1 = ... """ self.__filename = filename from ostap.io.root_file import ROOTCWD, open_mode with ROOTCWD() : ## NB: preserve current directory in ROOT! rfile = ROOT.TFile.Open ( filename , open_mode ( mode ) , *args ) if not rfile or not rfile.IsOpen() : raise IOError("Can't open ``%s'' with mode ``%s''" % ( filename , mode ) ) shelve.Shelf.__init__ ( self , rfile , writeback ) self.nominal_dbname = filename