CMS 3D CMS Logo

Public Member Functions | Public Attributes

valtools::webpage Class Reference

List of all members.

Public Member Functions

def __init__
def parseArgs
def readCaption
def readCaptions
def setOutputDir

Public Attributes

 benchmarkName_
 date_
 dirPlots_
 outputDir_
 parser_
 rootFile_
 templates_

Detailed Description

Definition at line 10 of file valtools.py.


Constructor & Destructor Documentation

def valtools::webpage::__init__ (   self)

Definition at line 13 of file valtools.py.

00014                       :
00015         self.parser_ = OptionParser()
00016         self.parser_.add_option("-c", "--comments", dest="comments",
00017                                help="name of another release",
00018                                default=None)
00019         self.parser_.add_option("-f", "--force", dest="force",
00020                                 action="store_true",
00021                                 help="overwrites the local benchmark page.",
00022                                 default=False)
00023         self.rootFile_ = 'benchmark.root'
00024         self.dirPlots_ = './'
00025         self.templates_ = '../Tools/templates'
00026         self.date_ =  os.popen( 'date' ).read()
00027         self.benchmarkName_ = os.path.basename( os.getcwd() ) 


Member Function Documentation

def valtools::webpage::parseArgs (   self)

Definition at line 28 of file valtools.py.

00029                        :
00030         (self.options_, self.args_) = self.parser_.parse_args()

def valtools::webpage::readCaption (   self,
  line 
)

Definition at line 71 of file valtools.py.

00072                                  :
00073         
00074         if( re.compile('^\s*$').match(line) ):
00075             raise Exception
00076         
00077         p = re.compile('^\s*(\S+)\s*\"(.*)\"');
00078         m = p.match(line)
00079         if m:
00080             pic = m.group(1)
00081             caption = m.group(2)
00082             return (pic, caption)
00083         else:
00084             print 'bad caption format: "%s"' % line
00085             raise Exception

def valtools::webpage::readCaptions (   self,
  captions 
)

Definition at line 47 of file valtools.py.

00048                                     :
00049         imgTemplate = '<IMG src="%s" width="500" align="left" border="0"><br clear="ALL">'
00050         images = ''
00051         captionsContents = open( captions )
00052         for line in captionsContents:
00053             try:
00054                 (picfile, caption) = self.readCaption( line )
00055                 img = imgTemplate % os.path.basename(picfile)
00056                 images = "%s<h3>%s:</h3>\n%s\n" % (images, caption, img)
00057                 # what to do if the file's not there? 
00058                 # : print a warning
00059                 shutil.copy(picfile, self.outputDir_) 
00060             except Exception:
00061                 print 'File %s does not exist. Did you generate the comparison plots?' % picfile
00062                 print 'Aborting the script.\n'
00063                 print 'Solution 1: run without the -m "" option, to run the compare.C macro'
00064                 print 'Solution 2: run with the -m "myMacro.C" option, to run another macro'
00065                 sys.exit(1)
00066                 raise
00067         return images

def valtools::webpage::setOutputDir (   self,
  outputDir 
)

Definition at line 32 of file valtools.py.

00033                                       :
00034 
00035         self.outputDir_ = outputDir
00036         if os.path.isdir( outputDir ):
00037             print outputDir, "already exists"
00038             if self.options_.force == False:
00039                 print 'sorry... run the script with the -h option for more information' 
00040                 sys.exit(3)
00041             else:
00042                 print 'overwriting local output directory...'
00043         else:
00044             os.makedirs( outputDir )


Member Data Documentation

Definition at line 13 of file valtools.py.

Definition at line 13 of file valtools.py.

Definition at line 13 of file valtools.py.

Definition at line 32 of file valtools.py.

Definition at line 13 of file valtools.py.

Definition at line 13 of file valtools.py.

Definition at line 13 of file valtools.py.