CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
tkal_create_file_lists._DasCache Class Reference
Inheritance diagram for tkal_create_file_lists._DasCache:

Public Member Functions

def __init__ (self, file_list_id)
 
def dump (self)
 
def empty (self)
 
def get (self)
 
def load (self)
 
def reset (self)
 
def set (self, total_events, file_list, file_info, max_run)
 

Private Attributes

 _cache_file_name
 
 _empty
 
 _events_in_dataset
 
 _file_info
 
 _file_list_id
 
 _files
 
 _max_run
 

Detailed Description

Helper class to cache information from DAS requests.

Definition at line 810 of file tkal_create_file_lists.py.

Constructor & Destructor Documentation

def tkal_create_file_lists._DasCache.__init__ (   self,
  file_list_id 
)
Constructor of the cache.

Arguments:
- `file_list_id`: ID of the cached file lists

Definition at line 813 of file tkal_create_file_lists.py.

813  def __init__(self, file_list_id):
814  """Constructor of the cache.
815 
816  Arguments:
817  - `file_list_id`: ID of the cached file lists
818  """
819 
820  self._file_list_id = file_list_id
821  self._cache_file_name = os.path.join(file_list_id, ".das_cache.pkl")
822  self.reset()
823 
824 

Member Function Documentation

def tkal_create_file_lists._DasCache.dump (   self)
Dumps the contents to the cache file.

Definition at line 882 of file tkal_create_file_lists.py.

References tkal_create_file_lists._DasCache._cache_file_name, APVCyclePhaseCollection.empty, pathelpers::Record.empty, GenericMVAComputerCache.empty, edm::math_private::ieee_long_double_shape_type.empty, L1RCTElectronIsolationCard.empty, L1RCT.empty, tkal_create_file_lists._DasCache.empty(), and tkal_create_file_lists.print_msg().

882  def dump(self):
883  """Dumps the contents to the cache file."""
884 
885  if self.empty:
886  print_msg("Cache is empty. Not writing to file.")
887  return
888 
889  with open(self._cache_file_name, "wb") as f:
890  cPickle.dump(self.__dict__, f, 2)
891 
892 
def print_msg(text, line_break=True, log_file=None)
def tkal_create_file_lists._DasCache.empty (   self)
Flag indicating whether the cache is empty or has been filled (possibly
with nothing).

Definition at line 894 of file tkal_create_file_lists.py.

References tkal_create_file_lists._DasCache._empty.

Referenced by tkal_create_file_lists._DasCache.dump(), tkal_create_file_lists._DasCache.load(), Vispa.Gui.VispaWidget.TextField.setAutosizeFont(), and Vispa.Gui.VispaWidget.TextField.setAutotruncate().

894  def empty(self):
895  """
896  Flag indicating whether the cache is empty or has been filled (possibly
897  with nothing).
898  """
899 
900  return self._empty
901 
902 
903 
def tkal_create_file_lists._DasCache.get (   self)
Get the content of the cache as tuple:
   result = (total number of events in dataset,
     list of files in dataset,
     dictionary with numbers of events and runs per file)

Definition at line 852 of file tkal_create_file_lists.py.

References tkal_create_file_lists.FileListCreator._events_in_dataset, tkal_create_file_lists._DasCache._events_in_dataset, tkal_create_file_lists.FileListCreator._file_info, tkal_create_file_lists._DasCache._file_info, tkal_create_file_lists.FileListCreator._files, tkal_create_file_lists._DasCache._files, tkal_create_file_lists.FileListCreator._max_run, and tkal_create_file_lists._DasCache._max_run.

Referenced by Options.Options.__getitem__(), betterConfigParser.BetterConfigParser.__updateDict(), data_sources.json_list.as_dicts(), data_sources.json_list.as_table(), rrapi.RRApi.columns(), util.rrapi.RRApi.columns(), util.rrapi.RRApi.count(), rrapi.RRApi.count(), util.rrapi.RRApi.data(), rrapi.RRApi.data(), data_sources.json_list.first(), betterConfigParser.BetterConfigParser.getCompares(), betterConfigParser.BetterConfigParser.getGeneral(), betterConfigParser.BetterConfigParser.getResultingSection(), data_sources.json_list.indices(), data_sources.json_list.last(), util.rrapi.RRApi.report(), rrapi.RRApi.report(), rrapi.RRApi.reports(), util.rrapi.RRApi.reports(), rrapi.RRApi.tables(), util.rrapi.RRApi.tables(), rrapi.RRApi.tags(), util.rrapi.RRApi.tags(), rrapi.RRApi.templates(), util.rrapi.RRApi.templates(), util.rrapi.RRApi.workspaces(), and rrapi.RRApi.workspaces().

852  def get(self):
853  """
854  Get the content of the cache as tuple:
855  result = (total number of events in dataset,
856  list of files in dataset,
857  dictionary with numbers of events and runs per file)
858  """
859 
860  return self._events_in_dataset, self._files, self._file_info, self._max_run
861 
862 
def tkal_create_file_lists._DasCache.load (   self)
Loads the cached contents.

Definition at line 863 of file tkal_create_file_lists.py.

References tkal_create_file_lists._DasCache._cache_file_name, tkal_create_file_lists._DasCache._file_list_id, APVCyclePhaseCollection.empty, pathelpers::Record.empty, GenericMVAComputerCache.empty, edm::math_private::ieee_long_double_shape_type.empty, L1RCTElectronIsolationCard.empty, L1RCT.empty, tkal_create_file_lists._DasCache.empty(), and tkal_create_file_lists.print_msg().

Referenced by MatrixToProcess.MatrixToProcess.getProcess(), MatrixToProcess.MatrixToProcess.listAll(), and ConfigBuilder.ConfigBuilder.prepare_FILTER().

863  def load(self):
864  """Loads the cached contents."""
865 
866  if not self.empty:
867  print_msg("Overriding file information with cached information.")
868  try:
869  with open(self._cache_file_name, "rb") as f:
870  tmp_dict = cPickle.load(f)
871  self.__dict__.update(tmp_dict)
872  except IOError as e:
873  if e.args == (2, "No such file or directory"):
874  msg = "Failed to load cache for '{}'.".format(self._file_list_id)
875  if not self.empty:
876  msg += " Keeping the previous file information."
877  print_msg(msg)
878  else:
879  raise
880 
881 
def print_msg(text, line_break=True, log_file=None)
def tkal_create_file_lists._DasCache.reset (   self)
def tkal_create_file_lists._DasCache.set (   self,
  total_events,
  file_list,
  file_info,
  max_run 
)
Set the content of the cache.

Arguments:
- `total_events`: total number of events in dataset
- `file_list`: list of files in dataset
- `file_info`: dictionary with numbers of events per file
- `max_run`: highest run number contained in the dataset

Definition at line 835 of file tkal_create_file_lists.py.

References tkal_create_file_lists._DasCache._empty, tkal_create_file_lists.FileListCreator._events_in_dataset, tkal_create_file_lists._DasCache._events_in_dataset, tkal_create_file_lists.FileListCreator._file_info, tkal_create_file_lists._DasCache._file_info, tkal_create_file_lists.FileListCreator._files, tkal_create_file_lists._DasCache._files, tkal_create_file_lists.FileListCreator._max_run, and tkal_create_file_lists._DasCache._max_run.

Referenced by betterConfigParser.BetterConfigParser.getGeneral().

835  def set(self, total_events, file_list, file_info, max_run):
836  """Set the content of the cache.
837 
838  Arguments:
839  - `total_events`: total number of events in dataset
840  - `file_list`: list of files in dataset
841  - `file_info`: dictionary with numbers of events per file
842  - `max_run`: highest run number contained in the dataset
843  """
844 
845  self._events_in_dataset = total_events
846  self._files = file_list
847  self._file_info = file_info
848  self._max_run = max_run
849  self._empty = False
850 
851 
def set(self, total_events, file_list, file_info, max_run)

Member Data Documentation

tkal_create_file_lists._DasCache._cache_file_name
private
tkal_create_file_lists._DasCache._empty
private
tkal_create_file_lists._DasCache._events_in_dataset
private
tkal_create_file_lists._DasCache._file_info
private
tkal_create_file_lists._DasCache._file_list_id
private

Definition at line 820 of file tkal_create_file_lists.py.

Referenced by tkal_create_file_lists._DasCache.load().

tkal_create_file_lists._DasCache._files
private
tkal_create_file_lists._DasCache._max_run
private