mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-24 14:25:00 +00:00
style: Apply linter formatting to testsr.py
This commit is contained in:
parent
55bca8d9e9
commit
3272a2b84e
1 changed files with 10 additions and 7 deletions
13
testsr.py
13
testsr.py
|
@ -1,24 +1,26 @@
|
||||||
import sys
|
|
||||||
import re
|
import re
|
||||||
|
import sys
|
||||||
|
|
||||||
|
|
||||||
def wordcount(text):
|
def wordcount(text):
|
||||||
"""Count the number of words in the given text."""
|
"""Count the number of words in the given text."""
|
||||||
return len(text.split())
|
return len(text.split())
|
||||||
|
|
||||||
|
|
||||||
def process_markdown(filename):
|
def process_markdown(filename):
|
||||||
try:
|
try:
|
||||||
with open(filename, 'r') as file:
|
with open(filename, "r") as file:
|
||||||
content = file.read()
|
content = file.read()
|
||||||
|
|
||||||
# Split the content into sections based on '####' headers
|
# Split the content into sections based on '####' headers
|
||||||
sections = re.split(r'(?=####\s)', content)
|
sections = re.split(r"(?=####\s)", content)
|
||||||
|
|
||||||
for section in sections:
|
for section in sections:
|
||||||
if section.strip(): # Ignore empty sections
|
if section.strip(): # Ignore empty sections
|
||||||
# Extract the header (if present)
|
# Extract the header (if present)
|
||||||
header = section.split('\n')[0].strip()
|
header = section.split("\n")[0].strip()
|
||||||
# Get the content (everything after the header)
|
# Get the content (everything after the header)
|
||||||
content = '\n'.join(section.split('\n')[1:]).strip()
|
content = "\n".join(section.split("\n")[1:]).strip()
|
||||||
|
|
||||||
# Count words
|
# Count words
|
||||||
count = wordcount(content)
|
count = wordcount(content)
|
||||||
|
@ -30,6 +32,7 @@ def process_markdown(filename):
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"An error occurred: {e}")
|
print(f"An error occurred: {e}")
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
if len(sys.argv) != 2:
|
if len(sys.argv) != 2:
|
||||||
print("Usage: python testsr.py <markdown_filename>")
|
print("Usage: python testsr.py <markdown_filename>")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue