C/C++ style main function.
This function executes all the code stored in this script.
27 from AthenaCommon.Logging
import logging
28 logger = logging.getLogger( os.path.splitext( os.path.basename( sys.argv[ 0 ] ) )[ 0 ] )
33 desc =
"This script can be used to generate a RootCore package out of the D3PDReader " \
34 "sources generated by one of the D3PDReader code generators."
35 vers =
"$Revision: 471380 $"
37 parser = optparse.OptionParser( description = desc,
39 usage =
"%prog [options] <source files>" )
40 parser.add_option(
"-v",
"--verbosity", dest =
"verbosity",
41 action =
"store", type =
"int", default = 3,
42 help =
"Message verbosity level" )
43 parser.add_option(
"-p",
"--package-name", dest =
"packagename",
44 action =
"store", type =
"string", default =
"D3PDReader",
45 help =
"Name for the RootCore package" )
46 parser.add_option(
"-o",
"--output", dest =
"output",
47 action =
"store", type =
"string", default =
"./",
48 help =
"Output directory for the RootCore package" )
51 ( options, files ) = parser.parse_args()
55 logger.error(
"You have to define at least one source file!" )
60 logging.getLogger(
"" ).
setLevel( options.verbosity )
63 logger.info(
"***********************************************************" )
64 logger.info(
"* D3PDReader RootCore Package Maker" )
65 logger.info(
"* Version: $Revision: 471380 $" )
67 logger.info(
"* Output level: " +
str( options.verbosity ) )
68 logger.info(
"* Package name: " + options.packagename )
69 logger.info(
"* Output directory: " + options.output )
70 logger.info(
"* Source files: " +
", ".
join( files ) )
71 logger.info(
"***********************************************************" )
79 logger.error(
"Failed to create RootCore package skeleton" )
84 for header
in header_files:
85 shutil.copy( header, options.output +
"/" + options.packagename + \
86 "/" + options.packagename )
90 for source
in source_files:
91 shutil.copy( source, options.output +
"/" + options.packagename +
"/Root/" )
95 rootcore_sources = [ ( options.output +
"/" + options.packagename +
"/Root/" + \
96 os.path.basename( source ) )
for source
in source_files ]
97 for source
in rootcore_sources:
99 sfile =
open( source,
"r" )
104 cont = re.sub(
"#include \"(.*)\"",
105 "#include \"../%s/\g<1>\"" % options.packagename,
109 sfile =
open( source,
"w" )
118 if writeLinkDefFile( options.output +
"/" + options.packagename +
"/Root/LinkDef.h",
120 [ (
"../" + options.packagename +
"/" + os.path.basename( header ) ) \
121 for header
in dictionary_header_files ] ):
122 logger.error(
"Failed writing RootCore LinkDef.h file" )
127 clog =
open( options.output +
"/" + options.packagename +
"/ChangeLog",
"w" )
128 clog.write(
"%s d3pdReaderRootCoreMaker.py <Attila.Krasznahorkay@cern.ch>\n" % datetime.date.today() )
129 clog.write(
"\t* Created the package\n" )