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

Public Member Functions

def __init__
 
def __lt__
 
def __str__
 
def pathToXRootD
 
def pathToPOSIX
 

Static Public Member Functions

def getFirstDataLogger
 
def setFirstDataLogger
 

Public Attributes

 line
 
 source
 
 path
 
 name
 
 is_file
 

Static Public Attributes

string XRootDprotocolHead = 'root://fndca1.fnal.gov:1094/'
 
string XRootDprotocolDir = 'pnfs/fnal.gov/usr'
 
string POSIXprotocolHead = '/'
 
string POSIXprotocolDir = 'pnfs'
 
tuple POSIXPattern
 
tuple XRootDPattern
 

Static Private Attributes

tuple _DataLoggerSorter = CycleCompareClass(first=4)
 

Detailed Description

This class collects information about a input file, including a sorting
criterium.

Definition at line 126 of file sortDataLoggerFiles.py.

Constructor & Destructor Documentation

def sortDataLoggerFiles.FileInfoClass.__init__ (   self,
  line 
)

Definition at line 154 of file sortDataLoggerFiles.py.

155  line: "input file line (should include endline)",
156  source: "an arbitrary identifier to track the origin of the line" = None,
157  ):
158  """Constructor: use and parse the specified input file line."""
159  self.line = line
160  self.source = source
161  self.path = line.strip()
162  self.protocolAndDir, self.name = os.path.split(self.path)
163  parsedName = FileNameParser.match(self.name)
164  self.is_file = bool(parsedName)
165  if self.is_file:
166  self.dataLogger, self.run, self.stream, self.pass_ \
= parsedName.get('DataLogger', 'RunNumber', 'StreamName', 'PassCount')
static constexpr bool

Member Function Documentation

def sortDataLoggerFiles.FileInfoClass.__lt__ (   self,
  other 
)
Comparison: run, then pass, then (offset cycled) data logger number.

Definition at line 169 of file sortDataLoggerFiles.py.

170  def __lt__(self, other):
171  """Comparison: run, then pass, then (offset cycled) data logger number."""
172  if not self.is_file:
173  raise RuntimeError \
174  ("Sorting not supported for non-file objects ('%s')" % self.path)
175  # if
176  if self.run < other.run: return True
177  if self.run > other.run: return False
178 
179  if self.pass_ < other.pass_: return True
180  if self.pass_ > other.pass_: return False
181 
182  if self.dataLogger != other.dataLogger:
183  return \
184  FileInfoClass._DataLoggerSorter.less(self.dataLogger, other.dataLogger)
185 
186  assert (self.stream is None) == (other.stream is None)
187  return False if self.stream is None else self.stream < other.stream
def sortDataLoggerFiles.FileInfoClass.__str__ (   self)

Definition at line 190 of file sortDataLoggerFiles.py.

191  def __str__(self):
192  s = f"Run {self.run} cycle {self.pass_} data logger {self.dataLogger}"
193  if self.stream: s += f" stream {self.stream}"
194  return s
def sortDataLoggerFiles.FileInfoClass.getFirstDataLogger (   index)
static

Definition at line 148 of file sortDataLoggerFiles.py.

def getFirstDataLogger(index): return FileInfoClass._DataLoggerSorter.first
def sortDataLoggerFiles.FileInfoClass.pathToPOSIX (   self,
  stored,
  file,
  path,
  in,
  POSIX,
  PNFS,
  local,
  format 
)

Definition at line 209 of file sortDataLoggerFiles.py.

210  def pathToPOSIX(self) -> "stored file path in POSIX (PNFS local) format":
211  if not self.is_file:
212  raise RuntimeError(
213  "XRootD conversion not supported for non-file objects ('%s')" % self.path
214  )
215  # if not file
216  match = FileInfoClass.XRootDPattern.match(self.path)
217  return os.path.join(
218  FileInfoClass.POSIXprotocolHead, FileInfoClass.POSIXprotocolDir,
219  match.group(1)
220  ) if match else self.path
def sortDataLoggerFiles.FileInfoClass.pathToXRootD (   self,
  stored,
  file,
  path,
  in,
  XRootD,
  format 
)

Definition at line 195 of file sortDataLoggerFiles.py.

196  def pathToXRootD(self) -> "stored file path in XRootD format":
197  if not self.is_file:
198  raise RuntimeError(
199  "XRootD conversion not supported for non-file objects ('%s')" % self.path
200  )
201  # if not file
202  match = FileInfoClass.POSIXPattern.match(self.path)
203  return os.path.join(
204  FileInfoClass.XRootDprotocolHead, FileInfoClass.XRootDprotocolDir,
205  *match.group(1, 2)
206  ) if match else self.path
def sortDataLoggerFiles.FileInfoClass.setFirstDataLogger (   index)
static

Definition at line 150 of file sortDataLoggerFiles.py.

151  def setFirstDataLogger(index):
152  FileInfoClass._DataLoggerSorter = CycleCompareClass(first=index)

Member Data Documentation

tuple sortDataLoggerFiles.FileInfoClass._DataLoggerSorter = CycleCompareClass(first=4)
staticprivate

Definition at line 145 of file sortDataLoggerFiles.py.

sortDataLoggerFiles.FileInfoClass.is_file

Definition at line 163 of file sortDataLoggerFiles.py.

sortDataLoggerFiles.FileInfoClass.line

Definition at line 158 of file sortDataLoggerFiles.py.

sortDataLoggerFiles.FileInfoClass.name

Definition at line 161 of file sortDataLoggerFiles.py.

sortDataLoggerFiles.FileInfoClass.path

Definition at line 160 of file sortDataLoggerFiles.py.

tuple sortDataLoggerFiles.FileInfoClass.POSIXPattern
static
Initial value:
1 = re.compile(
2  POSIXprotocolHead.replace('.', r'\.')
3  + POSIXprotocolDir.replace('.', r'\.')
4  + r"/([^/]+)/(.*)")

Definition at line 136 of file sortDataLoggerFiles.py.

string sortDataLoggerFiles.FileInfoClass.POSIXprotocolDir = 'pnfs'
static

Definition at line 134 of file sortDataLoggerFiles.py.

string sortDataLoggerFiles.FileInfoClass.POSIXprotocolHead = '/'
static

Definition at line 133 of file sortDataLoggerFiles.py.

sortDataLoggerFiles.FileInfoClass.source

Definition at line 159 of file sortDataLoggerFiles.py.

tuple sortDataLoggerFiles.FileInfoClass.XRootDPattern
static
Initial value:
1 = re.compile(
2  XRootDprotocolHead.replace('.', r'\.')
3  + XRootDprotocolDir.replace('.', r'\.')
4  + r"/(.*)"
5  )

Definition at line 140 of file sortDataLoggerFiles.py.

string sortDataLoggerFiles.FileInfoClass.XRootDprotocolDir = 'pnfs/fnal.gov/usr'
static

Definition at line 132 of file sortDataLoggerFiles.py.

string sortDataLoggerFiles.FileInfoClass.XRootDprotocolHead = 'root://fndca1.fnal.gov:1094/'
static

Definition at line 131 of file sortDataLoggerFiles.py.


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