* local helper update
* Delete entities.ftl
* Helper Refactor
* Revert "Helper Refactor"
This reverts commit 4aca315593.
* Helper Refactor
* Жееесть, я не знал про setdefault у словарей
* Update localization_helper.py
* Ревёрт "Жееесть, я не знал про setdefault у словарей"
Лучше бы я продолжал не знать о них
* чтооооо
* Update yml_parser.py
* Update entities.ftl
---------
Co-authored-by: Ed <96445749+TheShuEd@users.noreply.github.com>
39 lines
1.2 KiB
Python
39 lines
1.2 KiB
Python
import os
|
|
import json
|
|
|
|
|
|
class BaseParser:
|
|
"""
|
|
BaseParser, contains the basic functions for the yml_parser module in the yml_parser package
|
|
and for the ftl_parser module in the ftl_parser package
|
|
"""
|
|
def __init__(self, paths: tuple):
|
|
self.path, self.errors_path = paths
|
|
|
|
def _get_files_paths(self) -> list:
|
|
"""
|
|
The method gets the path to the yml folder of localization prototypes/files, e.g. "ftl",
|
|
then with the help of os library goes through each file in
|
|
the folder and creates a path for it, e.g. "ftl/objects.ftl".
|
|
"""
|
|
files_paths_lst = []
|
|
|
|
for dirpath, _, filenames in os.walk(self.path):
|
|
for filename in filenames:
|
|
path = f"{dirpath}\\{filename}"
|
|
files_paths_lst.append(path)
|
|
|
|
return files_paths_lst
|
|
|
|
@staticmethod
|
|
def save_to_json(prototypes: dict, path: str) -> None:
|
|
with open(path, 'w') as json_file:
|
|
json.dump(prototypes, json_file, indent=4)
|
|
|
|
@staticmethod
|
|
def _check_file_extension(path: str, extension: str) -> bool:
|
|
if path.endswith(extension):
|
|
return True
|
|
return False
|
|
|