Belle II Software  release-08-01-10
callbacks.py
1 #!/usr/bin/env python3
2 
3 
10 
11 """
12 This script provides callback functions to use the recommended global tags.
13 """
14 
15 from basf2 import B2INFO
16 from basf2.version import get_release
17 from versioning import recommended_global_tags_v2
18 
19 
20 def _get_recommended_tags(base_tags, user_tags, metadata):
21  """Get the recommendation from versioning and print a message if there is one"""
22 
23  recommendation = recommended_global_tags_v2(get_release(), base_tags, user_tags, metadata)
24  if 'message' in recommendation.keys():
25  B2INFO('Your global tag manager says: ' + recommendation['message'])
26  return recommendation['tags']
27 
28 
29 def _join_tags(*tags):
30  """Return concatenated list of GTs"""
31  return sum((entry for entry in tags if entry is not None), [])
32 
33 
34 def recommended_tags(base_tags, user_tags, metadata):
35  """Return the the user GTs + the recommended GTs"""
36 
37  recommendation = _get_recommended_tags(base_tags, user_tags, metadata)
38  return _join_tags(user_tags, recommendation)
39 
40 
41 def recommended_analysis_tags(base_tags, user_tags, metadata):
42  """Return the the user GTs + the recommended analysis GTs + the base tags"""
43 
44  recommendation = [tag for tag in _get_recommended_tags(base_tags, user_tags, metadata) if tag.startswith('analysis')]
45  return _join_tags(user_tags, recommendation, base_tags)