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 an SFrame 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 SFrame 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 +
"/include/" )
89 for source
in source_files:
90 shutil.copy( source, options.output +
"/" + options.packagename +
"/src/" )
94 sframe_sources = [ ( options.output +
"/" + options.packagename +
"/src/" + \
95 os.path.basename( source ) )
for source
in source_files ]
96 for source
in sframe_sources:
98 sfile =
open( source,
"r" )
103 cont = re.sub(
"#include \"(.*)\"",
104 "#include \"../include/\g<1>\"", cont )
107 sfile =
open( source,
"w" )
116 if writeLinkDefFile( options.output +
"/" + options.packagename +
"/include/" + \
117 options.packagename +
"_LinkDef.h", classnames ):
118 logger.error(
"Failed writing SFrame LinkDef.h file" )
123 clog =
open( options.output +
"/" + options.packagename +
"/ChangeLog",
"w" )
124 clog.write(
"%s d3pdReaderSFrameMaker.py <Attila.Krasznahorkay@cern.ch>\n" % \
125 datetime.date.today() )
126 clog.write(
"\t* Created the package\n" )