5 sys.stderr.write(
'Usage: %s CLASS_NAME\n\n' % sys.argv[0])
7 if not 'MRB_TOP' in os.environ.keys():
8 sys.stderr.write(
'$MRB_TOP not defined!\n\n')
11 name=
'CMAlgo' + sys.argv[1]
12 working_package=
'CMTool' 13 target_dir=
'%s/srcs/larreco/RecoAlg/CMTool' % os.environ[
'MRB_TOP']
14 source_dir=
'%s/mac/tmp' % target_dir
16 in_source=
'%s/cmalgo.cxx' % source_dir
17 in_header=
'%s/cmalgo.h' % source_dir
19 src_list = { in_source :
'%s/%s.cxx' % (target_dir,name),
20 in_header :
'%s/%s.h' % (target_dir,name) }
22 for src
in src_list.keys():
23 if os.path.isfile(src_list[src]):
24 sys.stderr.write(
'File already exists: %s\n\n' % src_list[src])
27 for src
in src_list.keys():
28 contents=
open(src,
'r').read() 29 contents=contents.replace('CMALGO_CLASS_NAME',name.upper())
30 contents=contents.replace(
'cmalgo_class_name',name.lower())
31 contents=contents.replace(
'CMAlgo_Class_Name',name)
32 contents=contents.replace(
'USER',os.environ[
'USER'])
33 contents=contents.replace(
'Working_Package',working_package)
34 fout=
open(src_list[src],
'w')
39 print 'Generated the followings under %s.' % target_dir
40 for key
in src_list.keys():
41 print ' %s' % src_list[key]
int open(const char *, int)
Opens a file descriptor.