From a108d34b375c952a341f71b365bcca4f250950af Mon Sep 17 00:00:00 2001 From: frabad Date: Wed, 18 May 2022 18:29:57 +0200 Subject: [PATCH] +commentaires --- LittleBock/add_dates.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/LittleBock/add_dates.py b/LittleBock/add_dates.py index 551ddc5..1078374 100755 --- a/LittleBock/add_dates.py +++ b/LittleBock/add_dates.py @@ -7,6 +7,8 @@ import datetime """ ajoute une valeur de date lisible par un humain à chaque entrée d'un document JSON +TODO: rassembler les dates dans un groupe d'entrées + """ def from_stamp(i: int) -> str: @@ -15,10 +17,9 @@ def from_stamp(i: int) -> str: if len(dt)>10: dt = dt[:10] sdt = str(datetime.datetime.fromtimestamp(int(dt))) - #print(f" {dt} : {sdt}") return sdt -def jsproc(path_in): +def proc(path_in): """traite un document JSON""" _json = None with open(path_in,'r') as f: @@ -30,12 +31,12 @@ def jsproc(path_in): if __name__ == "__main__": here = pathlib.Path.cwd() - jsdocs = tuple(here.rglob("*.json")) - if len(jsdocs) == 0: + docs = tuple(here.rglob("*.json")) + if len(docs) == 0: print("Aucun fichier JSON ('.json') trouvé.") - for i in jsdocs: + for i in docs: if i.exists() and i.stat().st_size > 0: - data = jsproc(i) + data = proc(i) if data: with open(i,'w') as f: f.write(json.dumps(data,