+commentaires
This commit is contained in:
parent
4ab903cbd9
commit
a108d34b37
@ -7,6 +7,8 @@ import datetime
|
|||||||
"""
|
"""
|
||||||
ajoute une valeur de date lisible par un humain à chaque entrée d'un document JSON
|
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:
|
def from_stamp(i: int) -> str:
|
||||||
@ -15,10 +17,9 @@ def from_stamp(i: int) -> str:
|
|||||||
if len(dt)>10:
|
if len(dt)>10:
|
||||||
dt = dt[:10]
|
dt = dt[:10]
|
||||||
sdt = str(datetime.datetime.fromtimestamp(int(dt)))
|
sdt = str(datetime.datetime.fromtimestamp(int(dt)))
|
||||||
#print(f" {dt} : {sdt}")
|
|
||||||
return sdt
|
return sdt
|
||||||
|
|
||||||
def jsproc(path_in):
|
def proc(path_in):
|
||||||
"""traite un document JSON"""
|
"""traite un document JSON"""
|
||||||
_json = None
|
_json = None
|
||||||
with open(path_in,'r') as f:
|
with open(path_in,'r') as f:
|
||||||
@ -30,12 +31,12 @@ def jsproc(path_in):
|
|||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
here = pathlib.Path.cwd()
|
here = pathlib.Path.cwd()
|
||||||
jsdocs = tuple(here.rglob("*.json"))
|
docs = tuple(here.rglob("*.json"))
|
||||||
if len(jsdocs) == 0:
|
if len(docs) == 0:
|
||||||
print("Aucun fichier JSON ('.json') trouvé.")
|
print("Aucun fichier JSON ('.json') trouvé.")
|
||||||
for i in jsdocs:
|
for i in docs:
|
||||||
if i.exists() and i.stat().st_size > 0:
|
if i.exists() and i.stat().st_size > 0:
|
||||||
data = jsproc(i)
|
data = proc(i)
|
||||||
if data:
|
if data:
|
||||||
with open(i,'w') as f:
|
with open(i,'w') as f:
|
||||||
f.write(json.dumps(data,
|
f.write(json.dumps(data,
|
||||||
|
Loading…
Reference in New Issue
Block a user