From: Gianluca Montecchi Date: Thu, 22 Oct 2009 20:20:19 +0000 (+0200) Subject: - Merged Trevor branch X-Git-Tag: 1.0.0~59^2~11^2~2 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=a60e599798d43ba930efc1f8e2f184d3e8262189;p=be.git - Merged Trevor branch - Reapplied the fix for subdirs --- a60e599798d43ba930efc1f8e2f184d3e8262189 diff --cc becommands/html.py index 0b28b4a,d1bd625..b0640da --- a/becommands/html.py +++ b/becommands/html.py @@@ -325,15 -298,52 +298,52 @@@ class HTMLGen (object) ('bug_comment_entry.tpl','bug_comment_entry')]: fullpath = os.path.join(self.template, filename) if os.path.exists(fullpath): - f = codecs.open(fullpath, "r", self.encoding) - setattr(self, attr, f.read()) - f.close() - - def _write_file(self, tpl, filename ): - f = codecs.open(os.path.join(self.out_dir, filename), "w", self.encoding) - f.write(tpl) + setattr(self, attr, self._read_file([fullpath])) + + def _make_dir(self, dir_path): + dir_path = os.path.abspath(os.path.expanduser(dir_path)) + if not os.path.exists(dir_path): + try: - os.mkdir(dir_path) ++ os.makedirs(dir_path) + except: + raise cmdutil.UsageError, "Cannot create output directory '%s'." % dir_path + return dir_path + + def _write_file(self, content, path_array, mode='w'): + f = codecs.open(os.path.join(*path_array), mode, self.encoding) + f.write(content) + f.close() + + def _read_file(self, path_array, mode='r'): + f = codecs.open(os.path.join(*path_array), mode, self.encoding) + content = f.read() f.close() - + return content + + def write_default_template(self, out_dir): + if self.verbose: + print "Creating output directories" + self.out_dir = self._make_dir(out_dir) + if self.verbose: + print "Creating css file" + self._write_css_file() + if self.verbose: + print "Creating index_file.tpl file" + self._write_file(self.index_file, + [self.out_dir, "index_file.tpl"]) + if self.verbose: + print "Creating index_bug_entry.tpl file" + self._write_file(self.index_bug_entry, + [self.out_dir, "index_bug_entry.tpl"]) + if self.verbose: + print "Creating bug_file.tpl file" + self._write_file(self.bug_file, + [self.out_dir, "bug_file.tpl"]) + if self.verbose: + print "Creating bug_comment_entry.tpl file" + self._write_file(self.bug_comment_entry, + [self.out_dir, "bug_comment_entry.tpl"]) + def _load_default_templates(self): self.css_file = """ body {