1
0
Fork 0
extract_discord_research/help.py

33 lines
1.0 KiB
Python
Raw Permalink 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="Outil pour manipuler le fichier JSON des recherches discord"
)
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"])
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)