Skip to content

Commit

Permalink
Minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
MaxHerbs committed Nov 3, 2024
1 parent 4aa5b4c commit 4bd1248
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions image_validator/SearchMethods.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ def __init__(self, requested_searches: list, files_to_search: list):
req = "search_" + req
if req in supported_searches:
try:
self.detected_paths += getattr(self, req)(files_to_search)
paths_found = getattr(self, req)(files_to_search)
self.detected_paths += paths_found
msg = f"{req.split('_')[1]} search completed. Found {len(paths_found)} paths."
typer.echo(msg)
except TypeError as e:
typer.echo(f"{req} is not a valid search type. Skipping.")
typer.echo(e)
Expand All @@ -35,21 +38,19 @@ def search_regex(self, file_paths) -> list:
return detected_paths

def search_frontmatter(self, file_paths) -> list:
typer.echo("Searching for images paths in frontmatter")
typer.echo("Searching for images paths using frontmatter")
detected_paths = []
for file in file_paths:
with open(file, "r") as f:
print("File: " + file)
frontMatter = ""
f.readline()
while True:
thisLine = f.readline().strip()
print(thisLine)
if thisLine == "---":
break
frontMatter += thisLine + "\n"
serialisedFrontmatter = yaml.safe_load(frontMatter)

if "background" in serialisedFrontmatter:
detected_paths.append(serialisedFrontmatter["background"])

Expand Down

0 comments on commit 4bd1248

Please sign in to comment.