mirror of
https://github.com/Redume/Kekkai.git
synced 2025-03-13 12:04:38 +03:00
сhore(chart): Made parsing and converting hjson to json
This commit is contained in:
parent
1964fd333a
commit
c00dea8a81
1 changed files with 9 additions and 11 deletions
|
@ -1,20 +1,18 @@
|
||||||
# pylint: disable=R0801
|
|
||||||
"""
|
"""
|
||||||
This module provides a function for loading a YAML configuration file.
|
Parsing and converting HJSON config to JSON
|
||||||
The function reads the file content and returns it as a Python dictionary.
|
|
||||||
"""
|
"""
|
||||||
import yaml
|
import hjson
|
||||||
|
import json
|
||||||
|
|
||||||
def load_config(file_path: str) -> dict:
|
def load_config(file_path: str) -> dict:
|
||||||
"""
|
"""
|
||||||
Loads a YAML configuration file and returns its contents as a dictionary.
|
Load an HJSON file, convert it to a JSON string with indentation,
|
||||||
|
and return it.
|
||||||
|
|
||||||
This function opens the specified YAML file, parses its content, and
|
params: file_path (str): The path to the HJSON file.
|
||||||
returns it in dictionary format, making it accessible for use in
|
|
||||||
the application.
|
|
||||||
|
|
||||||
:param file_path: The path to the YAML configuration file to be loaded.
|
returns str: The JSON string formatted with indentation.
|
||||||
:return: A dictionary containing the parsed content of the YAML file.
|
|
||||||
"""
|
"""
|
||||||
with open(file_path, 'r', encoding='utf-8') as file:
|
with open(file_path, 'r', encoding='utf-8') as file:
|
||||||
return yaml.safe_load(file)
|
hjson_data = hjson.load(file)
|
||||||
|
return json.dumps(hjson_data, indent=4)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue