mirror of
https://github.com/maoakeEnterprise/amazing.git
synced 2026-04-28 16:04:35 +02:00
Compare commits
19 Commits
b54e49122c
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 0bd43d21a5 | |||
| f5131f0e01 | |||
| 4d5662c248 | |||
| e137389216 | |||
| 21e9aba95f | |||
| 9fa121cdce | |||
| 04c28a851f | |||
| 6189d7f321 | |||
| e63c2679a6 | |||
| f04381568d | |||
| ee4f48a5c0 | |||
| 2532a35e30 | |||
| 6f503bdd36 | |||
| 5022cfe020 | |||
| 11947db62f | |||
| 0045def73b | |||
| b6067b2045 | |||
| 9c76914366 | |||
| b38da3fc31 |
@@ -215,5 +215,3 @@ __marimo__/
|
|||||||
# Streamlit
|
# Streamlit
|
||||||
.streamlit/secrets.toml
|
.streamlit/secrets.toml
|
||||||
test.txt
|
test.txt
|
||||||
|
|
||||||
mazegen-1.0.0-py3-none-any.whl
|
|
||||||
|
|||||||
@@ -13,15 +13,15 @@ run_windows:
|
|||||||
.venv\Scripts\python -m a_maze_ing config.txt
|
.venv\Scripts\python -m a_maze_ing config.txt
|
||||||
|
|
||||||
debug:
|
debug:
|
||||||
uv pdb python3 a_maze_ing.py config.txt
|
uv run python3 -m pdb a_maze_ing.py config.txt
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -rf */**/__pycache__ */__pycache__ __pycache__ .mypy_cache .venv dist build */**/*.egg-info */*.egg-info *.egg-info test.txt
|
rm -rf */**/__pycache__ */__pycache__ __pycache__ */.mypy_cache .mypy_cache .venv dist build */**/*.egg-info */*.egg-info *.egg-info test.txt
|
||||||
|
|
||||||
fclean: clean
|
fclean: clean
|
||||||
rm mazegen-1.0.0-py3-none-any.whl
|
rm mazegen-1.0.0-py3-none-any.whl
|
||||||
|
|
||||||
lint:
|
lint: install
|
||||||
uv run flake8 . --exclude=.venv
|
uv run flake8 . --exclude=.venv
|
||||||
uv run env PYTHONPATH=src python3 -m mypy --warn-return-any --warn-unused-ignores --ignore-missing-imports --disallow-untyped-defs --check-untyped-defs -p mazegen
|
uv run env PYTHONPATH=src python3 -m mypy --warn-return-any --warn-unused-ignores --ignore-missing-imports --disallow-untyped-defs --check-untyped-defs -p mazegen
|
||||||
uv run env PYTHONPATH=src python3 -m mypy --warn-return-any --warn-unused-ignores --ignore-missing-imports --disallow-untyped-defs --check-untyped-defs -p parsing
|
uv run env PYTHONPATH=src python3 -m mypy --warn-return-any --warn-unused-ignores --ignore-missing-imports --disallow-untyped-defs --check-untyped-defs -p parsing
|
||||||
@@ -29,7 +29,7 @@ lint:
|
|||||||
uv run env PYTHONPATH=src python3 -m mypy --warn-return-any --warn-unused-ignores --ignore-missing-imports --disallow-untyped-defs --check-untyped-defs tests
|
uv run env PYTHONPATH=src python3 -m mypy --warn-return-any --warn-unused-ignores --ignore-missing-imports --disallow-untyped-defs --check-untyped-defs tests
|
||||||
uv run env PYTHONPATH=src python3 -m mypy --warn-return-any --warn-unused-ignores --ignore-missing-imports --disallow-untyped-defs --check-untyped-defs a_maze_ing.py
|
uv run env PYTHONPATH=src python3 -m mypy --warn-return-any --warn-unused-ignores --ignore-missing-imports --disallow-untyped-defs --check-untyped-defs a_maze_ing.py
|
||||||
|
|
||||||
lint-strict:
|
lint-strict: install
|
||||||
uv run flake8 . --exclude=.venv
|
uv run flake8 . --exclude=.venv
|
||||||
uv run env PYTHONPATH=src python3 -m mypy --strict -p mazegen
|
uv run env PYTHONPATH=src python3 -m mypy --strict -p mazegen
|
||||||
uv run env PYTHONPATH=src python3 -m mypy --strict src/AMazeIng.py
|
uv run env PYTHONPATH=src python3 -m mypy --strict src/AMazeIng.py
|
||||||
|
|||||||
+5
-5
@@ -1,3 +1,4 @@
|
|||||||
|
import os
|
||||||
from typing import Any
|
from typing import Any
|
||||||
from numpy.typing import NDArray
|
from numpy.typing import NDArray
|
||||||
from AMazeIng import AMazeIng
|
from AMazeIng import AMazeIng
|
||||||
@@ -224,7 +225,6 @@ class MazeMLX:
|
|||||||
progressively.
|
progressively.
|
||||||
"""
|
"""
|
||||||
path = amazing.solve_path()
|
path = amazing.solve_path()
|
||||||
print(path)
|
|
||||||
actual = amazing.entry
|
actual = amazing.entry
|
||||||
actual = (actual[0] - 1, actual[1] - 1)
|
actual = (actual[0] - 1, actual[1] - 1)
|
||||||
maze = amazing.maze.get_maze()
|
maze = amazing.maze.get_maze()
|
||||||
@@ -474,7 +474,7 @@ class MazeMLX:
|
|||||||
self.mlx.mlx_loop_hook(self.mlx_ptr, self.draw_image, amazing)
|
self.mlx.mlx_loop_hook(self.mlx_ptr, self.draw_image, amazing)
|
||||||
self.mlx.mlx_hook(self.win_ptr, 33, 0, self.close_loop, None)
|
self.mlx.mlx_hook(self.win_ptr, 33, 0, self.close_loop, None)
|
||||||
self.mlx.mlx_hook(
|
self.mlx.mlx_hook(
|
||||||
self.win_ptr, 2, 1 << 0, self.handle_key_press_mteriier, amazing
|
self.win_ptr, 2, 1 << 0, self.handle_key_press, amazing
|
||||||
)
|
)
|
||||||
self.mlx.mlx_loop(self.mlx_ptr)
|
self.mlx.mlx_loop(self.mlx_ptr)
|
||||||
|
|
||||||
@@ -483,12 +483,12 @@ def main() -> None:
|
|||||||
"""Run the maze application."""
|
"""Run the maze application."""
|
||||||
mlx = None
|
mlx = None
|
||||||
try:
|
try:
|
||||||
mlx = MazeMLX(1000, 1000)
|
os.system("cls" if os.name == "nt" else "clear")
|
||||||
config = Parsing.get_data_maze("config.txt")
|
config = Parsing.get_data_maze("config.txt")
|
||||||
amazing = AMazeIng(**config)
|
amazing = AMazeIng(**config)
|
||||||
|
mlx = MazeMLX(1600, 2000)
|
||||||
mlx.start(amazing)
|
mlx.start(amazing)
|
||||||
with open("test.txt", "w") as output:
|
amazing.export_maze()
|
||||||
output.write(amazing.__str__())
|
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
print(err)
|
print(err)
|
||||||
finally:
|
finally:
|
||||||
|
|||||||
+8
-8
@@ -1,8 +1,8 @@
|
|||||||
WIDTH=10
|
WIDTH=15
|
||||||
HEIGHT=10
|
HEIGHT=15
|
||||||
ENTRY=1,1
|
ENTRY=2,1
|
||||||
EXIT=10,10
|
EXIT=3,5
|
||||||
OUTPUT_FILE=maze.txt
|
OUTPUT_FILE=con.txt
|
||||||
PERFECT=True
|
PERFECT=False
|
||||||
GENERATOR=Kruskal
|
GENERATOR=DFS
|
||||||
SOLVER=AStar
|
Solver=AStar
|
||||||
|
|||||||
Binary file not shown.
+19
-3
@@ -12,8 +12,8 @@ class AMazeIng(BaseModel):
|
|||||||
|
|
||||||
model_config = ConfigDict(arbitrary_types_allowed=True)
|
model_config = ConfigDict(arbitrary_types_allowed=True)
|
||||||
|
|
||||||
width: int = Field(ge=4)
|
width: int = Field(ge=5, le=100)
|
||||||
height: int = Field(ge=4)
|
height: int = Field(ge=5, le=100)
|
||||||
entry: tuple[int, int]
|
entry: tuple[int, int]
|
||||||
exit: tuple[int, int]
|
exit: tuple[int, int]
|
||||||
output_file: str = Field(min_length=3)
|
output_file: str = Field(min_length=3)
|
||||||
@@ -21,6 +21,7 @@ class AMazeIng(BaseModel):
|
|||||||
maze: Maze = Field(default=Maze(None))
|
maze: Maze = Field(default=Maze(None))
|
||||||
generator: MazeGenerator
|
generator: MazeGenerator
|
||||||
solver: MazeSolver
|
solver: MazeSolver
|
||||||
|
seed: int | None = Field(default=None)
|
||||||
|
|
||||||
@model_validator(mode="after")
|
@model_validator(mode="after")
|
||||||
def check_entry_exit(self) -> Self:
|
def check_entry_exit(self) -> Self:
|
||||||
@@ -36,6 +37,14 @@ class AMazeIng(BaseModel):
|
|||||||
raise ValueError("Entry coordinates exceed the maze size")
|
raise ValueError("Entry coordinates exceed the maze size")
|
||||||
if self.exit[0] > self.width or self.exit[1] > self.height:
|
if self.exit[0] > self.width or self.exit[1] > self.height:
|
||||||
raise ValueError("Exit coordinates exceed the maze size")
|
raise ValueError("Exit coordinates exceed the maze size")
|
||||||
|
if self.entry == self.exit:
|
||||||
|
raise ValueError("Entry and Exit coordinates cant be the same")
|
||||||
|
if self.exit[0] < 1 or self.exit[1] < 1:
|
||||||
|
raise ValueError("Exit coordinates to low")
|
||||||
|
if self.entry[0] < 1 or self.entry[1] < 1:
|
||||||
|
raise ValueError("Entry coordinates to low")
|
||||||
|
if self.width < 9 or self.height < 7:
|
||||||
|
print("Height or width to low for disply forty two logo")
|
||||||
return self
|
return self
|
||||||
|
|
||||||
def generate(self) -> Generator[Maze, None, None]:
|
def generate(self) -> Generator[Maze, None, None]:
|
||||||
@@ -46,7 +55,9 @@ class AMazeIng(BaseModel):
|
|||||||
Yields:
|
Yields:
|
||||||
The current maze state after each generation step.
|
The current maze state after each generation step.
|
||||||
"""
|
"""
|
||||||
for array in self.generator.generator(self.height, self.width):
|
for array in self.generator.generator(
|
||||||
|
self.height, self.width, self.seed
|
||||||
|
):
|
||||||
self.maze.set_maze(array)
|
self.maze.set_maze(array)
|
||||||
yield self.maze
|
yield self.maze
|
||||||
return
|
return
|
||||||
@@ -59,6 +70,11 @@ class AMazeIng(BaseModel):
|
|||||||
"""
|
"""
|
||||||
return self.solver.solve(self.maze, self.height, self.width)
|
return self.solver.solve(self.maze, self.height, self.width)
|
||||||
|
|
||||||
|
def export_maze(self) -> None:
|
||||||
|
"""Export maze, entry, exit and resolved path in output_file"""
|
||||||
|
with open(self.output_file, "w") as file:
|
||||||
|
file.write(self.__str__())
|
||||||
|
|
||||||
def __str__(self) -> str:
|
def __str__(self) -> str:
|
||||||
"""Return a string representation of the maze and its solution.
|
"""Return a string representation of the maze and its solution.
|
||||||
|
|
||||||
|
|||||||
@@ -20,8 +20,8 @@ class MazeGenerator(ABC):
|
|||||||
end: Ending cell coordinates, using 1-based indexing.
|
end: Ending cell coordinates, using 1-based indexing.
|
||||||
perfect: Whether to generate a perfect maze with no loops.
|
perfect: Whether to generate a perfect maze with no loops.
|
||||||
"""
|
"""
|
||||||
self.start = (start[0] - 1, start[1] - 1)
|
self.start = (start[1] - 1, start[0] - 1)
|
||||||
self.end = (end[0] - 1, end[1] - 1)
|
self.end = (end[1] - 1, end[0] - 1)
|
||||||
self.perfect = perfect
|
self.perfect = perfect
|
||||||
|
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
@@ -105,10 +105,24 @@ class MazeGenerator(ABC):
|
|||||||
The modified maze.
|
The modified maze.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
def enough_wall(cell: Cell) -> bool:
|
||||||
|
nb_wall = 0
|
||||||
|
if cell.get_est():
|
||||||
|
nb_wall += 1
|
||||||
|
if cell.get_north():
|
||||||
|
nb_wall += 1
|
||||||
|
if cell.get_west():
|
||||||
|
nb_wall += 1
|
||||||
|
if cell.get_south():
|
||||||
|
nb_wall += 1
|
||||||
|
if nb_wall == 3:
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
directions = {"N": (0, -1), "S": (0, 1), "W": (-1, 0), "E": (1, 0)}
|
directions = {"N": (0, -1), "S": (0, 1), "W": (-1, 0), "E": (1, 0)}
|
||||||
|
|
||||||
reverse = {"N": "S", "S": "N", "W": "E", "E": "W"}
|
reverse = {"N": "S", "S": "N", "W": "E", "E": "W"}
|
||||||
min_break = 2
|
min_break = 1
|
||||||
while True:
|
while True:
|
||||||
count = 0
|
count = 0
|
||||||
for y in range(height):
|
for y in range(height):
|
||||||
@@ -125,7 +139,9 @@ class MazeGenerator(ABC):
|
|||||||
continue
|
continue
|
||||||
if direc in ["S", "E"]:
|
if direc in ["S", "E"]:
|
||||||
continue
|
continue
|
||||||
if np.random.random() < prob:
|
if not enough_wall(maze[y][x]):
|
||||||
|
continue
|
||||||
|
else:
|
||||||
count += 1
|
count += 1
|
||||||
cell = maze[y][x]
|
cell = maze[y][x]
|
||||||
cell_n = maze[ny][nx]
|
cell_n = maze[ny][nx]
|
||||||
@@ -137,7 +153,7 @@ class MazeGenerator(ABC):
|
|||||||
maze[y][x] = cell
|
maze[y][x] = cell
|
||||||
maze[ny][nx] = cell_n
|
maze[ny][nx] = cell_n
|
||||||
yield maze
|
yield maze
|
||||||
if count > min_break:
|
if count >= min_break:
|
||||||
break
|
break
|
||||||
return maze
|
return maze
|
||||||
|
|
||||||
@@ -292,9 +308,13 @@ class Kruskal(MazeGenerator):
|
|||||||
The final generated maze.
|
The final generated maze.
|
||||||
"""
|
"""
|
||||||
cells_ft = None
|
cells_ft = None
|
||||||
if height > 10 and width > 10:
|
if height >= 7 and width >= 9:
|
||||||
cells_ft = self.get_cell_ft(width, height)
|
cells_ft = self.get_cell_ft(width, height)
|
||||||
if cells_ft and (self.start in cells_ft or self.end in cells_ft):
|
if cells_ft and (self.start in cells_ft or self.end in cells_ft):
|
||||||
|
print(
|
||||||
|
"Forty two will not be display. "
|
||||||
|
"Entry or exit set in the ft logo"
|
||||||
|
)
|
||||||
cells_ft = None
|
cells_ft = None
|
||||||
|
|
||||||
if seed is not None:
|
if seed is not None:
|
||||||
@@ -324,7 +344,6 @@ class Kruskal(MazeGenerator):
|
|||||||
len(sets.sets) == 19 and cells_ft is not None
|
len(sets.sets) == 19 and cells_ft is not None
|
||||||
):
|
):
|
||||||
break
|
break
|
||||||
print(f"nb sets: {len(sets.sets)}")
|
|
||||||
maze = self.walls_to_maze(walls, height, width)
|
maze = self.walls_to_maze(walls, height, width)
|
||||||
if self.perfect is False:
|
if self.perfect is False:
|
||||||
gen = Kruskal.unperfect_maze(width, height, maze, cells_ft)
|
gen = Kruskal.unperfect_maze(width, height, maze, cells_ft)
|
||||||
@@ -347,8 +366,8 @@ class DepthFirstSearch(MazeGenerator):
|
|||||||
end: Ending cell coordinates, using 1-based indexing.
|
end: Ending cell coordinates, using 1-based indexing.
|
||||||
perfect: Whether to generate a perfect maze with no loops.
|
perfect: Whether to generate a perfect maze with no loops.
|
||||||
"""
|
"""
|
||||||
self.start = (start[0] - 1, start[1] - 1)
|
self.start = (start[1] - 1, start[0] - 1)
|
||||||
self.end = (end[0] - 1, end[1] - 1)
|
self.end = (end[1] - 1, end[0] - 1)
|
||||||
self.perfect = perfect
|
self.perfect = perfect
|
||||||
self.forty_two: set[tuple[int, int]] | None = None
|
self.forty_two: set[tuple[int, int]] | None = None
|
||||||
|
|
||||||
@@ -369,9 +388,9 @@ class DepthFirstSearch(MazeGenerator):
|
|||||||
The final generated maze.
|
The final generated maze.
|
||||||
"""
|
"""
|
||||||
if seed is not None:
|
if seed is not None:
|
||||||
np.random.seed(seed)
|
random.seed(seed)
|
||||||
maze = self.init_maze(width, height)
|
maze = self.init_maze(width, height)
|
||||||
if width > 9 and height > 9:
|
if width >= 9 and height >= 7:
|
||||||
self.forty_two = self.get_cell_ft(width, height)
|
self.forty_two = self.get_cell_ft(width, height)
|
||||||
visited: NDArray[np.object_] = np.zeros((height, width), dtype=bool)
|
visited: NDArray[np.object_] = np.zeros((height, width), dtype=bool)
|
||||||
if (
|
if (
|
||||||
@@ -380,6 +399,11 @@ class DepthFirstSearch(MazeGenerator):
|
|||||||
and self.end not in self.forty_two
|
and self.end not in self.forty_two
|
||||||
):
|
):
|
||||||
visited = self.lock_cell_ft(visited, self.forty_two)
|
visited = self.lock_cell_ft(visited, self.forty_two)
|
||||||
|
else:
|
||||||
|
print(
|
||||||
|
"Forty two will not be display. "
|
||||||
|
"Entry or exit set in the ft logo"
|
||||||
|
)
|
||||||
path: list[tuple[int, int]] = list()
|
path: list[tuple[int, int]] = list()
|
||||||
w_h = (width, height)
|
w_h = (width, height)
|
||||||
coord = (0, 0)
|
coord = (0, 0)
|
||||||
|
|||||||
@@ -84,7 +84,8 @@ class AStar(MazeSolver):
|
|||||||
start: Start coordinates using 1-based indexing.
|
start: Start coordinates using 1-based indexing.
|
||||||
end: End coordinates using 1-based indexing.
|
end: End coordinates using 1-based indexing.
|
||||||
"""
|
"""
|
||||||
super().__init__(start, end)
|
self.start = (start[0] - 1, start[1] - 1)
|
||||||
|
self.end = (end[0] - 1, end[1] - 1)
|
||||||
|
|
||||||
def h(self, n: tuple[int, int]) -> int:
|
def h(self, n: tuple[int, int]) -> int:
|
||||||
"""Compute the Manhattan distance heuristic to the goal.
|
"""Compute the Manhattan distance heuristic to the goal.
|
||||||
@@ -196,6 +197,8 @@ class AStar(MazeSolver):
|
|||||||
to_check,
|
to_check,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
if path == self.end:
|
||||||
|
break
|
||||||
raise Exception("Path not found")
|
raise Exception("Path not found")
|
||||||
|
|
||||||
def get_rev_dir(self, current: Node) -> str:
|
def get_rev_dir(self, current: Node) -> str:
|
||||||
|
|||||||
+51
-10
@@ -6,6 +6,22 @@ from typing import Any
|
|||||||
class DataMaze:
|
class DataMaze:
|
||||||
"""Provide helper methods to load and validate maze configuration data."""
|
"""Provide helper methods to load and validate maze configuration data."""
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def test_output_file(name_file: str) -> None:
|
||||||
|
try:
|
||||||
|
with open(name_file, "r"):
|
||||||
|
while True:
|
||||||
|
res = input(
|
||||||
|
f"{name_file} already exist. Data will"
|
||||||
|
" be erased. Continue ? (y/n)"
|
||||||
|
)
|
||||||
|
if res == "y":
|
||||||
|
break
|
||||||
|
elif res == "n":
|
||||||
|
raise Exception("")
|
||||||
|
except FileNotFoundError:
|
||||||
|
return
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_file_data(name_file: str) -> str:
|
def get_file_data(name_file: str) -> str:
|
||||||
"""Read and return the contents of a configuration file.
|
"""Read and return the contents of a configuration file.
|
||||||
@@ -38,8 +54,12 @@ class DataMaze:
|
|||||||
A dictionary mapping configuration keys to their string values.
|
A dictionary mapping configuration keys to their string values.
|
||||||
"""
|
"""
|
||||||
tmp = data.split("\n")
|
tmp = data.split("\n")
|
||||||
tmp2 = [value.split("=", 1) for value in tmp if "=" in value]
|
tmp2 = [
|
||||||
data_t = {value[0]: value[1] for value in tmp2}
|
value.split("=", 1)
|
||||||
|
for value in tmp
|
||||||
|
if not value.startswith("#") and "=" in value
|
||||||
|
]
|
||||||
|
data_t = {value[0].upper(): value[1] for value in tmp2}
|
||||||
return data_t
|
return data_t
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@@ -62,14 +82,14 @@ class DataMaze:
|
|||||||
"GENERATOR",
|
"GENERATOR",
|
||||||
"SOLVER",
|
"SOLVER",
|
||||||
}
|
}
|
||||||
set_key = {key for key in data.keys()}
|
i = 0
|
||||||
if len(set_key) != len(key_test):
|
for key in data:
|
||||||
raise KeyError("Missing some data the len do not correspond")
|
if key.upper() == "OUTPUT_FILE":
|
||||||
res_key = {key for key in set_key if key not in key_test}
|
DataMaze.test_output_file(data[key])
|
||||||
if len(res_key) != 0:
|
if key in key_test:
|
||||||
raise KeyError(
|
i += 1
|
||||||
"Some Key " f"do not correspond the keys: {res_key}"
|
if len(key_test) != i:
|
||||||
)
|
raise Exception("Some mandatory key not provide")
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def convert_values(data: dict[str, str]) -> dict[str, Any]:
|
def convert_values(data: dict[str, str]) -> dict[str, Any]:
|
||||||
@@ -88,6 +108,10 @@ class DataMaze:
|
|||||||
res: dict[str, Any] = {}
|
res: dict[str, Any] = {}
|
||||||
for key in key_int:
|
for key in key_int:
|
||||||
res.update({key: int(data[key])})
|
res.update({key: int(data[key])})
|
||||||
|
try:
|
||||||
|
res.update({"SEED": int(data["SEED"])})
|
||||||
|
except KeyError:
|
||||||
|
pass
|
||||||
for key in key_tuple:
|
for key in key_tuple:
|
||||||
res.update({key: DataMaze.convert_tuple(data[key])})
|
res.update({key: DataMaze.convert_tuple(data[key])})
|
||||||
for key in key_bool:
|
for key in key_bool:
|
||||||
@@ -181,6 +205,22 @@ class DataMaze:
|
|||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def test_file_format(file: str) -> None:
|
||||||
|
with open(file) as data_str:
|
||||||
|
for line in data_str:
|
||||||
|
if line.startswith("#"):
|
||||||
|
continue
|
||||||
|
if len(line.split("=", 1)) != 2:
|
||||||
|
raise Exception(
|
||||||
|
"config file format not respected. excpected format : "
|
||||||
|
"KEY=VALUE"
|
||||||
|
)
|
||||||
|
if not line.split("=", 1)[1] or line.split("=", 1)[1] == "\n":
|
||||||
|
raise Exception(
|
||||||
|
f"VALUE not provide for {line.split('=')[0]} key"
|
||||||
|
)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_data_maze(name_file: str) -> dict[str, Any]:
|
def get_data_maze(name_file: str) -> dict[str, Any]:
|
||||||
"""Load, validate, and convert maze configuration data from a file.
|
"""Load, validate, and convert maze configuration data from a file.
|
||||||
@@ -192,6 +232,7 @@ class DataMaze:
|
|||||||
A dictionary of validated configuration values with lowercase keys.
|
A dictionary of validated configuration values with lowercase keys.
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
|
DataMaze.test_file_format(name_file)
|
||||||
data_str = DataMaze.get_file_data(name_file)
|
data_str = DataMaze.get_file_data(name_file)
|
||||||
data_dict = DataMaze.transform_data(data_str)
|
data_dict = DataMaze.transform_data(data_str)
|
||||||
DataMaze.verif_key_data(data_dict)
|
DataMaze.verif_key_data(data_dict)
|
||||||
|
|||||||
Reference in New Issue
Block a user