working on my README update script

This commit is contained in:
TristanAncelet 2021-09-04 16:13:56 -05:00
parent 957fae078e
commit c35eeadd88
2 changed files with 37 additions and 3 deletions

View File

@ -1,3 +0,0 @@
import os
items_in_dir = os.listdir()

37
update.py Normal file
View File

@ -0,0 +1,37 @@
import os
import re
article_finder = re.compile(r'- \[\S+\]\((\S+)\)')
def articles_in_readme(readme_path):
with open(readme_path, 'r', encoding="UTF-8") as file:
contents = article_finder.findall(file.read())
file.close()
return contents
def is_markdown_file(filename):
matcher = re.compile(f'\S+\.md')
return True if matcher.match(filename) else False
def make_readme_article_name(filename):
word_finder = re.compile(r"_?([A-Z][a-z]+")
def articles_in_directory(directory):
files = list()
for file in os.listdir(directory):
if is_markdown_file(file) and file := "README.md":
files.append(file)
def update_readme_contents(directory):
def readme_matches_directory_contents(directory):
if articles_in_readme(os.path.join(directory, 'README.md')) == os.listdir()
for directory in os.listdir():
if os.path.isdir(directory):
readme