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

Functions

def main (argv)
 

Variables

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

Function Documentation

◆ main()

def printer_harvester.main (   argv)

Definition at line 34 of file printer_harvester.py.

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

34 def main(argv):
35 
36  printer_headers=set([]) # Printer definition headers
37  extra_headers=set([]) # Extra headers needed by printers
38  extra_source=set([]) # Extra source files needed by printers
39  exclude_printers=set([]) # -Ditch'ed printers
40 
41  # Handle command line options
42  verbose = False
43  try:
44  opts, args = getopt.gnu_getopt(argv,"vx:",["verbose","exclude-printers="])
45  except getopt.GetoptError:
46  print('Usage: printer_harvestor.py [flags]')
47  print(' flags:')
48  print(' -v : More verbose output')
49  print(' -x printer1,printer2,... : Exclude printer1, printer2, etc.')
50  sys.exit(2)
51  for opt, arg in opts:
52  if opt in ('-v','--verbose'):
53  verbose = True
54  print('printer_harvester.py: verbose=True')
55  elif opt in ('-x','--exclude-printers'):
56  exclude_printers.update(neatsplit(",",arg))
57 
58  # Get list of printers to include in printers_rollcall.hpp
59  printer_headers.update(retrieve_generic_headers(verbose,"./Printers/include/gambit/Printers/printers","printer",exclude_printers))
60 
61  # Generate a c++ header containing all the printer headers we have just harvested.
62  towrite = "\
63 // GAMBIT: Global and Modular BSM Inference Tool\n\
64 // *********************************************\n\
65 /// \\file \n\
66 /// \n\
67 /// Compile-time registration of GAMBIT printers.\n\
68 /// \n\
69 /// This file was automatically generated by \n\
70 /// printer_harvester.py. Do not modify. \n\
71 /// \n\
72 /// Do not add to this if you want to add a new \n\
73 /// printer -- just add your printer header to \n\
74 /// Printers/include/gambit/Printers/ \n\
75 /// and rest assured that printer_harvester.py \n\
76 /// will make sure it ends up here. \n\
77 /// \n\
78 /// *********************************************\n\
79 /// \n\
80 /// Authors (add name and date if you modify): \n\
81 /// \n\
82 /// \\author The GAMBIT Collaboration \n\
83 /// \date "+datetime.datetime.now().strftime("%I:%M%p on %B %d, %Y")+"\n\
84 /// \n\
85 /// *********************************************\n\
86  \n\
87 #ifndef __printer_rollcall_hpp__ \n\
88 #define __printer_rollcall_hpp__ \n\
89  \n\
90 // Automatically-generated list of printers. \n"
91 
92  for h in printer_headers:
93  towrite+='#include \"gambit/Printers/printers/{0}\"\n'.format(h)
94  towrite+="\n#endif // defined __printer_rollcall_hpp__\n"
95 
96  # Don't touch any existing file unless it is actually different from what we will create
97  header = "./Printers/include/gambit/Printers/printer_rollcall.hpp"
98  candidate = "./scratch/build_time/printer_rollcall.hpp.candidate"
99  with open(candidate,"w") as f: f.write(towrite)
100  update_only_if_different(header, candidate)
101 
102  if verbose:
103  print("\nGenerated printer_rollcall.hpp.")
104 
105 # 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=[])
def update_only_if_different(existing, candidate, verbose=True)
def neatsplit(regex, string)
Here is the call graph for this function:

Variable Documentation

◆ toolsfile

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

Definition at line 31 of file printer_harvester.py.