Re: rst2odt and odf-config-file option
Dave Kuhlman <[email protected]>
| Newsgroups | gmane.text.docutils.user |
|---|---|
| Message-ID | <[email protected]> |
I've run into a bit of a problem.
I've used docutils `odf_odt/__init__.py` under Python3. That works.
But, the reason is because the version I've used is out of the
Anaconda Python 3 distribution, *and* that has been converted for
Python 3. The version in the docutils SVN repository has *not* been
converted. Maybe Gilles is using the Anaconda version, too. I'm
pretty sure that they (the people at `https://www.anaconda.com`) ran
`odf_odt/__init__.py` through `2to3` and used that result, as is.
When I run the Python 2 version through `2to3` I get a file that's
identical to theirs, except for one more recent change.
So, I need to ask: We want a *single* version that runs under both
Python 2 and Python 3, right?
Since a version that has been converted with `2to3` only runs under
Python 3, I'll need to do the following:
1. Convert `odf_odt/__init__.py` so that it runs under both Python 2
and Python 3. Then do a commit and check-in.
2. Add Gilles's change. Then do a commit and check-in.
3. Do the clean-up for `flake8` and `pep8`. Then do a commit and
check-in.
I'm pretty sure that is what we want. But, I thought I'd ask,
because the number of changes needed for Python 3 is quite large.
In the meantime, I'll get started. Suggestions and guidance will be
welcomed.
Dave
On Thu, Feb 07, 2019 at 12:04:47PM -0800, Dave Kuhlman wrote:
> Gilles,
>
> Ugh. Did I really do that?
>
> Thanks for this fix.
>
> I'll do some testing and will check the unit tests. Then I'll push
> it back to the repo.
>
> Question for the docutils list: When I apply the `flake8` style and
> error checker to `__init__.py`, I get lots of warnings (405 when I
> count them with `wc`). Most of them have to do with indentation,
> missing or extra blank lines, missing or extra spaces, etc. I'm
> willing to clean those up. Or, would that amount of changes be too
> disruptive (for example, in making svn history less useful)? Anyone
> have an opinion? Clean it up? Leave it alone? If I do it, I'll
> make an extra check-in with only those cleanup changes.
>
> Dave K
>
> On Thu, Feb 07, 2019 at 01:48:42PM +0100, POIRET via Docutils-users wrote:
> > 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
> >
> >
> >
> >
> >
> >
>
>
> > _______________________________________________
> > Docutils-users mailing list
> > [email protected]
> > https://lists.sourceforge.net/lists/listinfo/docutils-users
> >
> > Please use "Reply All" to reply to the list.
>
>
> --
>
> Dave Kuhlman
> http://www.davekuhlman.org
>
>
> _______________________________________________
> Docutils-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/docutils-users
>
> Please use "Reply All" to reply to the list.
--
Dave Kuhlman
http://www.davekuhlman.org