gambit is hosted by Hepforge, IPPP Durham
GAMBIT  v1.5.0-2191-ga4742ac
a Global And Modular Bsm Inference Tool
find_all_gambit_bits.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 
3 import os
4 import yaml
5 import argparse
6 
7 
8 def get_bits_from_directory_list(gambit_directory):
9  """Get Gambit Bits.
10 
11  Return a sorted list of directory names with "Bit" in the name.
12  This effectively generates a list of all available Bits in Gambit based on the established nameing scheme inside the Gambit repository.
13 
14  Args:
15  gambit_directory (str): Directory to search in. To work properly this has to be the Gambit source directory.
16 
17  Returns:
18  list: sorted list of Gambit Bits
19  """
20  return sorted(set([directory for directory in os.listdir(gambit_directory) if "Bit" in directory]))
21 
22 
23 def write_list_to_yaml(list_of_bits, output_file, yaml_key="gambit_bits"):
24  """Write given list to a yaml file.
25 
26  Args:
27  list_of_bits list(str): List of Gambit Bits.
28  output_file (str): Path/name for the output file.
29  yaml_key (str): Key which is used to write the yaml file.
30  """
31  with open(output_file, "w+") as f:
32  yaml.dump({
33  yaml_key: list_of_bits
34  }, f)
35 
36 
37 if __name__ == "__main__":
38  parser = argparse.ArgumentParser(description="""Generates a list of all available Gambit Bits which can be used by the Gambit cmake and diagnostic systems.""")
39  parser.add_argument("--source-dir", required=True, help="Source directory of the Gambit repository.")
40  parser.add_argument("--output-file", required=True, help="Output path for the generated yaml file containing the list of Bits. Recommended to place the file in config/gambit_bits.yaml.")
41  args = parser.parse_args()
42 
44  get_bits_from_directory_list(args.source_dir),
45  args.output_file
46  )
def get_bits_from_directory_list(gambit_directory)
def write_list_to_yaml(list_of_bits, output_file, yaml_key="gambit_bits")