bakefile 0.0.6__tar.gz → 0.0.7__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.
- {bakefile-0.0.6 → bakefile-0.0.7}/PKG-INFO +1 -1
- {bakefile-0.0.6 → bakefile-0.0.7}/pyproject.toml +1 -1
- bakefile-0.0.7/src/bake/manage/write_bakefile.py +39 -0
- bakefile-0.0.6/src/bake/manage/write_bakefile.py +0 -20
- {bakefile-0.0.6 → bakefile-0.0.7}/README.md +0 -0
- {bakefile-0.0.6 → bakefile-0.0.7}/src/bake/__init__.py +0 -0
- {bakefile-0.0.6 → bakefile-0.0.7}/src/bake/bakebook/__init__.py +0 -0
- {bakefile-0.0.6 → bakefile-0.0.7}/src/bake/bakebook/bakebook.py +0 -0
- {bakefile-0.0.6 → bakefile-0.0.7}/src/bake/bakebook/decorator.py +0 -0
- {bakefile-0.0.6 → bakefile-0.0.7}/src/bake/bakebook/get.py +0 -0
- {bakefile-0.0.6 → bakefile-0.0.7}/src/bake/cli/__init__.py +0 -0
- {bakefile-0.0.6 → bakefile-0.0.7}/src/bake/cli/bake/__init__.py +0 -0
- {bakefile-0.0.6 → bakefile-0.0.7}/src/bake/cli/bake/__main__.py +0 -0
- {bakefile-0.0.6 → bakefile-0.0.7}/src/bake/cli/bake/main.py +0 -0
- {bakefile-0.0.6 → bakefile-0.0.7}/src/bake/cli/bake/reinvocation.py +0 -0
- {bakefile-0.0.6 → bakefile-0.0.7}/src/bake/cli/bakefile/__init__.py +0 -0
- {bakefile-0.0.6 → bakefile-0.0.7}/src/bake/cli/bakefile/__main__.py +0 -0
- {bakefile-0.0.6 → bakefile-0.0.7}/src/bake/cli/bakefile/add_inline.py +0 -0
- {bakefile-0.0.6 → bakefile-0.0.7}/src/bake/cli/bakefile/export.py +0 -0
- {bakefile-0.0.6 → bakefile-0.0.7}/src/bake/cli/bakefile/find_python.py +0 -0
- {bakefile-0.0.6 → bakefile-0.0.7}/src/bake/cli/bakefile/init.py +0 -0
- {bakefile-0.0.6 → bakefile-0.0.7}/src/bake/cli/bakefile/lint.py +0 -0
- {bakefile-0.0.6 → bakefile-0.0.7}/src/bake/cli/bakefile/main.py +0 -0
- {bakefile-0.0.6 → bakefile-0.0.7}/src/bake/cli/bakefile/uv.py +0 -0
- {bakefile-0.0.6 → bakefile-0.0.7}/src/bake/cli/common/__init__.py +0 -0
- {bakefile-0.0.6 → bakefile-0.0.7}/src/bake/cli/common/app.py +0 -0
- {bakefile-0.0.6 → bakefile-0.0.7}/src/bake/cli/common/callback.py +0 -0
- {bakefile-0.0.6 → bakefile-0.0.7}/src/bake/cli/common/context.py +0 -0
- {bakefile-0.0.6 → bakefile-0.0.7}/src/bake/cli/common/exception_handler.py +0 -0
- {bakefile-0.0.6 → bakefile-0.0.7}/src/bake/cli/common/obj.py +0 -0
- {bakefile-0.0.6 → bakefile-0.0.7}/src/bake/cli/common/params.py +0 -0
- {bakefile-0.0.6 → bakefile-0.0.7}/src/bake/cli/utils/__init__.py +0 -0
- {bakefile-0.0.6 → bakefile-0.0.7}/src/bake/cli/utils/version.py +0 -0
- {bakefile-0.0.6 → bakefile-0.0.7}/src/bake/manage/__init__.py +0 -0
- {bakefile-0.0.6 → bakefile-0.0.7}/src/bake/manage/add_inline.py +0 -0
- {bakefile-0.0.6 → bakefile-0.0.7}/src/bake/manage/find_python.py +0 -0
- {bakefile-0.0.6 → bakefile-0.0.7}/src/bake/manage/lint.py +0 -0
- {bakefile-0.0.6 → bakefile-0.0.7}/src/bake/manage/run_uv.py +0 -0
- {bakefile-0.0.6 → bakefile-0.0.7}/src/bake/py.typed +0 -0
- {bakefile-0.0.6 → bakefile-0.0.7}/src/bake/samples/__init__.py +0 -0
- {bakefile-0.0.6 → bakefile-0.0.7}/src/bake/samples/simple.py +0 -0
- {bakefile-0.0.6 → bakefile-0.0.7}/src/bake/ui/__init__.py +0 -0
- {bakefile-0.0.6 → bakefile-0.0.7}/src/bake/ui/console.py +0 -0
- {bakefile-0.0.6 → bakefile-0.0.7}/src/bake/ui/logger/__init__.py +0 -0
- {bakefile-0.0.6 → bakefile-0.0.7}/src/bake/ui/logger/capsys.py +0 -0
- {bakefile-0.0.6 → bakefile-0.0.7}/src/bake/ui/logger/setup.py +0 -0
- {bakefile-0.0.6 → bakefile-0.0.7}/src/bake/ui/logger/utils.py +0 -0
- {bakefile-0.0.6 → bakefile-0.0.7}/src/bake/ui/params.py +0 -0
- {bakefile-0.0.6 → bakefile-0.0.7}/src/bake/ui/run/__init__.py +0 -0
- {bakefile-0.0.6 → bakefile-0.0.7}/src/bake/ui/run/run.py +0 -0
- {bakefile-0.0.6 → bakefile-0.0.7}/src/bake/ui/run/script.py +0 -0
- {bakefile-0.0.6 → bakefile-0.0.7}/src/bake/ui/run/splitter.py +0 -0
- {bakefile-0.0.6 → bakefile-0.0.7}/src/bake/ui/run/uv.py +0 -0
- {bakefile-0.0.6 → bakefile-0.0.7}/src/bake/ui/style.py +0 -0
- {bakefile-0.0.6 → bakefile-0.0.7}/src/bake/utils/__init__.py +0 -0
- {bakefile-0.0.6 → bakefile-0.0.7}/src/bake/utils/constants.py +0 -0
- {bakefile-0.0.6 → bakefile-0.0.7}/src/bake/utils/env.py +0 -0
- {bakefile-0.0.6 → bakefile-0.0.7}/src/bake/utils/exceptions.py +0 -0
- {bakefile-0.0.6 → bakefile-0.0.7}/src/bakelib/__init__.py +0 -0
- {bakefile-0.0.6 → bakefile-0.0.7}/src/bakelib/space/__init__.py +0 -0
- {bakefile-0.0.6 → bakefile-0.0.7}/src/bakelib/space/base.py +0 -0
- {bakefile-0.0.6 → bakefile-0.0.7}/src/bakelib/space/python.py +0 -0
- {bakefile-0.0.6 → bakefile-0.0.7}/src/bakelib/space/utils.py +0 -0
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import types
|
|
2
|
+
from pathlib import Path
|
|
3
|
+
|
|
4
|
+
from bake.samples import simple
|
|
5
|
+
from bake.utils.constants import BAKEBOOK_NAME_IN_SAMPLES
|
|
6
|
+
|
|
7
|
+
# Allowed sample modules
|
|
8
|
+
# This dictionary acts as a whitelist for security - only these modules can be used
|
|
9
|
+
ALLOWED_SAMPLE_MODULES: dict[str, types.ModuleType] = {
|
|
10
|
+
simple.__name__: simple,
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def write_bakefile(
|
|
15
|
+
bakefile_path: Path, bakebook_name: str, sample_module: types.ModuleType
|
|
16
|
+
) -> None:
|
|
17
|
+
if not hasattr(sample_module, BAKEBOOK_NAME_IN_SAMPLES):
|
|
18
|
+
raise ValueError(
|
|
19
|
+
f"Module `{sample_module.__name__}` must have `{BAKEBOOK_NAME_IN_SAMPLES}` attribute"
|
|
20
|
+
)
|
|
21
|
+
|
|
22
|
+
module_name = sample_module.__name__
|
|
23
|
+
if module_name not in ALLOWED_SAMPLE_MODULES:
|
|
24
|
+
raise ValueError(
|
|
25
|
+
f"Module `{module_name}` is not in the allowed sample modules list. "
|
|
26
|
+
f"Allowed modules: {list(ALLOWED_SAMPLE_MODULES.keys())}"
|
|
27
|
+
)
|
|
28
|
+
|
|
29
|
+
allowed_module = ALLOWED_SAMPLE_MODULES[module_name]
|
|
30
|
+
if sample_module is not allowed_module:
|
|
31
|
+
raise ValueError(f"Module `{module_name}` does not match the allowed module object")
|
|
32
|
+
|
|
33
|
+
if allowed_module.__file__ is None:
|
|
34
|
+
raise ValueError(f"Could not find file for module `{module_name}`")
|
|
35
|
+
|
|
36
|
+
source_file_path = Path(allowed_module.__file__)
|
|
37
|
+
original_bakefile_content = source_file_path.read_text()
|
|
38
|
+
customized_content = original_bakefile_content.replace(BAKEBOOK_NAME_IN_SAMPLES, bakebook_name)
|
|
39
|
+
bakefile_path.write_text(customized_content)
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import types
|
|
2
|
-
from pathlib import Path
|
|
3
|
-
|
|
4
|
-
from bake.utils.constants import BAKEBOOK_NAME_IN_SAMPLES
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
def write_bakefile(
|
|
8
|
-
bakefile_path: Path, bakebook_name: str, sample_module: types.ModuleType
|
|
9
|
-
) -> None:
|
|
10
|
-
if not hasattr(sample_module, BAKEBOOK_NAME_IN_SAMPLES):
|
|
11
|
-
raise ValueError(
|
|
12
|
-
f"Module `{sample_module.__name__}` must have `{BAKEBOOK_NAME_IN_SAMPLES}` attribute"
|
|
13
|
-
)
|
|
14
|
-
|
|
15
|
-
if sample_module.__file__ is None:
|
|
16
|
-
raise ValueError(f"Could not find `{sample_module.__name__}`")
|
|
17
|
-
|
|
18
|
-
original_bakefile_content = Path(sample_module.__file__).read_text()
|
|
19
|
-
customized_content = original_bakefile_content.replace(BAKEBOOK_NAME_IN_SAMPLES, bakebook_name)
|
|
20
|
-
bakefile_path.write_text(customized_content)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|