SF.net SVN: docutils:[9540] trunk/docutils/docutils/frontend.py

milde--- via Docutils-checkins <[email protected]>
Newsgroups gmane.text.docutils.cvs
Message-ID <[email protected]>
Revision: 9540
          http://sourceforge.net/p/docutils/code/9540
Author:   milde
Date:     2024-02-17 10:36:59 +0000 (Sat, 17 Feb 2024)
Log Message:
-----------
Use "pathlib" and add deprecation warnings in frontend.py

Modified Paths:
--------------
    trunk/docutils/docutils/frontend.py

Modified: trunk/docutils/docutils/frontend.py
===================================================================
--- trunk/docutils/docutils/frontend.py	2024-02-17 10:36:51 UTC (rev 9539)
+++ trunk/docutils/docutils/frontend.py	2024-02-17 10:36:59 UTC (rev 9540)
@@ -59,6 +59,7 @@
 from optparse import SUPPRESS_HELP
 import os
 import os.path
+from pathlib import Path
 import sys
 import warnings
 
@@ -384,19 +385,23 @@
     `OptionParser.relative_path_settings`.
     """
     if base_path is None:
-        base_path = os.getcwd()
+        base_path = Path.cwd()
+    else:
+        base_path = Path(base_path)
     for key in keys:
         if key in pathdict:
             value = pathdict[key]
             if isinstance(value, list):
-                value = [make_one_path_absolute(base_path, path)
-                         for path in value]
+                value = [str((base_path/path).resolve()) for path in value]
             elif value:
-                value = make_one_path_absolute(base_path, value)
+                value = str((base_path/value).resolve())
             pathdict[key] = value
 
 
 def make_one_path_absolute(base_path, path):
+    # deprecated, will be removed
+    warnings.warn('frontend.make_one_path_absolute() will be removed '
+                  'in Docutils 0.23.', DeprecationWarning, stacklevel=2)
     return os.path.abspath(os.path.join(base_path, path))
 
 
@@ -882,7 +887,10 @@
         return source, destination
 
     def set_defaults_from_dict(self, defaults):
-        # not used, deprecated, will be removed
+        # deprecated, will be removed
+        warnings.warn('OptionParser.set_defaults_from_dict() will be removed '
+                      'in Docutils 0.22 or with the switch to ArgumentParser.',
+                      DeprecationWarning, stacklevel=2)
         self.defaults.update(defaults)
 
     def get_default_values(self):
@@ -934,7 +942,7 @@
     old_warning = (
         'The "[option]" section is deprecated.\n'
         'Support for old-format configuration files will be removed in '
-        'Docutils 0.21 or later.  Please revise your configuration files.  '
+        'Docutils 2.0.  Please revise your configuration files.  '
         'See <https://docutils.sourceforge.io/docs/user/config.html>, '
         'section "Old-Format Configuration Files".')
 

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.