rst2odt and odf-config-file option

POIRET via Docutils-users <[email protected]>
Newsgroups gmane.text.docutils.user
Message-ID <[email protected]>
Hello, 

I guess I've found a bug on rst2odt.py 

-- 

I wanted to
apply custom style with rst2odt, and discovered the --odf-config-file
option. 

This option allows to map the default style to a custom one
(so, used in conjunction with --template option). 

But it was not
working on my environment (Debian 9, python3, docutils 1.4) 

-- 

The
__init__ method (l. 888) of the ODFTranslator class initializes a
dictionary : format_map, but it's filled only for python2 

Involved
file:
/usr/lib/python3/dist-packages/docutils/writers/odf_odt/__init__.py 

  
   parser = ConfigParser()
           
parser.read(self.settings.odf_config_file)
            for rststyle,
format in parser.items("Formats"):
                if rststyle not in
self.used_styles:
                    self.document.reporter.warning(
  
                    'Style "%s" is not a style used by odtwriter.' % (

                          rststyle, ))
                if
sys.version_info.major == 2:
                   
self.format_map[rststyle] = format.decode('utf-8')
               # my
addition below 

               else:
                   
self.format_map[rststyle] = format 

---

After applying my update, it
works. (never tested with python2)

Let me know if I can do something
else. 

Regards, 

-- 

Gilles
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.