Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def write_rst_files(self, root='.'):
self.writing_format = 'rst'
self.main.write_rst_files(root)
if False: # must convert to new structure
fn = os.path.join('dict', 'et_fr.rst')
logger.info("Generate %s", fn)
fd = codecs.open(fn, 'w', 'utf-8')
write_header(fd, 1, 'eesti-prantsuse')
t = rstgen.Table(['Nr.', "ET", "FR", u"hääldamine", "Tasand"])
self.words.sort(sort_by_et)
words_et = [w for w in self.words if not w.hide_et]
t.write(fd, [
(i, w.et, html2rst(w.html_fr()),
w.pronounciation, w.lesson.rst_ref_to())
for i, w in enumerate(words_et)])
fd.close()
fn = os.path.join(root, *self.name_parts()) + ".rst"
logger.info("Generate %s", fn)
newroot = os.path.dirname(fn)
makedirs_if_missing(newroot)
fd = codecs.open(fn, 'w', 'utf-8')
if self.number is None:
title = self.title
else:
title = "%d. %s" % (self.number, self.title)
#~ if self.number is None:
#~ write_header(fd,1,"%s" % self.title)
#~ else:
#~ write_header(fd,1,"%d. %s" % (self.number,self.title))
write_header(fd, 1, self.memo2rst(title))
self.write_body(fd)
fd.close()
for s in self.children:
s.write_rst_files(newroot)