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