mirror of
https://github.com/ethauvin/warp-themes.git
synced 2025-04-25 09:07:11 -07:00
Lint
This commit is contained in:
parent
a2bceb56f3
commit
45294b57d3
1 changed files with 8 additions and 0 deletions
|
@ -8,15 +8,18 @@ from typing import Tuple
|
||||||
|
|
||||||
import yaml
|
import yaml
|
||||||
|
|
||||||
|
|
||||||
def get_all_input_files(input_dir: str) -> List[str]:
|
def get_all_input_files(input_dir: str) -> List[str]:
|
||||||
filenames = next(os.walk(input_dir), (None, None, []))[2]
|
filenames = next(os.walk(input_dir), (None, None, []))[2]
|
||||||
files = filter(lambda f: (f.endswith("yaml") or f.endswith("yml")), filenames)
|
files = filter(lambda f: (f.endswith("yaml") or f.endswith("yml")), filenames)
|
||||||
return list(files)
|
return list(files)
|
||||||
|
|
||||||
|
|
||||||
def ensure_output_dir(output_dir: str):
|
def ensure_output_dir(output_dir: str):
|
||||||
if not os.path.exists(output_dir):
|
if not os.path.exists(output_dir):
|
||||||
os.makedirs(output_dir)
|
os.makedirs(output_dir)
|
||||||
|
|
||||||
|
|
||||||
def add_color_to_dict(
|
def add_color_to_dict(
|
||||||
output: Dict[str, str], obj: Dict[str, str], key: str, prefix: Optional[str] = None
|
output: Dict[str, str], obj: Dict[str, str], key: str, prefix: Optional[str] = None
|
||||||
):
|
):
|
||||||
|
@ -24,6 +27,7 @@ def add_color_to_dict(
|
||||||
prefix = ""
|
prefix = ""
|
||||||
output[f"{prefix}{key}"] = obj[key]
|
output[f"{prefix}{key}"] = obj[key]
|
||||||
|
|
||||||
|
|
||||||
def get_color_dict(input_dir: str, file_name: str) -> Dict[str, str]:
|
def get_color_dict(input_dir: str, file_name: str) -> Dict[str, str]:
|
||||||
file = open(os.path.join(input_dir, file_name), "r")
|
file = open(os.path.join(input_dir, file_name), "r")
|
||||||
loaded_theme = yaml.safe_load(file)
|
loaded_theme = yaml.safe_load(file)
|
||||||
|
@ -42,6 +46,7 @@ def get_color_dict(input_dir: str, file_name: str) -> Dict[str, str]:
|
||||||
|
|
||||||
return output
|
return output
|
||||||
|
|
||||||
|
|
||||||
def file_name_to_display(file_name: str) -> str:
|
def file_name_to_display(file_name: str) -> str:
|
||||||
file_name = Path(file_name).with_suffix("").name
|
file_name = Path(file_name).with_suffix("").name
|
||||||
|
|
||||||
|
@ -51,6 +56,7 @@ def file_name_to_display(file_name: str) -> str:
|
||||||
output.append(s.capitalize())
|
output.append(s.capitalize())
|
||||||
return " ".join(output)
|
return " ".join(output)
|
||||||
|
|
||||||
|
|
||||||
def gen_svg_for_theme(color_dict: Dict[str, str], svg_template: str) -> str:
|
def gen_svg_for_theme(color_dict: Dict[str, str], svg_template: str) -> str:
|
||||||
output = svg_template
|
output = svg_template
|
||||||
|
|
||||||
|
@ -59,6 +65,7 @@ def gen_svg_for_theme(color_dict: Dict[str, str], svg_template: str) -> str:
|
||||||
output = output.replace(f"{{{key}}}", value)
|
output = output.replace(f"{{{key}}}", value)
|
||||||
return output
|
return output
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
parser = argparse.ArgumentParser(
|
parser = argparse.ArgumentParser(
|
||||||
description="Generate README.md with embedded SVG previews."
|
description="Generate README.md with embedded SVG previews."
|
||||||
|
@ -117,5 +124,6 @@ def main():
|
||||||
with open(os.path.join(output_dir, "README.md"), "w") as output:
|
with open(os.path.join(output_dir, "README.md"), "w") as output:
|
||||||
output.write(output_str)
|
output.write(output_str)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue