def html_href (url,text): return '<a href="%s">%s</a>'%(url,text)
@staticmethod
def html_anchor (url,text): return '<a name="%s">%s</a>'%(url,text)
+ # there must be some smarter means to do that - dirty for now
+ @staticmethod
+ def html_quote (text):
+ return text.replace('&','&').replace('<','<').replace('>','>')
# only the fake error module has multiple titles
def html_store_title (self, title):
self.body += html
def html_store_pre (self, text):
if not hasattr(self,'body'): self.body=''
- self.body += '<pre>' + text + '</pre>'
+ self.body += '<pre>' + self.html_quote(text) + '</pre>'
+
+ def html_print (self, txt):
+ if not self.options.www:
+ print txt
+ else:
+ if not hasattr(self,'in_list') or not self.in_list:
+ self.html_store_raw('<ul>')
+ self.in_list=True
+ self.html_store_raw('<li>'+txt+'</li>')
+ def html_print_end (self):
+ if self.options.www:
+ self.html_store_raw ('</ul>')
- def html_dump_header(self):
- now=time.strftime("%Y-%m-%d %H:%M")
+ @staticmethod
+ def html_dump_header(title):
+ nowdate=time.strftime("%Y-%m-%d")
+ nowtime=time.strftime("%H:%M")
print """
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
-<title> Pending changes in %s </title>
+<title> %s </title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
body { font-family:georgia, serif; }
</style>
</head>
<body>
-<p class='title'> Pending changes in %s - status at %s</p>
+<p class='title'> %s - status on %s at %s</p>
<ul>
-"""%(self.options.www,self.options.www,now)
+"""%(title,title,nowdate,nowtime)
@staticmethod
def html_dump_middle():
def html_dump_body(self):
if hasattr(self,'titles'):
for title in self.titles:
- print ('<hr />')
- print '<h1>',self.html_anchor(self.friendly_name(),title),'</h1>'
+ print '<hr /><h1>',self.html_anchor(self.friendly_name(),title),'</h1>'
if hasattr(self,'body'):
print self.body
+ print '<p class="top">',self.html_href('#','Back to top'),'</p>'
####################
@staticmethod
else:
return "%s/trunk"%(self.mod_url())
+ def last_tag (self, spec_dict):
+ return "%s-%s"%(spec_dict[self.module_version_varname],spec_dict[self.module_taglevel_varname])
+
def tag_name (self, spec_dict):
try:
- return "%s-%s-%s"%(#spec_dict[self.module_name_varname],
- self.name,
- spec_dict[self.module_version_varname],
- spec_dict[self.module_taglevel_varname])
+ return "%s-%s"%(self.name,
+ self.last_tag(spec_dict))
except KeyError,err:
raise Exception, 'Something is wrong with module %s, cannot determine %s - exiting'%(self.name,err)
self.revert_edge_dir()
self.update_edge_dir()
spec_dict = self.spec_dict()
+ if self.options.www:
+ self.html_store_title('Version for module %s (%s)' % (self.friendly_name(),self.last_tag(spec_dict)))
for varname in self.varnames:
if not spec_dict.has_key(varname):
- print 'Could not find %%define for %s'%varname
+ self.html_print ('Could not find %%define for %s'%varname)
return
else:
- print "%-16s %s"%(varname,spec_dict[varname])
+ self.html_print ("%-16s %s"%(varname,spec_dict[varname]))
if self.options.show_urls:
- print "%-16s %s"%('edge url',self.edge_url())
- print "%-16s %s"%('latest tag url',self.tag_url(spec_dict))
+ self.html_print ("%-16s %s"%('edge url',self.edge_url()))
+ self.html_print ("%-16s %s"%('latest tag url',self.tag_url(spec_dict)))
if self.options.verbose:
- print "%-16s %s"%('main specfile:',self.main_specname())
- print "%-16s %s"%('specfiles:',self.all_specnames())
+ self.html_print ("%-16s %s"%('main specfile:',self.main_specname()))
+ self.html_print ("%-16s %s"%('specfiles:',self.all_specnames()))
+ self.html_print_end()
##############################
def do_list (self):
if diff_output:
print self.name
else:
- anchor=self.friendly_name()
+ thename=self.friendly_name()
do_print=False
if self.options.www and diff_output:
- self.html_store_title("Diffs in module %s (%d chars)"%(anchor,len(diff_output)))
+ self.html_store_title("Diffs in module %s (%s) : %d chars"%(\
+ thename,self.last_tag(spec_dict),len(diff_output)))
link=self.html_href(tag_url,tag_url)
self.html_store_raw ('<p> < (left) %s </p>'%link)
link=self.html_href(edge_url,edge_url)
self.html_store_raw ('<p> > (right) %s </p>'%link)
self.html_store_pre (diff_output)
elif not self.options.www:
- print 'x'*30,'module',anchor
+ print 'x'*30,'module',thename
print 'x'*20,'<',tag_url
print 'x'*20,'>',edge_url
print diff_output
if mode == "sync" :
parser.add_option("-m","--message", action="store", dest="message", default=None,
help="specify log message")
- if mode == "diff" :
+ if mode in ["diff","version"] :
parser.add_option("-W","--www", action="store", dest="www", default=False,
help="export diff in html format, e.g. -W trunk")
if mode == "diff" :
method(module)
except Exception,e:
if options.www:
- title='<span class="error"> Skipping module %s - failure: %s </span>'%(module.name, str(e))
+ title='<span class="error"> Skipping module %s - failure: %s </span>'%\
+ (module.friendly_name(), str(e))
error_module.html_store_title(title)
else:
print 'Skipping module %s: '%modname,e
# in which case we do the actual printing in the second pass
if options.www:
+ if mode == "diff":
+ modetitle="Changes to tag in %s"%options.www
+ elif mode == "version":
+ modetitle="Latest tags in %s"%options.www
modules.append(error_module)
- error_module.html_dump_header()
+ error_module.html_dump_header(modetitle)
for module in modules:
module.html_dump_toc()
Module.html_dump_middle()