ATLAS Offline Software
DQCDispatch.py
Go to the documentation of this file.
1 # Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
2 
3 # This holds the method that returns an appropriate DataQualityConfiguration
4 # module for the specified input string
5 # Algorithm: exact match to input if exists, otherwise dispatch based on end
6 # of string, or to pattern data[0-9]{2}
7 #
8 # 2012-12-05 Peter Onyisi
9 
10 def getmodule(modname):
11  assert isinstance(modname, str), 'Argument to getmodule must be a string'
12 
13  # Local file?
14  try:
15  mod = __import__(modname)
16  components = modname.split('.')
17  for comp in components[1:]:
18  mod = getattr(mod,comp)
19  return mod
20  except ImportError:
21  pass
22 
23  # Does it exist already?
24  try:
25  return getattr(__import__('DataQualityConfigurations.'+modname), modname)
26  except ImportError:
27  pass
28 
29  # Does it match a pattern?
30  if (modname.endswith('GeV')
31  or modname.endswith('TeV')
32  or modname.endswith('_calib')
33  or modname.endswith('_comm')
34  or modname.endswith('_refcomm')):
35  from . import base_data; return base_data
36  if (modname.endswith('_hi')
37  or modname.endswith('_hicomm')
38  or modname.endswith('_hip')):
39  from . import base_data_hi; return base_data_hi
40  elif (modname.endswith('_1beam') ):
41  from . import base_data_1beam; return base_data_1beam
42  #return __import__('base_data_1beam')
43  elif (modname.endswith('_cos')
44  or modname.endswith('_calocomm')
45  or modname.endswith('_idcomm')
46  or modname.endswith('_larcomm')
47  or modname.endswith('_muoncomm')
48  or modname.endswith('_tilecomm')):
49  from . import base_data_cos; return base_data_cos
50 
51  import re
52  # Does it look like datann_hip?
53  m = re.match(r'data\d{2}_hip', modname)
54  if m:
55  from . import base_data_hi; return base_data_hi
56  # Does it look like datann?
57  m = re.match(r'data\d{2}$', modname)
58  if m:
59  from . import base_data; return base_data
60 
61  raise ValueError('Unable to find a valid configuration for %s' % modname)
python.DQCDispatch.getmodule
def getmodule(modname)
Definition: DQCDispatch.py:10