gambit is hosted by Hepforge, IPPP Durham
GAMBIT  v1.5.0-2191-ga4742ac
a Global And Modular Bsm Inference Tool
model_harvester Namespace Reference

Functions

def main (argv)
 

Variables

string toolsfile = "./Utils/scripts/harvesting_tools.py"
 

Function Documentation

◆ main()

def model_harvester.main (   argv)

Definition at line 32 of file model_harvester.py.

References Gambit::ColliderBit.print(), and harvesting_tools.retrieve_generic_headers().

32 def main(argv):
33 
34  model_headers=set([])
35  model_type_headers = set([])
36 
37  # Handle command line options
38  verbose = False
39  try:
40  opts, args = getopt.getopt(argv,"vx:",["verbose","exclude-models="])
41  except getopt.GetoptError:
42  print('Usage: model_harvestor.py [flags]')
43  print(' flags:')
44  print(' -v : More verbose output')
45  sys.exit(2)
46  for opt, arg in opts:
47  if opt in ('-v','--verbose'):
48  verbose = True
49  print('model_harvester.py: verbose=True')
50 
51  # Get list of models to include in models_rollcall.hpp
52  model_headers.update(retrieve_generic_headers(verbose,"./Models/include/gambit/Models/models","model", set()))
53  # Get lists of model type header files
54  model_type_headers.update(retrieve_generic_headers(verbose,"./Models/include/gambit/Models/model_types","model type", set()))
55 
56  if verbose:
57  print("Model headers identified:")
58  for h in model_headers:
59  print(' gambit/Models/models/'+h)
60  print("Model type headers identified:")
61  for h in model_type_headers:
62  print(' gambit/Models/model_types/'+h)
63 
64  # Generate a c++ header containing all the model headers we have just harvested.
65  towrite = "\
66 // GAMBIT: Global and Modular BSM Inference Tool\n\
67 // *********************************************\n\
68 /// \\file \n\
69 /// \n\
70 /// Compile-time registration of GAMBIT models. \n\
71 /// \n\
72 /// This file was automatically generated by \n\
73 /// model_harvester.py. Do not modify. \n\
74 /// \n\
75 /// Do not add to this if you want to add a new \n\
76 /// model -- just add your model header to \n\
77 /// Models/include/gambit/Models/models and rest \n\
78 /// assured that model_harvester.py will make \n\
79 /// sure it ends up here. \n\
80 /// \n\
81 /// *********************************************\n\
82 /// \n\
83 /// Authors (add name and date if you modify): \n\
84 /// \n\
85 /// \\author The GAMBIT Collaboration \n\
86 /// \date "+datetime.datetime.now().strftime("%I:%M%p on %B %d, %Y")+"\n\
87 /// \n\
88 /// *********************************************\n\
89  \n\
90 #ifndef __model_rollcall_hpp__ \n\
91 #define __model_rollcall_hpp__ \n\
92  \n\
93 // Include the model macro definitions \n\
94 #include \"gambit/Models/model_macros.hpp\" \n\
95  \n\
96 // Automatically-generated list of models. \n"
97 
98  for h in model_headers:
99  towrite+='#include \"gambit/Models/models/{0}\"\n'.format(h)
100  towrite+="\n#endif // defined __model_rollcall_hpp__\n"
101 
102  with open("./Models/include/gambit/Models/model_rollcall.hpp","w") as f:
103  f.write(towrite)
104 
105  # Generate a c++ header containing all the model type headers we have just harvested.
106  towrite = "\
107 // GAMBIT: Global and Modular BSM Inference Tool\n\
108 // *********************************************\n\
109 /// \\file \n\
110 /// \n\
111 /// Compile-time registration of GAMBIT model \n\
112 /// types. \n\
113 /// \n\
114 /// This file was automatically generated by \n\
115 /// model_harvester.py. Do not modify. \n\
116 /// \n\
117 /// Do not add to this if you want to add new \n\
118 /// types associated with a new (or old) model. \n\
119 /// Just add your model type header to \n\
120 /// Models/include/gambit/Models/model_types and \n\
121 /// rest assured that model_harvester.py will \n\
122 /// make sure it ends up here. \n\
123 /// \n\
124 /// *********************************************\n\
125 /// \n\
126 /// Authors (add name and date if you modify): \n\
127 /// \n\
128 /// \\author The GAMBIT Collaboration \n\
129 /// \date "+datetime.datetime.now().strftime("%I:%M%p on %B %d, %Y")+"\n\
130 /// \n\
131 /// *********************************************\n\
132  \n\
133 #ifndef __model_types_rollcall_hpp__ \n\
134 #define __model_types_rollcall_hpp__ \n\
135  \n\
136 // Automatically-generated list of model types. \n"
137 
138  for h in model_type_headers:
139  towrite+='#include \"gambit/Models/model_types/{0}\"\n'.format(h)
140  towrite+="\n#endif // defined __model_types_rollcall_hpp__\n"
141 
142  with open("./Models/include/gambit/Models/model_types_rollcall.hpp","w") as f:
143  f.write(towrite)
144 
145  if verbose:
146  print("\nGenerated model_rollcall.hpp.")
147  print("Generated model_types_rollcall.hpp.\n")
148 
149 # Handle command line arguments (verbosity)
void print(MixMatrix A)
Helper function to print a matrix.
def retrieve_generic_headers(verbose, starting_dir, kind, excludes, exclude_list=[])
Here is the call graph for this function:

Variable Documentation

◆ toolsfile

string model_harvester.toolsfile = "./Utils/scripts/harvesting_tools.py"

Definition at line 29 of file model_harvester.py.