Author: dsahlberg
Date: Sat Mar 1 22:45:20 2025
New Revision: 1924121
URL: http://svn.apache.org/viewvc?rev=1924121&view=rev
Log:
Prepare backport/status parser for adding new entries with code.
* tools/dist/backport/status.py
(StatusFile.__doc__): Clarify that TEXT is not used for Kind.nomination
(StatusFile.insert): New function to insert a nomination in the file
(StatusEntry): Handle if para_text is None, for example when creating an
entry with code and filling the attributes afterwards.
Modified:
subversion/trunk/tools/dist/backport/status.py
Modified: subversion/trunk/tools/dist/backport/status.py
URL: http://svn.apache.org/viewvc/subversion/trunk/tools/dist/backport/status.py?rev=1924121&r1=1924120&r2=1924121&view=diff
==============================================================================
--- subversion/trunk/tools/dist/backport/status.py (original)
+++ subversion/trunk/tools/dist/backport/status.py Sat Mar 1 22:45:20 2025
@@ -88,7 +88,8 @@ class Paragraph:
KIND is one of the Kind.* enumerators.
- TEXT is the physical text in the file, used by unparsing.
+ TEXT is the physical text in the file, used by unparsing unless kind is
+ Kind.nomination.
ENTRY is the StatusEntry object, if Kind.nomination, else None.
@@ -235,6 +236,30 @@ class StatusFile:
for para in entry_paras:
para.kind = Kind.unknown
+ def insert(self, entry, containing_section):
+ p = Paragraph(Kind.nomination,
+ "",
+ entry,
+ containing_section)
+
+ # Find an existing section header to insert the new entry
+ i = 0
+ while i < len(self.paragraphs):
+ if self.paragraphs[i].kind is Kind.section_header \
+ and self.paragraphs[i]._containing_section == containing_section:
+ self.paragraphs.insert(i+1, p)
+ return
+ i += 1
+
+ # None found so we need to append a new header followed by the new entry
+ self.paragraphs.append(Paragraph(Kind.section_header,
+ containing_section + ":\n" \
+ + '=' * (len(containing_section)+1) + "\n",
+ None,
+ containing_section)
+ )
+ self.paragraphs.append(p)
+
def remove(self, entry):
"Remove ENTRY from SELF."
for para in self.entries_paras():
@@ -361,9 +386,13 @@ class StatusEntry:
self.notes_str = None
self.votes_str = None
self.status_file = status_file
+ self.indentation = 0
self.raw = para_text
+ if para_text is None:
+ return
+
_re_entry_indentation = re.compile(r'^( *\* )')
_re_revisions_line = re.compile(r'^(?:r?\d+[,; ]*)+$')
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.