SF.net SVN: docutils:[9768 ] trunk/docutils

milde--- via Docutils-checkins <[email protected]>
Newsgroups gmane.text.docutils.cvs
Message-ID <[email protected]>
Revision: 9768
          http://sourceforge.net/p/docutils/code/9768
Author:   milde
Date:     2024-06-15 12:08:27 +0000 (Sat, 15 Jun 2024)
Log Message:
-----------
Deprecate `io.BinaryFileOutput` and `core.publish_cmdline_to_binary()`.

Announce removal in Docutils 0.24 (2 releases after 0.22, which may also be
1.0 or 2.0).

Use `io.FileOutput` and `core.publish_cmdline()` instead
(works with `bytes` since Docutils 0.20).

Modified Paths:
--------------
    trunk/docutils/HISTORY.txt
    trunk/docutils/RELEASE-NOTES.txt
    trunk/docutils/docutils/core.py
    trunk/docutils/docutils/io.py
    trunk/docutils/tools/rst2odt.py

Modified: trunk/docutils/HISTORY.txt
===================================================================
--- trunk/docutils/HISTORY.txt	2024-06-14 16:20:08 UTC (rev 9767)
+++ trunk/docutils/HISTORY.txt	2024-06-15 12:08:27 UTC (rev 9768)
@@ -139,6 +139,10 @@
 
 * tools/rst2odt_prepstyles.py
 
+  - Use `core.publish_file()` instead of `core.publish_file_to_binary()`.
+
+* tools/rst2odt_prepstyles.py
+
   - Removed. Use `docutils.writers.odf_odt.prepstyles`.
 
 

Modified: trunk/docutils/RELEASE-NOTES.txt
===================================================================
--- trunk/docutils/RELEASE-NOTES.txt	2024-06-14 16:20:08 UTC (rev 9767)
+++ trunk/docutils/RELEASE-NOTES.txt	2024-06-15 12:08:27 UTC (rev 9768)
@@ -121,6 +121,9 @@
 Misc
 ----
 
+* Remove `io.BinaryFileOutput` and `core.publish_cmdline_to_binary()`
+  in Docutils 0.24.
+
 * Remove `parsers.rst.directives.CSVTable.HeaderDialect`
   in Docutils 1.0.
 

Modified: trunk/docutils/docutils/core.py
===================================================================
--- trunk/docutils/docutils/core.py	2024-06-14 16:20:08 UTC (rev 9767)
+++ trunk/docutils/docutils/core.py	2024-06-15 12:08:27 UTC (rev 9768)
@@ -595,7 +595,13 @@
       line.
     - `description`: Program description, output for the "--help" option
       (along with command-line option descriptions).
+
+    Deprecated. Use `publish_cmdline()` (works with `bytes` since
+    Docutils 0.20). Will be removed in Docutils 0.24.
     """
+    warnings.warn('"publish_cmdline_to_binary()" is obsoleted'
+                  ' by "publish_cmdline()" and will be removed'
+                  ' in Docutils 0.24.', DeprecationWarning, stacklevel=2)
     publisher = Publisher(reader, parser, writer, settings=settings,
                           destination_class=destination_class)
     publisher.set_components(reader_name, parser_name, writer_name)

Modified: trunk/docutils/docutils/io.py
===================================================================
--- trunk/docutils/docutils/io.py	2024-06-14 16:20:08 UTC (rev 9767)
+++ trunk/docutils/docutils/io.py	2024-06-15 12:08:27 UTC (rev 9768)
@@ -554,12 +554,20 @@
 class BinaryFileOutput(FileOutput):
     """
     A version of docutils.io.FileOutput which writes to a binary file.
+
+    Deprecated. Use `FileOutput` (works with `bytes` since Docutils 0.20).
+    Will be removed in Docutils 0.24.
     """
-    # Used by core.publish_cmdline_to_binary() which in turn is used by
-    # tools/rst2odt.py but not by core.rst2odt().
+    # Used by core.publish_cmdline_to_binary() which is also deprecated.
     mode = 'wb'
 
+    def __init__(self, *args, **kwargs):
+        warnings.warn('"BinaryFileOutput" is obsoleted by "FileOutput"'
+                      ' and will be removed in Docutils 0.24.',
+                      DeprecationWarning, stacklevel=2)
+        super().__init__(*args, **kwargs)
 
+
 class StringInput(Input):
     """Input from a `str` or `bytes` instance."""
 

Modified: trunk/docutils/tools/rst2odt.py
===================================================================
--- trunk/docutils/tools/rst2odt.py	2024-06-14 16:20:08 UTC (rev 9767)
+++ trunk/docutils/tools/rst2odt.py	2024-06-15 12:08:27 UTC (rev 9768)
@@ -14,7 +14,7 @@
 except Exception:
     pass
 
-from docutils.core import publish_cmdline_to_binary, default_description
+from docutils.core import publish_cmdline, default_description
 from docutils.writers.odf_odt import Writer, Reader
 
 
@@ -24,5 +24,4 @@
 
 writer = Writer()
 reader = Reader()
-output = publish_cmdline_to_binary(reader=reader, writer=writer,
-                                   description=description)
+output = publish_cmdline(reader=reader, writer=writer, description=description)

This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.



_______________________________________________
Docutils-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/docutils-checkins
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.