Skip to content

Commit

Permalink
reduce duplication
Browse files Browse the repository at this point in the history
  • Loading branch information
TimidRobot committed Aug 9, 2024
1 parent b065cbd commit a08a957
Showing 1 changed file with 9 additions and 15 deletions.
24 changes: 9 additions & 15 deletions scripts/shared.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,16 +162,17 @@ def update_readme(
if specific_section_end in lines[i]:
specific_end = i

# Prepare the new content for this specific section
new_content = [
f"{specific_section_start}\n",
f"### {section_title}\n",
f"![{description}]({rel_image_path})\n",
f"{description}\n",
f"{specific_section_end}\n",
]

# If the specific section is found, replace the content
if specific_start is not None and specific_end is not None:
# Prepare the new content for this specific section
new_content = [
f"{specific_section_start}\n",
f"### {section_title}\n",
f"![{description}]({rel_image_path})\n",
f"{description}\n",
f"{specific_section_end}\n",
]
# Replace the content between the specific markers
lines = (
lines[:specific_start]
Expand All @@ -180,13 +181,6 @@ def update_readme(
)
else:
# If specific section does not exist, add it before main end marker
new_content = [
f"{specific_section_start}\n",
f"### {section_title}\n",
f"![{description}]({rel_image_path})\n",
f"{description}\n",
f"{specific_section_end}\n",
]
lines = lines[:section_end] + new_content + lines[section_end:]

# Write back to the README.md file
Expand Down

0 comments on commit a08a957

Please sign in to comment.