extract_discord_research/help.py
2020-10-31 21:45:11 +01:00

32 lines
1.1 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import argparse
import json
######################
# INITIALISATION DES #
# VARIABLES #
######################
__author__ = "rick@gnous.eu"
__licence__ = "GLP3 or later"
parser = argparse.ArgumentParser(
description="Permet dentrer des phrases ou des mots qui seront traduient en morse grace à la classe traducteurMorse. Cette traduction sera ensuite convertie en flash lumineux."
)
parser.add_argument('-g', '--getelem', action="store_true", help="Retourne le nombre déléments du fichier json")
parser.add_argument('-u', '--updatejson', action="store_true", help="Met à jour le fichier json avec les nouvelles infos")
args = parser.parse_args()
if args.getelem:
with open("/tmp/file-tmp", 'r') as file:
data = json.load(file)
print(data["total_results"])
exit(0)
elif args.updatejson:
with open("/tmp/file-tmp", 'r') as file:
data = json.load(file)
with open("result.json", 'r+') as file:
oldData = json.load(file)
for messages in data["messages"]:
oldData["messages"].append(messages)
file.seek(0)
json.dump(oldData, file, indent=4)