Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
move local aliases -> SECTION_ALIASES
  • Loading branch information
gpshead committed Jul 13, 2025
commit 5b8a36bf22f65cb1ed84a3db31d4883adef63d40
27 changes: 12 additions & 15 deletions src/blurb/blurb.py
Comment thread
gpshead marked this conversation as resolved.
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,17 @@


LOWEST_POSSIBLE_GH_ISSUE_NUMBER = 32426
SECTION_ALIASES = {
'api': 'C API',
'capi': 'C API',
'builtin': 'Core and Builtins',
'builtins': 'Core and Builtins',
'core': 'Core and Builtins',
'demo': 'Tools/Demos',
'demos': 'Tools/Demos',
'tool': 'Tools/Demos',
'tools': 'Tools/Demos',
}

#
# This template is the canonical list of acceptable section names!
Expand Down Expand Up @@ -797,15 +808,15 @@
try:
blurb.load(tmp_path)
if len(blurb) > 1:
raise BlurbError("Too many entries! Don't specify '..' on a line by itself.")
return blurb

Check warning on line 812 in src/blurb/blurb.py

View check run for this annotation

Codecov / codecov/patch

src/blurb/blurb.py#L811-L812

Added lines #L811 - L812 were not covered by tests
except BlurbError as e:
print(f"\nError: {e}\n")
try:
prompt("Hit return to retry (or Ctrl-C to abort)")
except KeyboardInterrupt:
print()
return None

Check warning on line 819 in src/blurb/blurb.py

View check run for this annotation

Codecov / codecov/patch

src/blurb/blurb.py#L819

Added line #L819 was not covered by tests
print()


Expand All @@ -829,7 +840,7 @@
def _extract_section_name(section):
"""Extract section name with smart matching."""
if section is None:
return None

Check warning on line 843 in src/blurb/blurb.py

View check run for this annotation

Codecov / codecov/patch

src/blurb/blurb.py#L843

Added line #L843 was not covered by tests

section = raw_section = section.strip()
if not section:
Expand Down Expand Up @@ -877,21 +888,7 @@

# Special cases and aliases
normalized = ''.join(section_words).lower()

# Check special aliases
aliases = {
'api': 'C API',
'capi': 'C API',
'builtin': 'Core and Builtins',
'builtins': 'Core and Builtins',
'core': 'Core and Builtins',
'demo': 'Tools/Demos',
'demos': 'Tools/Demos',
'tool': 'Tools/Demos',
'tools': 'Tools/Demos',
}

for alias, section_name in aliases.items():
for alias, section_name in SECTION_ALIASES.items():
if normalized.startswith(alias):
if section_name not in matches:
matches.append(section_name)
Expand All @@ -901,7 +898,7 @@
for section_name in SECTIONS:
section_normalized = re.sub(r'[^a-zA-Z0-9]', '', section_name).lower()
if section_normalized.startswith(normalized):
matches.append(section_name)

Check warning on line 901 in src/blurb/blurb.py

View check run for this annotation

Codecov / codecov/patch

src/blurb/blurb.py#L901

Added line #L901 was not covered by tests

return matches

Expand Down Expand Up @@ -933,7 +930,7 @@
# Extract and validate issue number
issue_number = _extract_issue_number(issue) if issue else None
if issue_number and int(issue_number) < LOWEST_POSSIBLE_GH_ISSUE_NUMBER:
error(f"Invalid issue number: {issue_number} (must be >= {LOWEST_POSSIBLE_GH_ISSUE_NUMBER})")

Check warning on line 933 in src/blurb/blurb.py

View check run for this annotation

Codecov / codecov/patch

src/blurb/blurb.py#L933

Added line #L933 was not covered by tests

# Extract and validate section
section_name = _extract_section_name(section) if section else None
Expand All @@ -948,7 +945,7 @@
if rst_on_stdin:
rst_content = sys.stdin.read().strip()
if not rst_content:
error("No content provided on stdin")

Check warning on line 948 in src/blurb/blurb.py

View check run for this annotation

Codecov / codecov/patch

src/blurb/blurb.py#L948

Added line #L948 was not covered by tests
editor = None
else:
rst_content = None
Expand All @@ -965,14 +962,14 @@
# Get blurb content
if editor:
blurb = edit_until_valid(editor, tmp_path)
if not blurb:
return 1

Check warning on line 966 in src/blurb/blurb.py

View check run for this annotation

Codecov / codecov/patch

src/blurb/blurb.py#L965-L966

Added lines #L965 - L966 were not covered by tests
else:
blurb = Blurbs()
try:
blurb.load(tmp_path)
except BlurbError as e:
error(str(e))

Check warning on line 972 in src/blurb/blurb.py

View check run for this annotation

Codecov / codecov/patch

src/blurb/blurb.py#L971-L972

Added lines #L971 - L972 were not covered by tests

# Save and commit
path = blurb.save_next()
Expand Down