bakefile 0.0.3__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,24 @@
1
+ Metadata-Version: 2.3
2
+ Name: bakefile
3
+ Version: 0.0.3
4
+ Summary: Add your description here
5
+ Author: Wisaroot Lertthaweedech
6
+ Author-email: Wisaroot Lertthaweedech <l.wisaroot@gmail.com>
7
+ Requires-Dist: pydantic>=2.12.5
8
+ Requires-Dist: typer>=0.0.1
9
+ Requires-Python: >=3.10
10
+ Description-Content-Type: text/markdown
11
+
12
+ [![tests](https://img.shields.io/github/actions/workflow/status/wislertt/bakefile/cd.yml?branch=main&label=tests&logo=github)](https://github.com/wislertt/bakefile/actions/workflows/cd.yml)
13
+ [![release](https://img.shields.io/github/actions/workflow/status/wislertt/bakefile/cd.yml?branch=main&label=release&logo=github)](https://github.com/wislertt/bakefile/actions/workflows/cd.yml)
14
+ [![quality-gate-status](https://sonarcloud.io/api/project_badges/measure?project=wislertt_bakefile&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=wislertt_bakefile)
15
+ [![security-rating](https://sonarcloud.io/api/project_badges/measure?project=wislertt_bakefile&metric=security_rating)](https://sonarcloud.io/summary/new_code?id=wislertt_bakefile)
16
+ [![vulnerabilities](https://sonarcloud.io/api/project_badges/measure?project=wislertt_bakefile&metric=vulnerabilities)](https://sonarcloud.io/summary/new_code?id=wislertt_bakefile)
17
+ [![codecov](https://codecov.io/gh/wislertt/bakefile/graph/badge.svg?token=G0ZRDBGAJB)](https://codecov.io/gh/wislertt/bakefile)
18
+ [![pypi](https://img.shields.io/pypi/v/bakefile.svg?color=blue)](https://pypi.python.org/pypi/bakefile)
19
+ [![downloads](https://static.pepy.tech/personalized-badge/bakefile?period=total&units=international_system&left_color=grey&right_color=blue&left_text=pypi%20downloads)](https://pepy.tech/projects/bakefile)
20
+ [![python](https://img.shields.io/badge/python-3.10%20%7C%203.11%20%7C%203.12%20%7C%203.13%20%7C%203.14-blue?logo=python)](https://github.com/wislertt/bakefile/)
21
+
22
+ # bakefile
23
+
24
+ 🚧 **Note:** This project is under active development. 🚧
@@ -0,0 +1,13 @@
1
+ [![tests](https://img.shields.io/github/actions/workflow/status/wislertt/bakefile/cd.yml?branch=main&label=tests&logo=github)](https://github.com/wislertt/bakefile/actions/workflows/cd.yml)
2
+ [![release](https://img.shields.io/github/actions/workflow/status/wislertt/bakefile/cd.yml?branch=main&label=release&logo=github)](https://github.com/wislertt/bakefile/actions/workflows/cd.yml)
3
+ [![quality-gate-status](https://sonarcloud.io/api/project_badges/measure?project=wislertt_bakefile&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=wislertt_bakefile)
4
+ [![security-rating](https://sonarcloud.io/api/project_badges/measure?project=wislertt_bakefile&metric=security_rating)](https://sonarcloud.io/summary/new_code?id=wislertt_bakefile)
5
+ [![vulnerabilities](https://sonarcloud.io/api/project_badges/measure?project=wislertt_bakefile&metric=vulnerabilities)](https://sonarcloud.io/summary/new_code?id=wislertt_bakefile)
6
+ [![codecov](https://codecov.io/gh/wislertt/bakefile/graph/badge.svg?token=G0ZRDBGAJB)](https://codecov.io/gh/wislertt/bakefile)
7
+ [![pypi](https://img.shields.io/pypi/v/bakefile.svg?color=blue)](https://pypi.python.org/pypi/bakefile)
8
+ [![downloads](https://static.pepy.tech/personalized-badge/bakefile?period=total&units=international_system&left_color=grey&right_color=blue&left_text=pypi%20downloads)](https://pepy.tech/projects/bakefile)
9
+ [![python](https://img.shields.io/badge/python-3.10%20%7C%203.11%20%7C%203.12%20%7C%203.13%20%7C%203.14-blue?logo=python)](https://github.com/wislertt/bakefile/)
10
+
11
+ # bakefile
12
+
13
+ 🚧 **Note:** This project is under active development. 🚧
@@ -0,0 +1,51 @@
1
+ [project]
2
+ name = "bakefile"
3
+ version = "0.0.3"
4
+ description = "Add your description here"
5
+ readme = "README.md"
6
+ authors = [
7
+ {name = "Wisaroot Lertthaweedech", email = "l.wisaroot@gmail.com"}
8
+ ]
9
+ requires-python = ">=3.10"
10
+ dependencies = [
11
+ "pydantic>=2.12.5",
12
+ "typer>=0.0.1"
13
+ ]
14
+
15
+ [project.scripts]
16
+ bake = "bakefile.cli.bake:app"
17
+ bakefile = "bakefile.cli.bakefile:app"
18
+
19
+ [dependency-groups]
20
+ dev = [
21
+ "pre-commit>=4.5.1",
22
+ "pytest-cov>=7.0.0",
23
+ "pytest>=9.0.2",
24
+ "ruff>=0.14.10",
25
+ "toml-sort>=0.24.3",
26
+ "ty>=0.0.5"
27
+ ]
28
+
29
+ [build-system]
30
+ requires = ["uv_build>=0.9.18,<0.10.0"]
31
+ build-backend = "uv_build"
32
+
33
+ [tool.ruff]
34
+ line-length = 100
35
+
36
+ [tool.ruff.lint]
37
+ select = [
38
+ "ARG",
39
+ "B", # bugbear
40
+ "B9",
41
+ "C4", # flake8-comprehensions
42
+ "E", # pycodestyle (error)
43
+ "F", # pyflakes
44
+ "I", # isort
45
+ "PGH", # pygrep-hooks
46
+ "PIE", # flake8-pie
47
+ "PYI", # flake8-pyi
48
+ "RUF",
49
+ "SIM", # flake8-simplify
50
+ "UP" # pyupgrade
51
+ ]
File without changes
@@ -0,0 +1 @@
1
+ __all__ = []
@@ -0,0 +1,3 @@
1
+ from bakefile.cli.bake.main import app
2
+
3
+ __all__ = ["app"]
@@ -0,0 +1,17 @@
1
+ import typer
2
+
3
+ from bakefile.cli.bake.resolve_bakebook import resolve_bakebook
4
+
5
+ app = typer.Typer()
6
+
7
+
8
+ @app.command()
9
+ def main(
10
+ chdir: str = typer.Option(None, "-C", "--chdir", help="Change directory before running"),
11
+ file_name: str = typer.Option("bakefile.py", "--file-name", "-f", help="Path to bakefile.py"),
12
+ bakebook_name: str = typer.Option(
13
+ "bakebook", "--book-name", "-b", help="Name of bakebook object to retrieve"
14
+ ),
15
+ ) -> None:
16
+ bakebook = resolve_bakebook(file_name=file_name, bakebook_name=bakebook_name, chdir=chdir)
17
+ typer.echo(bakebook)
@@ -0,0 +1,75 @@
1
+ import importlib.util
2
+ import os
3
+ import pathlib
4
+ import sys
5
+ import types
6
+
7
+ import typer
8
+
9
+
10
+ def change_directory(path: str) -> None:
11
+ if not path or not path.strip():
12
+ typer.echo("Directory path cannot be empty", err=True)
13
+ raise SystemExit(1)
14
+ dir_path = pathlib.Path(path)
15
+ if not dir_path.exists():
16
+ typer.echo(f"Directory not found: {path}", err=True)
17
+ raise SystemExit(1)
18
+ if not dir_path.is_dir():
19
+ typer.echo(f"Not a directory: {path}", err=True)
20
+ raise SystemExit(1)
21
+ os.chdir(dir_path)
22
+
23
+
24
+ def validate_file_name(file_name: str) -> None:
25
+ if "/" in file_name or "\\" in file_name:
26
+ typer.echo(f"File name must not contain path separators: {file_name}", err=True)
27
+ raise SystemExit(1)
28
+ if not file_name.endswith(".py"):
29
+ typer.echo(f"File name must end with .py: {file_name}", err=True)
30
+ raise SystemExit(1)
31
+
32
+
33
+ def resolve_file_path(file_name: str) -> pathlib.Path:
34
+ path = pathlib.Path.cwd() / file_name
35
+ if not path.exists():
36
+ typer.echo(f"File not found: {file_name}", err=True)
37
+ raise SystemExit(1)
38
+ return path
39
+
40
+
41
+ def load_module(path: pathlib.Path) -> types.ModuleType:
42
+ module_name = "bakefile"
43
+ spec = importlib.util.spec_from_file_location(module_name, path)
44
+ if spec is None or spec.loader is None:
45
+ typer.echo(f"Failed to load: {path}", err=True)
46
+ raise SystemExit(1)
47
+
48
+ module: types.ModuleType = importlib.util.module_from_spec(spec)
49
+ sys.modules[module_name] = module
50
+ spec.loader.exec_module(module)
51
+ return module
52
+
53
+
54
+ def get_bakebook(module: types.ModuleType, bakebook_name: str, path: pathlib.Path) -> str:
55
+ if not hasattr(module, bakebook_name):
56
+ typer.echo(f"No '{bakebook_name}' found in {path}", err=True)
57
+ raise SystemExit(1)
58
+ bakebook = getattr(module, bakebook_name)
59
+ if not isinstance(bakebook, str):
60
+ typer.echo(
61
+ f"Bakebook '{bakebook_name}' must be a string, got {type(bakebook).__name__}",
62
+ err=True,
63
+ )
64
+ raise SystemExit(1)
65
+ return bakebook
66
+
67
+
68
+ def resolve_bakebook(file_name: str, bakebook_name: str, chdir: str | None = None) -> str:
69
+ if chdir:
70
+ change_directory(chdir)
71
+
72
+ validate_file_name(file_name)
73
+ path = resolve_file_path(file_name)
74
+ module = load_module(path)
75
+ return get_bakebook(module=module, bakebook_name=bakebook_name, path=path)
@@ -0,0 +1,8 @@
1
+ import typer
2
+
3
+ app = typer.Typer()
4
+
5
+
6
+ @app.command()
7
+ def main() -> None:
8
+ typer.echo("hello world")
File without changes