19 import options_class, options_rosetta
23 Options = options_rosetta.Options
38 if existing_file.read() != self.
body:
45 print "file",self.
fname,
"being updated"
63 header1 =
'// -*- mode:c++;tab-width:2;indent-tabs-mode:t;show-trailing-whitespace:t;rm-trailing-spaces:t -*-\n' +
'// vi: set ts=2 noet:\n' +
'//\n' +
'// (c) Copyright Rosetta Commons Member Institutions.\n' +
'// (c) This file is part of the Rosetta software suite and is made available under license.\n' +
'// (c) The Rosetta software is developed by the contributing members of the Rosetta Commons.\n' +
'// (c) For more information, see http://www.rosettacommons.org. Questions about this can be\n' +
'// (c) addressed to University of Washington UW TechTransfer, email: license@u.washington.edu.\n\n'
64 header3 =
'\n/// @brief basic::options::OptionKeys collection\n' +
'/// @author Stuart G. Mentzer (Stuart_Mentzer@objexx.com)\n' +
'/// @author James M. Thompson (tex@u.washington.edu)\n' +
'\n'
65 header5 =
'\n// Unit headers\n#include <basic/options/keys/OptionKeys.hh>\n\n' +
'namespace basic {\n' +
'namespace options {\n' +
'namespace OptionKeys {\n' +
'\n'
66 footer =
'\n} // namespace OptionKeys\n' +
'} // namespace options\n' +
'} // namespace basic\n\n#endif\n'
67 header_gen_hh =
'#ifndef OPTION_CC_GEN_HH\n' +\
68 '#define OPTION_CC_GEN_HH\n'+\
69 '#include <basic/options/option.hh>\n' + \
70 '#include <basic/options/option.cc.include.gen.hh>\n' + \
71 '#include <utility/options/OptionCollection.hh>\n'
73 footer_gen_hh_pre =
'\ninline void add_all_rosetta_options( utility::options::OptionCollection &option ) {\n'
74 footer_gen_hh_post =
'}\n#endif\n'
83 output[
'option.cc.gen.hh' ] = []
84 output[
'keys/OptionKeys.gen.hh' ] = {}
85 output[
'keys/OptionKeys.cc.gen' ] = []
93 ns = str( opt.get_namespace(0) )
96 if not output[
'keys/OptionKeys.gen.hh' ].has_key( ns ):
97 output[
'keys/OptionKeys.gen.hh' ][ ns ] = []
99 output[
'option.cc.gen.hh' ].append( opt.getOptionCC() )
100 output[
'keys/OptionKeys.gen.hh' ][ ns ].append( opt.getOptionKeysHH() )
101 output[
'keys/OptionKeys.cc.gen' ].append( opt.getOptionKeysCC() )
106 for file_prefix
in output.keys():
107 (dirname,filename) = os.path.split( file_prefix )
108 if file_prefix ==
'option.cc.gen.hh':
109 outfile = file_prefix
112 f.write( header_gen_hh )
114 split_len =
len( output[ file_prefix ] ) // 16 + 1
115 groups = [ output[ file_prefix ][i: i+split_len]
for i
in range(0,
len(output[ file_prefix ]), split_len) ]
116 for i,g
in enumerate(groups):
117 lines =
'inline void add_rosetta_options_%s( utility::options::OptionCollection &option ) {' % i
118 lines +=
"".
join(g) +
'\n}\n'
121 f.write( footer_gen_hh_pre )
122 for i,g
in enumerate(groups):
123 f.write(
'\tadd_rosetta_options_%s( option );\n' %i )
124 f.write( footer_gen_hh_post )
125 num_changed_files += f.close()
126 elif file_prefix ==
'keys/OptionKeys.cc.gen':
127 split_len =
len( output[ file_prefix ] ) // 16 + 1
128 groups = [ output[ file_prefix ][i: i+split_len]
for i
in range(0,
len(output[ file_prefix ]), split_len) ]
129 for i,g
in enumerate(groups):
130 outfile = file_prefix +
'%s.hh' % i
133 f.write(
"".
join(g) )
134 num_changed_files += f.close()
136 for ns
in output[ file_prefix ].keys():
137 new_filename =
".".
join( [ns, filename] )
138 outfile = os.path.join( dirname, new_filename )
139 header2 =
'/// @file basic/options/' + outfile
140 full_fn =
'basic/options/keys/' + ns +
'_OptionKeys_gen_HH'
141 inc_path = full_fn.replace(
'/',
'_')
142 inc_symb =
'INCLUDED_' + inc_path
143 header4 =
'#ifndef ' + inc_symb +
'\n#define ' + inc_symb +
'\n'
144 gen_hh_files.append( new_filename )
145 header = [ header1, header2, header3, header4, header5 ]
146 output[ file_prefix ][ ns ].append( footer )
147 output[ file_prefix ][ ns ] = header + output[ file_prefix ][ ns ]
148 lines =
"".
join( output[ file_prefix ][ ns ] )
151 f.write(
"".
join(lines) )
152 num_changed_files += f.close()
155 for include_file
in gen_hh_files:
156 f.write(
'#include <basic/options/keys/' + include_file +
'>\n' )
157 num_changed_files += f.close()
168 num_changed_files += f.close()
173 num_changed_files += f.close()
175 print "Number of option files updated:",num_changed_files
176 print "Total %s options." %
len(Options)
178 elif args[1] ==
'-Wiki':
182 if __name__ ==
"__main__":
main(sys.argv)
Fstring::size_type len(Fstring const &s)
Length.
bool open(utility::io::izstream &db_stream, std::string const &db_file, bool warn)
Open a database file on a provided stream.