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

milde--- via Docutils-checkins <[email protected]>
Newsgroups gmane.text.docutils.cvs
Message-ID <[email protected]>
Revision: 9905
          http://sourceforge.net/p/docutils/code/9905
Author:   milde
Date:     2024-08-15 07:31:04 +0000 (Thu, 15 Aug 2024)
Log Message:
-----------
Small code updates to "modern" syntax constructs.

Modified Paths:
--------------
    trunk/docutils/docutils/nodes.py
    trunk/docutils/docutils/parsers/rst/directives/body.py
    trunk/docutils/docutils/utils/code_analyzer.py
    trunk/docutils/docutils/writers/_html_base.py
    trunk/docutils/docutils/writers/latex2e/__init__.py

Modified: trunk/docutils/docutils/nodes.py
===================================================================
--- trunk/docutils/docutils/nodes.py	2024-08-15 07:30:48 UTC (rev 9904)
+++ trunk/docutils/docutils/nodes.py	2024-08-15 07:31:04 UTC (rev 9905)
@@ -818,7 +818,7 @@
         """
         for cls in self.get('classes', []):
             if cls.startswith('language-'):
-                return cls[9:]
+                return cls.removeprefix('language-')
         try:
             return self.parent.get_language(fallback)
         except AttributeError:

Modified: trunk/docutils/docutils/parsers/rst/directives/body.py
===================================================================
--- trunk/docutils/docutils/parsers/rst/directives/body.py	2024-08-15 07:30:48 UTC (rev 9904)
+++ trunk/docutils/docutils/parsers/rst/directives/body.py	2024-08-15 07:31:04 UTC (rev 9905)
@@ -71,8 +71,8 @@
 
     required_arguments = 0
     optional_arguments = 1
-    option_spec = BasePseudoSection.option_spec.copy()
-    option_spec['subtitle'] = directives.unchanged_required
+    option_spec = BasePseudoSection.option_spec | {
+                      'subtitle': directives.unchanged_required}
 
     def run(self):
         if isinstance(self.state_machine.node, nodes.sidebar):

Modified: trunk/docutils/docutils/utils/code_analyzer.py
===================================================================
--- trunk/docutils/docutils/utils/code_analyzer.py	2024-08-15 07:30:48 UTC (rev 9904)
+++ trunk/docutils/docutils/utils/code_analyzer.py	2024-08-15 07:31:04 UTC (rev 9905)
@@ -122,7 +122,7 @@
         self.tokens = tokens
         self.startline = startline
         # pad linenumbers, e.g. endline == 100 -> fmt_str = '%3d '
-        self.fmt_str = '%%%dd ' % len(str(endline))
+        self.fmt_str = f'%{len(str(endline))}d '
 
     def __iter__(self):
         lineno = self.startline

Modified: trunk/docutils/docutils/writers/_html_base.py
===================================================================
--- trunk/docutils/docutils/writers/_html_base.py	2024-08-15 07:30:48 UTC (rev 9904)
+++ trunk/docutils/docutils/writers/_html_base.py	2024-08-15 07:31:04 UTC (rev 9905)
@@ -531,7 +531,7 @@
         # unify class arguments and move language specification
         for cls in node.get('classes', []) + atts.pop('class', '').split():
             if cls.startswith('language-'):
-                languages.append(cls[9:])
+                languages.append(cls.removeprefix('language-'))
             elif cls.strip() and cls not in classes:
                 classes.append(cls)
         if languages:
@@ -1022,7 +1022,7 @@
             if cls.startswith('field-indent-'):
                 try:
                     indent_length = length_or_percentage_or_unitless(
-                                                        cls[13:], 'px')
+                        cls.removeprefix('field-indent-'), 'px')
                 except ValueError:
                     break
                 atts['style'] = '--field-indent: %s;' % indent_length

Modified: trunk/docutils/docutils/writers/latex2e/__init__.py
===================================================================
--- trunk/docutils/docutils/writers/latex2e/__init__.py	2024-08-15 07:30:48 UTC (rev 9904)
+++ trunk/docutils/docutils/writers/latex2e/__init__.py	2024-08-15 07:31:04 UTC (rev 9905)
@@ -1595,7 +1595,7 @@
         # separate:
         align = [cls for cls in node['classes'] if cls.startswith('align-')]
         if align:
-            node['align'] = align[-1].replace('align-', '')
+            node['align'] = align[-1].removeprefix('align-')
             node['classes'] = [cls for cls in node['classes']
                                if not cls.startswith('align-')]
 

This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
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.