Skip to content

Commit

Permalink
re-format with black
Browse files Browse the repository at this point in the history
  • Loading branch information
diondrapeck committed Nov 2, 2023
1 parent a340f76 commit 497f465
Showing 1 changed file with 25 additions and 6 deletions.
31 changes: 25 additions & 6 deletions infra/bootstrapping/check-readme.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,41 @@


argParser = argparse.ArgumentParser()
argParser.add_argument("sample_path", help="The absolute path to the sample directory.", type=Path)
argParser.add_argument(
"sample_path", help="The absolute path to the sample directory.", type=Path
)
args = argParser.parse_args()
sample_path = str(args.sample_path).strip()
working_directory = Path(__file__).parent.parent


def main():
INVALID_README_MSG = f"{sample_path} does not contain a README.md file with all required words. See the Discoverability section of CONTRIBUTING.md."
EXCLUSIONS_FILE_PATH = f"{working_directory}/bootstrapping/readme_validation_exclusions.txt"
required_sections = ["overview", "objective", "programming languages", "estimated runtime", "page_type: sample", "languages:", "products:", "description:"]
EXCLUSIONS_FILE_PATH = (
f"{working_directory}/bootstrapping/readme_validation_exclusions.txt"
)
required_sections = [
"overview",
"objective",
"programming languages",
"estimated runtime",
"page_type: sample",
"languages:",
"products:",
"description:",
]

print(f"Checking if {sample_path} contains a README.md file with all required words...")
print(
f"Checking if {sample_path} contains a README.md file with all required words..."
)

# Check if sample is excluded from README validation
with open(EXCLUSIONS_FILE_PATH, encoding="utf-8") as exclusions_file:
exclusions = exclusions_file.read().splitlines()
if sample_path in exclusions:
print(f"Skipping {sample_path} since it is excluded from README validation.")
print(
f"Skipping {sample_path} since it is excluded from README validation."
)
sys.exit(0)

# Check if sample contains a valid README.md file
Expand All @@ -32,7 +49,9 @@ def main():
readme_content = readme_file.read()

if all(section in readme_content for section in required_sections):
print(f"{sample_path} contains a README.md file with all required sections.")
print(
f"{sample_path} contains a README.md file with all required sections."
)
sys.exit(0)
except FileNotFoundError:
pass
Expand Down

0 comments on commit 497f465

Please sign in to comment.