CMS 3D CMS Logo

Functions | Variables
FileUtils Namespace Reference

Functions

def loadListFromFile (filename)
 
def save_history (historyPath=historyPath)
 
def sectionNofTotal (inputList, currentSection, numSections)
 

Variables

 historyPath
 

Function Documentation

def FileUtils.loadListFromFile (   filename)
Loads a list of strings from file.  Will append to given list
if asked.

Definition at line 6 of file FileUtils.py.

References edm.print().

6 def loadListFromFile (filename):
7  """Loads a list of strings from file. Will append to given list
8  if asked."""
9  retval = []
10  filename = os.path.expanduser (filename)
11  if not os.path.exists (filename):
12  print("Error: file '%s' does not exist."%(filename))
13  raise RuntimeError("Bad filename")
14  source = open (filename, 'r')
15  for line in source.readlines():
16  line = re.sub (r'#.+$', '', line) # remove comment characters
17  line = line.strip()
18  if len (line):
19  retval.append (line)
20  source.close()
21  return retval
22 
23 
S & print(S &os, JobReport::InputFile const &f)
Definition: JobReport.cc:66
def loadListFromFile(filename)
Definition: FileUtils.py:6
def FileUtils.save_history (   historyPath = historyPath)

Definition at line 60 of file FileUtils.py.

60  def save_history(historyPath=historyPath):
61  import readline
62  readline.write_history_file(historyPath)
63  if os.path.exists(historyPath):
64  readline.read_history_file(historyPath)
65 
66 
def save_history(historyPath=historyPath)
Definition: FileUtils.py:60
def FileUtils.sectionNofTotal (   inputList,
  currentSection,
  numSections 
)
Returns the appropriate sublist given the current section
(1..numSections)

Definition at line 24 of file FileUtils.py.

24 def sectionNofTotal (inputList, currentSection, numSections):
25  """Returns the appropriate sublist given the current section
26  (1..numSections)"""
27  currentSection -= 1 # internally, we want 0..N-1, not 1..N
28  size = len (inputList)
29  perSection = size // numSections
30  extra = size % numSections
31  start = perSection * currentSection
32  num = perSection
33  if currentSection < extra:
34  # the early sections get an extra item
35  start += currentSection
36  num += 1
37  else:
38  start += extra
39  stop = start + num
40  return inputList[ start:stop ]
41 
42 
def sectionNofTotal(inputList, currentSection, numSections)
Definition: FileUtils.py:24

Variable Documentation

FileUtils.historyPath

Definition at line 57 of file FileUtils.py.