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

Classes

class  ParsedNameClass
 

Public Member Functions

def __init__
 

Static Public Member Functions

def match
 

Static Public Attributes

list Patterns
 

Detailed Description

Static object (namespace?) containing file name parsing utilities.

All supported file name patterns are in the `Patterns` class variable.
The static method `match()` tries all of them, in order.

Definition at line 64 of file sortDataLoggerFiles.py.

Constructor & Destructor Documentation

def sortDataLoggerFiles.FileNameParser.__init__ (   self)

Definition at line 107 of file sortDataLoggerFiles.py.

108  def __init__(self): pass

Member Function Documentation

def sortDataLoggerFiles.FileNameParser.match (   name)
static

Definition at line 110 of file sortDataLoggerFiles.py.

111  def match(name):
112  # the first successful pattern is used
113  for patternInfo in FileNameParser.Patterns:
114  match = patternInfo['Pattern'].match(name)
115  if match is None: continue
116  d = dict(
117  ( name, ( type_(value) if (value := match.group(index)) else None ) )
118  for name, ( index, type_ ) in patternInfo['Parameters'].items()
119  )
120  d['Name'] = patternInfo['Name']
121  return FileNameParser.ParsedNameClass(name, d)
else: return FileNameParser.ParsedNameClass(name, {})

Member Data Documentation

list sortDataLoggerFiles.FileNameParser.Patterns
static
Initial value:
1 = [
2  {
3  'Name': 'general',
4  # pattern parameters: data logger stream stream name run pass filler (timestamp)
5  # <1> <2> <3> <4> <5> <6>
6  'Pattern': re.compile(r"data_dl(\d+)(_fstrm([^_]*))?_run(\d+)_(\d+)_(.*)\.root"),
7  'Parameters': {
8  'DataLogger': ( 1, int ),
9  'StreamName': ( 3, str ),
10  'RunNumber' : ( 4, int ),
11  'PassCount' : ( 5, int ),
12  },
13  }, # general
14  {
15  'Name': 'multistream',
16  # pattern parameters: stream name data logger run pass filler (timestamp)
17  # <1> <2> <3> <4> <5>
18  'Pattern': re.compile(r"([^_]+)_data_dl(\d+)_run(\d+)_(\d+)_(.*)\.root"),
19  'Parameters': {
20  'DataLogger': ( 2, int ),
21  'StreamName': ( 1, str ),
22  'RunNumber' : ( 3, int ),
23  'PassCount' : ( 4, int ),
24  },
25  }, # general
26  ]

Definition at line 70 of file sortDataLoggerFiles.py.


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