-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathrpc.py
More file actions
27 lines (20 loc) · 704 Bytes
/
rpc.py
File metadata and controls
27 lines (20 loc) · 704 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import json
file_name = "./rpc.json"
def read_variable_json(nom_variable):
global file_name
try:
with open(file_name, "r") as file:
data = json.load(file)
if nom_variable in data:
return data[nom_variable]
except Exception as e:
print(f"Erreur while trying to read the rpc.json: {e}")
return None
def edit_variable_json(nom_variable, nouvelle_valeur):
global file_name
with open(file_name, "r") as file:
data = json.load(file)
if nom_variable in data:
data[nom_variable] = nouvelle_valeur
with open(file_name, "w") as file:
json.dump(data, file, indent=4)