bakefile 0.0.2rc1.post7__py3-none-any.whl → 0.0.3__py3-none-any.whl

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 @@
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")
@@ -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,11 @@
1
+ bakefile/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
+ bakefile/cli/__init__.py,sha256=da1PTClDMl-IBkrSvq6JC1lnS-K_BASzCvxVhNxN5Ls,13
3
+ bakefile/cli/bake/__init__.py,sha256=ODwmoNPYI4nEjw0ac6DDu0uNcBSULA0nFVevdFGTdEE,58
4
+ bakefile/cli/bake/main.py,sha256=QV7Ug_5L6AoHCAcqO3iro_XYklCDeYfTOpcLOUr8aKE,580
5
+ bakefile/cli/bake/resolve_bakebook.py,sha256=c6-puofWBTvoqKcmZZKr0LiswzTSBa4EhNhYJLOzPdQ,2410
6
+ bakefile/cli/bakefile.py,sha256=KCuJFSJkn7ORlNUrT-xGhlttnhwgz1p2-P9i6A5UpCE,101
7
+ bakefile/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
8
+ bakefile-0.0.3.dist-info/WHEEL,sha256=ZyFSCYkV2BrxH6-HRVRg3R9Fo7MALzer9KiPYqNxSbo,79
9
+ bakefile-0.0.3.dist-info/entry_points.txt,sha256=9oSP-EtniU7OO52Nuto40-DsGYe5zZvoaXUULkYFs2M,85
10
+ bakefile-0.0.3.dist-info/METADATA,sha256=_2HxykBi-CYOCxCzdy57EwxRZe5XGJJ7KUBXUWqcE3I,1908
11
+ bakefile-0.0.3.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ [console_scripts]
2
+ bake = bakefile.cli.bake:app
3
+ bakefile = bakefile.cli.bakefile:app
4
+
bakefile/hello.py DELETED
@@ -1,33 +0,0 @@
1
- import sys
2
- from datetime import datetime
3
- from pathlib import Path
4
-
5
- import pydantic
6
-
7
-
8
- class GreetingMessage(pydantic.BaseModel):
9
- message: str
10
- timestamp: datetime
11
- python_version: str
12
- directory: str
13
-
14
-
15
- def hello(test_test: None = None) -> str:
16
- _ = test_test
17
- current_time = datetime.now()
18
- current_dir = str(Path.cwd())
19
- python_version = f"{sys.version_info.major}.{sys.version_info.minor}"
20
-
21
- greeting = GreetingMessage(
22
- message="Hello from bakefile!",
23
- timestamp=current_time,
24
- python_version=python_version,
25
- directory=current_dir,
26
- )
27
-
28
- return (
29
- f"{greeting.message}\n"
30
- f"Current time: {greeting.timestamp}\n"
31
- f"Current directory: {greeting.directory}\n"
32
- f"Python version: {greeting.python_version}"
33
- )
@@ -1,11 +0,0 @@
1
- Metadata-Version: 2.3
2
- Name: bakefile
3
- Version: 0.0.2rc1.post7
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-Python: >=3.11
9
- Description-Content-Type: text/markdown
10
-
11
- # bakefile
@@ -1,6 +0,0 @@
1
- bakefile/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
- bakefile/hello.py,sha256=5LswkAzN4mokkp5iuETANV6B8xm660TvuD2_tTuqznw,803
3
- bakefile/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
- bakefile-0.0.2rc1.post7.dist-info/WHEEL,sha256=ZyFSCYkV2BrxH6-HRVRg3R9Fo7MALzer9KiPYqNxSbo,79
5
- bakefile-0.0.2rc1.post7.dist-info/METADATA,sha256=IEyxhU-OyuSyUt4ggUBaLG5OCNL7yRGx5LJcUrTikQc,297
6
- bakefile-0.0.2rc1.post7.dist-info/RECORD,,