extract_discord_research/help.py

33 lines
1.0 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

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)