fix StorageManager save, read expression and operation
fix create fix export; not remove src space
This commit is contained in:
10
run.py
10
run.py
@@ -383,7 +383,7 @@ class StorageManager:
|
||||
) -> None:
|
||||
path = STORAGE_DIR / location / lang.value / ("completed" if completed else "")
|
||||
os.makedirs(path, exist_ok=True)
|
||||
with open(f"{path}/{filename}", "wb") as f:
|
||||
with open(path / f"{filename}.{lang.value}", "wb") as f:
|
||||
f.write(content)
|
||||
|
||||
def read_file(self, location: str, lang: Language, filename: str) -> bytes:
|
||||
@@ -392,8 +392,8 @@ class StorageManager:
|
||||
raise FileNotFoundError(
|
||||
f"File not found in storage: {location}/{filename}.{lang.value}"
|
||||
)
|
||||
file_path = f"{path}/{filename}"
|
||||
if not os.path.isfile(file_path):
|
||||
file_path = path / f"{filename}.{lang.value}"
|
||||
if not file_path.is_file():
|
||||
raise FileNotFoundError(f"File not found in storage: {file_path}")
|
||||
with open(file_path, "rb") as f:
|
||||
return f.read()
|
||||
@@ -586,7 +586,7 @@ def create(target: str, completed: bool, no_template: bool, force: bool):
|
||||
click.secho(f"Template not found: {template_path}", fg="yellow")
|
||||
|
||||
StorageManager().save_file(
|
||||
loc, lang, f"{filename}.{lang.value}", content, completed
|
||||
loc, lang, filename, content, completed
|
||||
)
|
||||
click.secho(
|
||||
f"Created '{filename}.{lang.value}' in location '{loc}'",
|
||||
@@ -768,7 +768,7 @@ def export(from_: tuple[str, ...], all_: bool, force: bool):
|
||||
|
||||
with open(src_path, "rb") as f_src:
|
||||
content = f_src.read()
|
||||
|
||||
os.remove(src_path)
|
||||
StorageManager().save_file(
|
||||
s_loc, from_language, s_file, content, s_is_completed
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user