Re: Is rst2odt -l cs supposed to work?

Dave Kuhlman <[email protected]>
Newsgroups gmane.text.docutils.user
Message-ID <[email protected]>
Günter,

Here is an update -- I did the following:

1. Merged your change for Jython import of locale module.

2. Added notes to HISTORY.txt.

3. Committed changes to the central repository.

Dave K


On Sun, May 21, 2017 at 10:22:39AM +0000, Guenter Milde wrote:
> Dear Dave,
> 
> On 2017-05-19, Dave Kuhlman wrote:
> 
> > I did the following:
> 
> > 1. Merged your changes (patch file below) into my local repository.
> 
> > 2. Did a bit of testing.  I had an exception when a document
> >    contained an admonition.  I fixed that.
> 
> > 3. Committed these changes to the central repository.
> 
> > Thank you for your help with this.  
> 
> > Let me know if/when there is something more I can do.
> 
> I have one more patch that makes the code failsafe for Python
> implementations missing the locale module (e.g. Jython).
> 
> If you could add a short summary of changed to the HISTORY.txt file,
> we should be ready for release.
> 
> Thanks,
> 
> Günter
> 
> 
> 
> Index: __init__.py
> ===================================================================
> --- __init__.py	(Revision 8070)
> +++ __init__.py	(Arbeitskopie)
> @@ -24,7 +24,10 @@
>  import copy
>  import urllib2
>  import docutils
> -import locale
> +try:
> +    import locale # module missing in Jython
> +except ImportError:
> +    pass
>  from docutils import frontend, nodes, utils, writers, languages
>  from docutils.readers import standalone
>  from docutils.transforms import references
> @@ -589,7 +592,10 @@
>                  elif len(subtag) == 1:
>                      break   # 1-letter tag is never before valid region tag
>              if region_code is None:
> -                rcode = locale.normalize(language_code)
> +                try:
> +                    rcode = locale.normalize(language_code)
> +                except NameError:
> +                    rcode = language_code
>                  rcode = rcode.split('_')
>                  if len(rcode) > 1:
>                      rcode = rcode[1].split('.')
> @@ -596,11 +602,10 @@
>                      region_code = rcode[0]
>                  if region_code is None:
>                      self.document.reporter.warning(
> -                        'invalid language-region.  '
> -                        'Could not find region with locale.normalize().  '
> -                        'If language is supplied, then you must specify '
> -                        'both language and region (ll-RR).  Examples: '
> -                        'es-MX (Spanish, Mexico), en-AU (English, Australia).')
> +                        'invalid language-region.\n'
> +                        '  Could not find region with locale.normalize().\n'
> +                        '  Please specify both language and region (ll-RR).\n'
> +                        '  Examples: es-MX (Spanish, Mexico), en-AU (English, Australia).')
>          # Update the style ElementTree with the language and region.
>          # Note that we keep a reference to the modified node because
>          # it is possible that ElementTree will throw away the Python
> 
> 
> ------------------------------------------------------------------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> _______________________________________________
> 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

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
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.