Using config.json

This commit is contained in:
LucasVbr
2022-06-05 12:08:02 +02:00
parent 9b46b290e1
commit 9c959af699
12 changed files with 188 additions and 91 deletions
+35
View File
@@ -0,0 +1,35 @@
# -*- coding: utf-8 -*-
"""
04/06/2022
"""
import json
__file__ = 'FileUtils.py'
__author__ = 'Lucas Vbr'
__version__ = '0.1'
DEFAULT_FILE_ENCODING = "utf8"
def getJsonData(filePath: str) -> str:
"""
Take data from JSON File
:param filePath: Path of the file to read
:return: The content of the JSON file
"""
with open(filePath, encoding=DEFAULT_FILE_ENCODING) as file:
data = json.load(file)
return data
def setFileData(filePath: str, content: str) -> None:
"""
Create a new File or replace it content if already exist
:param filePath: Path of the file to fill
:param content: Content to place in the file
:return: None
"""
with open(filePath, "w", encoding=DEFAULT_FILE_ENCODING) as file:
file.write(content)