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

Public Member Functions

def __init__
 
def __iter__
 
def __next__
 

Public Attributes

 fileIter
 
 lineNo
 
 fileNo
 

Detailed Description

Iterator: returns one file name at each iteration.

The text file is expected to have one file name per line. Lines are stripped
(`str.strip()`) of spaces.
Empty lines and lines which are a comment are skipped.
A comment line is a line whose first non-blank character is a hash character
('#').

The value returned at each iteration is (lineNo, fileNo, fileName); if
`withLineNo` or `withFileNo` are `False`, the respective element is omitted.
If only the file name is requested (all other option `False`) the return value
is not a tuple but just the file name.

Definition at line 88 of file CheckPhotonLibraryJobs.py.

Constructor & Destructor Documentation

def CheckPhotonLibraryJobs.FileListIterator.__init__ (   self,
  listFile 
)

Definition at line 104 of file CheckPhotonLibraryJobs.py.

105  listFile: "text file containing the list" = None,
106  listName: "path of the text file containing the list" = None,
107  withLineNo: "whether to return also the number of line in file" = False,
108  withFileNo: "whether to return also the number of file" = False,
109  ):
110  assert listFile or listName
111 
112  if not listFile: listFile = open(listName, 'r')
113  self.fileIter = iter(listFile)
114  self.lineNo = 0 if withLineNo else None
self.fileNo = 0 if withFileNo else None
open(RACETRACK) or die("Could not open file $RACETRACK for writing")

Member Function Documentation

def CheckPhotonLibraryJobs.FileListIterator.__iter__ (   self)

Definition at line 117 of file CheckPhotonLibraryJobs.py.

118  def __iter__(self): return self
def CheckPhotonLibraryJobs.FileListIterator.__next__ (   self)

Definition at line 119 of file CheckPhotonLibraryJobs.py.

120  def __next__(self):
121  while True:
122  fileName = next(self.fileIter).strip()
123  if self.lineNo is not None: self.lineNo += 1
124  if not fileName or fileName[0] == '#': continue
125 
126  if self.fileNo is not None: self.fileNo += 1
127  if not self.fileNo and not self.lineNo: return fileName
128  else: return tuple(filter(None, ( self.lineNo, self.fileNo, fileName, )))
# while
Framework includes.

Member Data Documentation

CheckPhotonLibraryJobs.FileListIterator.fileIter

Definition at line 112 of file CheckPhotonLibraryJobs.py.

CheckPhotonLibraryJobs.FileListIterator.fileNo

Definition at line 114 of file CheckPhotonLibraryJobs.py.

CheckPhotonLibraryJobs.FileListIterator.lineNo

Definition at line 113 of file CheckPhotonLibraryJobs.py.


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