All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Public Attributes | List of all members
ROOTutils.DirectoryChanger Class Reference

Public Member Functions

def __init__
 
def saveCurrentDir
 
def saveDir
 
def changeDir
 
def restoreDir
 
def forget
 
def __del__
 
def __enter__
 
def __exit__
 
def __init__
 
def saveCurrentDir
 
def saveDir
 
def changeDir
 
def restoreDir
 
def forget
 
def __del__
 
def __enter__
 
def __exit__
 

Public Attributes

 newDir
 
 oldDir
 

Detailed Description

Object changing ROOT directory while on scope.

The purpose is to make a ROOT directory current only as long as it is needed.
The most typical uses of this objects include the automatic restoration of
the previous directory as the object falls out of scope.
Two methods are supported:
1. function scope:
      
      def writeEverythingInto(dir, everything):
        dirChanger = ROOTutils.DirectoryChanger(dir)
        for item in everything: item.Write()
      # writeEverythingInto()
      
2. local scope (equivalent to using `activateDirectory()`):
      
      with DirectoryChanger(dir):
        for item in everything: item.Write()
      # with

Definition at line 172 of file icarusalg/icarusalg/gallery/helpers/python/ROOTutils.py.

Constructor & Destructor Documentation

def ROOTutils.DirectoryChanger.__init__ (   self,
  newDir = None,
  saveDir = None 
)
def ROOTutils.DirectoryChanger.__del__ (   self)

Definition at line 214 of file icarusalg/icarusalg/gallery/helpers/python/ROOTutils.py.

215  def __del__(self):
216  self.restoreDir()
def ROOTutils.DirectoryChanger.__init__ (   self,
  newDir = None,
  saveDir = None 
)

Definition at line 195 of file sbndcode/sbndcode/gallery/python/ROOTutils.py.

196  def __init__(self, newDir = None, saveDir = None):
197  if saveDir: self.saveDir(saveDir)
198  else: self.saveCurrentDir()
199  self.newDir = newDir
self.changeDir()
def ROOTutils.DirectoryChanger.__del__ (   self)

Definition at line 214 of file sbndcode/sbndcode/gallery/python/ROOTutils.py.

215  def __del__(self):
216  self.restoreDir()

Member Function Documentation

def ROOTutils.DirectoryChanger.__enter__ (   self)

Definition at line 217 of file icarusalg/icarusalg/gallery/helpers/python/ROOTutils.py.

218  def __enter__(self):
219  self.changeDir()
def ROOTutils.DirectoryChanger.__enter__ (   self)

Definition at line 217 of file sbndcode/sbndcode/gallery/python/ROOTutils.py.

218  def __enter__(self):
219  self.changeDir()
def ROOTutils.DirectoryChanger.__exit__ (   self,
  exc_type,
  exc_value,
  traceback 
)

Definition at line 220 of file icarusalg/icarusalg/gallery/helpers/python/ROOTutils.py.

221  def __exit__(self, exc_type, exc_value, traceback):
222  self.restoreDir()
223  self.forget()
224 
225 # DirectoryChanger()
226 
def ROOTutils.DirectoryChanger.__exit__ (   self,
  exc_type,
  exc_value,
  traceback 
)

Definition at line 220 of file sbndcode/sbndcode/gallery/python/ROOTutils.py.

221  def __exit__(self, exc_type, exc_value, traceback):
222  self.restoreDir()
223  self.forget()
224 
225 # DirectoryChanger()
226 
def ROOTutils.DirectoryChanger.changeDir (   self)

Definition at line 206 of file sbndcode/sbndcode/gallery/python/ROOTutils.py.

207  def changeDir(self):
208  if self.newDir: self.newDir.cd()
def ROOTutils.DirectoryChanger.changeDir (   self)

Definition at line 206 of file icarusalg/icarusalg/gallery/helpers/python/ROOTutils.py.

207  def changeDir(self):
208  if self.newDir: self.newDir.cd()
def ROOTutils.DirectoryChanger.forget (   self)

Definition at line 212 of file icarusalg/icarusalg/gallery/helpers/python/ROOTutils.py.

213  def forget(self): self.oldDir = None
def ROOTutils.DirectoryChanger.forget (   self)

Definition at line 212 of file sbndcode/sbndcode/gallery/python/ROOTutils.py.

213  def forget(self): self.oldDir = None
def ROOTutils.DirectoryChanger.restoreDir (   self)

Definition at line 209 of file sbndcode/sbndcode/gallery/python/ROOTutils.py.

210  def restoreDir(self):
211  if self.oldDir: self.oldDir.cd()
def ROOTutils.DirectoryChanger.restoreDir (   self)

Definition at line 209 of file icarusalg/icarusalg/gallery/helpers/python/ROOTutils.py.

210  def restoreDir(self):
211  if self.oldDir: self.oldDir.cd()
def ROOTutils.DirectoryChanger.saveCurrentDir (   self)

Definition at line 202 of file sbndcode/sbndcode/gallery/python/ROOTutils.py.

203  def saveCurrentDir(self): self.saveDir(ROOT.gDirectory)
def ROOTutils.DirectoryChanger.saveCurrentDir (   self)

Definition at line 202 of file icarusalg/icarusalg/gallery/helpers/python/ROOTutils.py.

203  def saveCurrentDir(self): self.saveDir(ROOT.gDirectory)
def ROOTutils.DirectoryChanger.saveDir (   self,
  ROOTdir 
)

Definition at line 204 of file icarusalg/icarusalg/gallery/helpers/python/ROOTutils.py.

205  def saveDir(self, ROOTdir): self.oldDir = ROOTdir
def ROOTutils.DirectoryChanger.saveDir (   self,
  ROOTdir 
)

Definition at line 204 of file sbndcode/sbndcode/gallery/python/ROOTutils.py.

205  def saveDir(self, ROOTdir): self.oldDir = ROOTdir

Member Data Documentation

ROOTutils.DirectoryChanger.newDir

Definition at line 198 of file icarusalg/icarusalg/gallery/helpers/python/ROOTutils.py.

ROOTutils.DirectoryChanger.oldDir

Definition at line 204 of file icarusalg/icarusalg/gallery/helpers/python/ROOTutils.py.


The documentation for this class was generated from the following files: