Is now using argparse library
This commit is contained in:
parent
58c5429e5c
commit
7a7f386891
26
poster.py
26
poster.py
@ -6,12 +6,26 @@ from threading import Thread
|
||||
from time import time
|
||||
from traceback import format_exc
|
||||
from pathlib import Path
|
||||
from argparse import ArgumentParser
|
||||
|
||||
from modules.logging import logWrite
|
||||
from modules.utils import configGet, jsonLoad, jsonSave, killProc, locale
|
||||
|
||||
# Args =====================================================================================================================================
|
||||
if "--move-sent" in argv:
|
||||
parser = ArgumentParser(
|
||||
prog = "Telegram Poster",
|
||||
description = "Bot for posting some of your stuff and also receiving submissions."
|
||||
)
|
||||
|
||||
parser.add_argument("-m", "--move-sent", action="store_true")
|
||||
parser.add_argument("-c", "--cleanup", action="store_true")
|
||||
parser.add_argument("--confirm", action="store_true")
|
||||
parser.add_argument("-i", "--cleanup-index", action="store_true")
|
||||
parser.add_argument("-n", "--norun", action="store_true")
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
if args.move_sent:
|
||||
for entry in jsonLoad(configGet("index", "locations"))["sent"]:
|
||||
try:
|
||||
move(configGet("queue", "locations")+sep+entry, configGet("sent", "locations")+sep+entry)
|
||||
@ -21,8 +35,8 @@ if "--move-sent" in argv:
|
||||
logWrite(locale("move_sent_doesnt_exception", "console", locale=configGet("locale")).format(entry, exp))
|
||||
logWrite(locale("move_sent_completed", "console", locale=configGet("locale")))
|
||||
|
||||
if "--cleanup" in argv:
|
||||
if "--confirm" in argv:
|
||||
if args.cleanup:
|
||||
if args.confirm:
|
||||
index = jsonLoad(configGet("index", "locations"))
|
||||
for entry in index["sent"]:
|
||||
try:
|
||||
@ -41,8 +55,8 @@ if "--cleanup" in argv:
|
||||
else:
|
||||
logWrite(locale("cleanup_unathorized", "console", locale=configGet("locale")))
|
||||
|
||||
if "--cleanup-index" in argv:
|
||||
if "--confirm" in argv:
|
||||
if args.cleanup_index:
|
||||
if args.confirm:
|
||||
index = jsonLoad(configGet("index", "locations"))
|
||||
index["sent"] = []
|
||||
jsonSave(index, jsonLoad(configGet("index", "locations")))
|
||||
@ -50,7 +64,7 @@ if "--cleanup-index" in argv:
|
||||
else:
|
||||
logWrite(locale("cleanup_index_unathorized", "console", locale=configGet("locale")))
|
||||
|
||||
if "--norun" in argv:
|
||||
if args.norun:
|
||||
logWrite(locale("passed_norun", "console", locale=configGet("locale")))
|
||||
exit()
|
||||
#===========================================================================================================================================
|
||||
|
Reference in New Issue
Block a user