Commit 4b0c5a3d authored by Adrien Laporte's avatar Adrien Laporte
Browse files

Add degradability

parent 6c768121
......@@ -43,11 +43,12 @@ json_output_file = (
chaton_keys = {
"name": "chaton",
"url": "chaton_website",
"services": "services",
}
service_keys = {
# "": "type", # Ajouté après coup
"software": "software", # list → str
# "": "type", # Ajouté après coup
"public": "open",
"weight": "weight", # Todo
"consent": "consent", # Todo
......@@ -108,17 +109,16 @@ software_descriptions = {
# Ajoutés à la main :
}
degradability = {"Jamais", "1 semaine", "6 mois", "12 mois"} # ToDo fonction
conv_values = {
"http": "HTTP",
"tout.e.s": "Tout⋅e⋅s",
"cercle_prive": "Cercle privé",
}
input = {"urll": "http", "a": ["out.e.s", "cercle_prive", {"b": "http",},]}
def convertDegradability(nb: int) -> str:
if nb == 0:
return "Jamais"
elif nb < 7:
return "1 semaine"
elif nb < 6*30.5:
return "6 mois"
else:
return "12 mois"
def showNode(str):
......@@ -164,15 +164,22 @@ def convertStr(v: str, context: str = None) -> str:
return v
elif context == "name":
return v
elif context == "type":
print("Ouiiiii")
elif context == "software":
return software_names.get(v, None)
return conv_values.get(v, None)
return None
def convertInt(v: int, context: str = None) -> str:
if context == "degradability":
return convertDegradability(v)
return None
def convertValue(val, context: str = None):
showNode(f"V : {val}, {context}")
if type(val) is int:
return convertInt(val, context)
if type(val) is str:
return convertStr(val, context)
elif type(val) is dict:
......@@ -187,4 +194,5 @@ with open(json_input_file, "r", encoding="utf8") as input_file:
input = json.loads(input_file.read())
print(input)
print()
print(convertValue(input))
{
"name": "Picasoft",
"url": "https://picasoft.net",
"services": [
{
"type": "rss",
"software": "mattermost",
"degradability" : 12
}
],
"structure": "association",
"status": "approuve"
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment