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  import six
12  assert isinstance(modname, six.string_types), 'Argument to getmodule must be a string'
13 
14  # Local file?
15  try:
16  mod = __import__(modname)
17  components = modname.split('.')
18  for comp in components[1:]:
19  mod = getattr(mod,comp)
20  return mod
21  except ImportError:
22  pass
23 
24  # Does it exist already?
25  try:
26  return getattr(__import__('DataQualityConfigurations.'+modname), modname)
27  except ImportError:
28  pass
29 
30  # Does it match a pattern?
31  if (modname.endswith('GeV')
32  or modname.endswith('TeV')
33  or modname.endswith('_calib')
34  or modname.endswith('_comm')
35  or modname.endswith('_refcomm')):
36  from . import base_data; return base_data
37  if (modname.endswith('_hi')
38  or modname.endswith('_hicomm')
39  or modname.endswith('_hip')):
40  from . import base_data_hi; return base_data_hi
41  elif (modname.endswith('_1beam') ):
42  from . import base_data_1beam; return base_data_1beam
43  #return __import__('base_data_1beam')
44  elif (modname.endswith('_cos')
45  or modname.endswith('_calocomm')
46  or modname.endswith('_idcomm')
47  or modname.endswith('_larcomm')
48  or modname.endswith('_muoncomm')
49  or modname.endswith('_tilecomm')):
50  from . import base_data_cos; return base_data_cos
51 
52  import re
53  # Does it look like datann_hip?
54  m = re.match(r'data\d{2}_hip', modname)
55  if m:
56  from . import base_data_hi; return base_data_hi
57  # Does it look like datann?
58  m = re.match(r'data\d{2}$', modname)
59  if m:
60  from . import base_data; return base_data
61 
62  raise ValueError('Unable to find a valid configuration for %s' % modname)
python.DQCDispatch.getmodule
def getmodule(modname)
Definition: DQCDispatch.py:10