MCPcopy Create free account
hub / github.com/apache/solr / process

Method process

dev-tools/scripts/changes2logchange.py:1014–1083  ·  view source on GitHub ↗

Read from stdin, parse individual changelog entries, and output YAML. Ignores headers and nested structure. Outputs YAML entries separated by '----' YAML separator.

()

Source from the content-addressed store, hash-verified

1012
1013 @staticmethod
1014 def process():
1015 """
1016 Read from stdin, parse individual changelog entries, and output YAML.
1017
1018 Ignores headers and nested structure.
1019 Outputs YAML entries separated by '----' YAML separator.
1020 """
1021 import sys
1022
1023 # Read all lines from stdin
1024 lines = sys.stdin.readlines()
1025
1026 entries_yaml = []
1027 i = 0
1028
1029 while i < len(lines):
1030 line = lines[i]
1031
1032 # Skip empty lines and header lines (lines with only dashes or equals)
1033 if not line.strip() or re.match(r'^[-=\s]+$', line):
1034 i += 1
1035 continue
1036
1037 # Check if this line starts a changelog entry (bullet point)
1038 if line.strip().startswith('*') or line.strip().startswith('-'):
1039 # Collect the full entry (may span multiple lines)
1040 entry_text = line.strip()[1:].strip() # Remove bullet and leading spaces
1041
1042 # Continue reading continuation lines
1043 i += 1
1044 while i < len(lines):
1045 next_line = lines[i]
1046 # If the next line is another entry or empty, stop collecting
1047 if (next_line.strip().startswith('*') or
1048 next_line.strip().startswith('-') or
1049 re.match(r'^[-=\s]+$', next_line) or
1050 not next_line.strip()):
1051 break
1052 # Add to entry text
1053 entry_text += ' ' + next_line.strip()
1054 i += 1
1055
1056 # Parse the entry to a ChangeEntry
1057 entry = EntryParser.parse_entry_line(entry_text)
1058 if entry:
1059 # Serialize to YAML
1060 yaml_dict = {
1061 'title': entry.title,
1062 'type': entry.change_type,
1063 }
1064 if entry.authors:
1065 yaml_dict['authors'] = [{'name': a.name} for a in entry.authors]
1066 if entry.links:
1067 yaml_dict['links'] = [
1068 {'name': link.name, 'url': link.url}
1069 for link in entry.links
1070 ]
1071

Callers

nothing calls this directly

Calls 5

stripMethod · 0.80
parse_entry_lineMethod · 0.80
dumpMethod · 0.80
appendMethod · 0.65
matchMethod · 0.45

Tested by

no test coverage detected