<s> """<STR_LIT>""" <EOL> __author__ = "<STR_LIT>" <EOL> __revision__ = "<STR_LIT>" [ <NUM_LIT:11> : - <NUM_LIT:2> ] <EOL> import time , types , os , sys <EOL> from Cheetah . Template import Template <EOL> True = ( <NUM_LIT:1> == <NUM_LIT:1> ) <EOL> False = ( <NUM_LIT:0> == <NUM_LIT:1> ) <EOL> class _SkeletonPage ( Template ) : <EOL> """<STR_LIT>""" <EOL> docType = '<STR_LIT>' + '<STR_LIT>' <EOL> title = '<STR_LIT>' <EOL> siteDomainName = '<STR_LIT>' <EOL> siteCredits = '<STR_LIT>' <EOL> siteCopyrightName = "<STR_LIT>" <EOL> htmlTag = '<STR_LIT>' <EOL> def __init__ ( self , * args , ** KWs ) : <EOL> Template . __init__ ( self , * args , ** KWs ) <EOL> self . _metaTags = { '<STR_LIT>' : { '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT:Content-Type>' : '<STR_LIT>' , <EOL> } , <EOL> '<STR_LIT>' : { '<STR_LIT>' : '<STR_LIT>' } <EOL> } <EOL> self . _stylesheets = { } <EOL> self . _stylesheetsOrder = [ ] <EOL> self . _stylesheetLibs = { } <EOL> self . _javascriptLibs = { } <EOL> self . _javascriptTags = { } <EOL> self . _bodyTagAttribs = { } <EOL> def metaTags ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . formatMetaTags ( self . _metaTags ) <EOL> def stylesheetTags ( self ) : <EOL> """<STR_LIT>""" <EOL> stylesheetTagsTxt = '<STR_LIT>' <EOL> for title , src in self . _stylesheetLibs . items ( ) : <EOL> stylesheetTagsTxt += '<STR_LIT>' + str ( src ) + '<STR_LIT>' <EOL> if not self . _stylesheetsOrder : <EOL> return stylesheetTagsTxt <EOL> stylesheetTagsTxt += '<STR_LIT>' <EOL> for identifier in self . _stylesheetsOrder : <EOL> if not self . _stylesheets . has_key ( identifier ) : <EOL> warning = '<STR_LIT>' + identifier + '<STR_LIT>' <EOL> print warning <EOL> stylesheetTagsTxt += warning <EOL> continue <EOL> attribsDict = self . _stylesheets [ identifier ] <EOL> cssCode = '<STR_LIT>' <EOL> attribCode = '<STR_LIT>' <EOL> for k , v in attribsDict . items ( ) : <EOL> attribCode += str ( k ) + '<STR_LIT>' + str ( v ) + '<STR_LIT>' <EOL> attribCode = attribCode [ : - <NUM_LIT:2> ] <EOL> cssCode = '<STR_LIT:\n>' + identifier + '<STR_LIT>' + attribCode + '<STR_LIT:}>' <EOL> stylesheetTagsTxt += cssCode <EOL> stylesheetTagsTxt += '<STR_LIT>' <EOL> return stylesheetTagsTxt <EOL> def javascriptTags ( self ) : <EOL> """<STR_LIT>""" <EOL> javascriptTagsTxt = [ ] <EOL> for key , details in self . _javascriptTags . items ( ) : <EOL> if type ( details ) not in ( types . ListType , types . TupleType ) : <EOL> details = [ '<STR_LIT>' , details ] <EOL> javascriptTagsTxt += [ '<STR_LIT>' , str ( details [ <NUM_LIT:0> ] ) , <EOL> '<STR_LIT>' , <EOL> str ( details [ <NUM_LIT:0> ] ) , '<STR_LIT>' ] <EOL> for key , details in self . _javascriptLibs . items ( ) : <EOL> if type ( details ) not in ( types . ListType , types . TupleType ) : <EOL> details = [ '<STR_LIT>' , details ] <EOL> javascriptTagsTxt += [ '<STR_LIT>' , str ( details [ <NUM_LIT:0> ] ) , <EOL> '<STR_LIT>' , <EOL> str ( details [ <NUM_LIT:1> ] ) , '<STR_LIT>' ] <EOL> return '<STR_LIT>' . join ( javascriptTagsTxt ) <EOL> def bodyTag ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . formHTMLTag ( '<STR_LIT:body>' , self . _bodyTagAttribs ) <EOL> def imgTag ( self , src , alt = '<STR_LIT>' , width = None , height = None , border = <NUM_LIT:0> ) : <EOL> """<STR_LIT>""" <EOL> src = self . normalizePath ( src ) <EOL> if not width or not height : <EOL> try : <EOL> import Image <EOL> im = Image . open ( src ) <EOL> calcWidth , calcHeight = im . size <EOL> del im <EOL> if not width : width = calcWidth <EOL> if not height : height = calcHeight <EOL> except : <EOL> try : <EOL> calcWidth , calcHeight = os . popen ( <EOL> '<STR_LIT>' + src ) . read ( ) . split ( '<STR_LIT:U+002C>' ) <EOL> if not width : width = calcWidth <EOL> if not height : height = calcHeight <EOL> except : <EOL> pass <EOL> if width and height : <EOL> return '<STR_LIT>' . join ( [ '<STR_LIT>' , src , '<STR_LIT>' , str ( width ) , '<STR_LIT>' , str ( height ) , <EOL> '<STR_LIT>' , alt , '<STR_LIT>' , str ( border ) , '<STR_LIT>' ] ) <EOL> elif width : <EOL> return '<STR_LIT>' . join ( [ '<STR_LIT>' , src , '<STR_LIT>' , str ( width ) , <EOL> '<STR_LIT>' , alt , '<STR_LIT>' , str ( border ) , '<STR_LIT>' ] ) <EOL> elif height : <EOL> return '<STR_LIT>' . join ( [ '<STR_LIT>' , src , '<STR_LIT>' , str ( height ) , <EOL> '<STR_LIT>' , alt , '<STR_LIT>' , str ( border ) , '<STR_LIT>' ] ) <EOL> else : <EOL> return '<STR_LIT>' . join ( [ '<STR_LIT>' , src , '<STR_LIT>' , alt , '<STR_LIT>' , str ( border ) , '<STR_LIT>' ] ) <EOL> def currentYr ( self ) : <EOL> """<STR_LIT>""" <EOL> return time . strftime ( "<STR_LIT>" , time . localtime ( time . time ( ) ) ) <EOL> def currentDate ( self , formatString = "<STR_LIT>" ) : <EOL> """<STR_LIT>""" <EOL> return time . strftime ( formatString , time . localtime ( time . time ( ) ) ) <EOL> def spacer ( self , width = <NUM_LIT:1> , height = <NUM_LIT:1> ) : <EOL> return '<STR_LIT>' % ( str ( width ) , str ( height ) ) <EOL> def formHTMLTag ( self , tagName , attributes = { } ) : <EOL> """<STR_LIT>""" <EOL> tagTxt = [ '<STR_LIT:<>' , tagName . lower ( ) ] <EOL> for name , val in attributes . items ( ) : <EOL> tagTxt += [ '<STR_LIT:U+0020>' , name . lower ( ) , '<STR_LIT>' , str ( val ) , '<STR_LIT:">' ] <EOL> tagTxt . append ( '<STR_LIT:>>' ) <EOL> return '<STR_LIT>' . join ( tagTxt ) <EOL> def formatMetaTags ( self , metaTags ) : <EOL> """<STR_LIT>""" <EOL> metaTagsTxt = [ ] <EOL> if metaTags . has_key ( '<STR_LIT>' ) : <EOL> for http_equiv , contents in metaTags [ '<STR_LIT>' ] . items ( ) : <EOL> metaTagsTxt += [ '<STR_LIT>' , str ( http_equiv ) , '<STR_LIT>' , <EOL> str ( contents ) , '<STR_LIT>' ] <EOL> if metaTags . has_key ( '<STR_LIT>' ) : <EOL> for name , contents in metaTags [ '<STR_LIT>' ] . items ( ) : <EOL> metaTagsTxt += [ '<STR_LIT>' , str ( name ) , '<STR_LIT>' , str ( contents ) , <EOL> '<STR_LIT>' ] <EOL> return '<STR_LIT>' . join ( metaTagsTxt ) </s>
