+ def do_version(self):
+ self.init_module_dir()
+ self.revert_module_dir()
+ self.update_module_dir()
+ spec_dict = self.spec_dict()
+ if self.options.www:
+ self.html_store_title('Version for module {} ({})'\
+ .format(self.friendly_name(), self.last_tag(spec_dict)))
+ for varname in self.varnames:
+ if varname not in spec_dict:
+ self.html_print('Could not find %define for {}'.format(varname))
+ return
+ else:
+ self.html_print("{:<16} {}".format(varname, spec_dict[varname]))
+ self.html_print("{:<16} {}".format('url', self.repository.url()))
+ if self.options.verbose:
+ self.html_print("{:<16} {}".format('main specfile:', self.main_specname()))
+ self.html_print("{:<16} {}".format('specfiles:', self.all_specnames()))
+ self.html_print_end()
+
+
+##############################
+ def do_diff(self):
+ self.init_module_dir()
+ self.revert_module_dir()
+ self.update_module_dir()
+ spec_dict = self.spec_dict()
+ self.show_dict(spec_dict)
+
+ # side effects
+ tag_name = self.tag_name(spec_dict)
+
+ # sanity check
+ tag_name = self.check_tag(tag_name, need_it=True)
+
+ if self.options.verbose:
+ print('Getting diff')
+ diff_output = self.repository.diff_with_tag(tag_name)
+
+ if self.options.list:
+ if diff_output:
+ print(self.pathname)
+ else:
+ thename = self.friendly_name()
+ do_print = False
+ if self.options.www and diff_output:
+ self.html_store_title("Diffs in module {} ({}) : {} chars"\
+ .format(thename, self.last_tag(spec_dict), len(diff_output)))
+
+ self.html_store_raw('<p> < (left) {} </p>'.format(tag_name))
+ self.html_store_raw('<p> > (right) {} </p>'.format(thename))
+ self.html_store_pre(diff_output)
+ elif not self.options.www:
+ print('x'*30, 'module', thename)
+ print('x'*20, '<', tag_name)
+ print('x'*20, '>', thename)
+ print(diff_output)
+
+##############################
+ # store and restitute html fragments
+ @staticmethod
+ def html_href(url,text):
+ return '<a href="{}">{}</a>'.format(url, text)
+
+ @staticmethod
+ def html_anchor(url,text):
+ return '<a name="{}">{}</a>'.format(url,text)
+
+ @staticmethod
+ def html_quote(text):
+ return text.replace('&', '&').replace('<', '<').replace('>', '>')
+
+ # only the fake error module has multiple titles
+ def html_store_title(self, title):
+ if not hasattr(self,'titles'):
+ self.titles=[]
+ self.titles.append(title)
+
+ def html_store_raw(self, html):
+ if not hasattr(self,'body'):
+ self.body=''
+ self.body += html
+
+ def html_store_pre(self, text):
+ if not hasattr(self,'body'):
+ self.body=''
+ self.body += '<pre>{}</pre>'.format(self.html_quote(text))
+
+ 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>{}</li>'.format(txt))
+
+ def html_print_end(self):
+ if self.options.www:
+ self.html_store_raw('</ul>')
+
+ @staticmethod
+ def html_dump_header(title):
+ nowdate = time.strftime("%Y-%m-%d")
+ nowtime = time.strftime("%H:%M (%Z)")
+ 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> {} </title>
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<style type="text/css">
+body {{ font-family:georgia, serif; }}
+h1 {{font-size: large; }}
+p.title {{font-size: x-large; }}
+span.error {{text-weight:bold; color: red; }}
+</style>
+</head>
+<body>
+<p class='title'> {} - status on {} at {}</p>
+<ul>
+""".format(title, title, nowdate, nowtime))
+
+ @staticmethod
+ def html_dump_middle():
+ print("</ul>")
+
+ @staticmethod
+ def html_dump_footer():
+ print("</body></html")
+
+ def html_dump_toc(self):
+ if hasattr(self,'titles'):
+ for title in self.titles:
+ print('<li>', self.html_href('#'+self.friendly_name(),title), '</li>')
+
+ def html_dump_body(self):
+ if hasattr(self,'titles'):
+ for title in self.titles:
+ 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>')
+
+
+
+class Build(Module):
+
+ def __get_modules(self, tagfile):
+ self.init_module_dir()
+ modules = {}
+
+ tagfile = os.path.join(self.module_dir, tagfile)
+ for line in open(tagfile):