__init__.py
Go to the documentation of this file.
1 import os
2 
3 def ROOT6WorkAroundEnabled(id=None):
4  '''
5  Helper function to easily exclude ROOT6 work-arounds for testing.
6 
7  >>> os.environ['ROOT6_WORK_AROUND'] = 'all'
8  >>> ROOT6WorkAroundEnabled()
9  True
10  >>> os.environ['ROOT6_WORK_AROUND'] = 'none'
11  >>> ROOT6WorkAroundEnabled('JIRA-XYZ')
12  False
13  >>> os.environ['ROOT6_WORK_AROUND'] = 'JIRA-X'
14  >>> ROOT6WorkAroundEnabled('JIRA-X')
15  True
16  >>> ROOT6WorkAroundEnabled('JIRA-Y')
17  True
18  >>> os.environ['ROOT6_WORK_AROUND'] = 'JIRA-X,-JIRA-Y'
19  >>> ROOT6WorkAroundEnabled('JIRA-X')
20  True
21  >>> ROOT6WorkAroundEnabled('JIRA-Y')
22  False
23  >>> os.environ['ROOT6_WORK_AROUND'] = '-JIRA-Y'
24  >>> ROOT6WorkAroundEnabled('JIRA-X')
25  True
26  >>> ROOT6WorkAroundEnabled('JIRA-Y')
27  False
28  '''
29  enabled = os.environ.get('ROOT6_WORK_AROUND', 'all').lower()
30  if enabled == 'all':
31  return True
32  if enabled in ('none', 'no', 'off', 'false', '0'):
33  return False
34  if id is None: # unnamed work-arounds can only be disabled globally
35  return True
36  enabled = set(map(str.strip, enabled.split(',')))
37  disabled = set([ e[1:] for e in enabled if e.startswith('-') ])
38  id = id.lower()
39  # the w-a is enabled if in the enabled list or not explicitly disabled
40  return id in enabled or id not in disabled
def ROOT6WorkAroundEnabled(id=None)
Definition: __init__.py:3
struct GAUDI_API map
Parametrisation class for map-like implementation.