Skip to content

Commit

Permalink
Lint
Browse files Browse the repository at this point in the history
  • Loading branch information
elvis kahoro committed Aug 17, 2022
1 parent a2bceb5 commit 45294b5
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions scripts/gen_theme_previews.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,26 @@

import yaml


def get_all_input_files(input_dir: str) -> List[str]:
filenames = next(os.walk(input_dir), (None, None, []))[2]
files = filter(lambda f: (f.endswith("yaml") or f.endswith("yml")), filenames)
return list(files)


def ensure_output_dir(output_dir: str):
if not os.path.exists(output_dir):
os.makedirs(output_dir)


def add_color_to_dict(
output: Dict[str, str], obj: Dict[str, str], key: str, prefix: Optional[str] = None
):
if not prefix:
prefix = ""
output[f"{prefix}{key}"] = obj[key]


def get_color_dict(input_dir: str, file_name: str) -> Dict[str, str]:
file = open(os.path.join(input_dir, file_name), "r")
loaded_theme = yaml.safe_load(file)
Expand All @@ -42,6 +46,7 @@ def get_color_dict(input_dir: str, file_name: str) -> Dict[str, str]:

return output


def file_name_to_display(file_name: str) -> str:
file_name = Path(file_name).with_suffix("").name

Expand All @@ -51,6 +56,7 @@ def file_name_to_display(file_name: str) -> str:
output.append(s.capitalize())
return " ".join(output)


def gen_svg_for_theme(color_dict: Dict[str, str], svg_template: str) -> str:
output = svg_template

Expand All @@ -59,6 +65,7 @@ def gen_svg_for_theme(color_dict: Dict[str, str], svg_template: str) -> str:
output = output.replace(f"{{{key}}}", value)
return output


def main():
parser = argparse.ArgumentParser(
description="Generate README.md with embedded SVG previews."
Expand Down Expand Up @@ -117,5 +124,6 @@ def main():
with open(os.path.join(output_dir, "README.md"), "w") as output:
output.write(output_str)


if __name__ == "__main__":
main()

0 comments on commit 45294b5

Please sign in to comment.