1
0
mirror of https://gitlab.crans.org/bde/nk20-scripts synced 2024-12-25 00:42:23 +00:00

Change debug option to "print stdout" / "edit wiki" in the Refresh activities script

This commit is contained in:
Yohann D'ANELLO 2020-09-05 00:45:10 +02:00
parent 2a113d22b9
commit 7246f4d18a

View File

@ -150,30 +150,31 @@ class Command(BaseCommand):
return page, header + body
@staticmethod
def refresh_raw_wiki_page(comment="refresh", debug=True):
def refresh_raw_wiki_page(comment="refresh", print_stdout=False, edit_wiki=False):
page, content = Command.get_raw_page()
if debug:
if print_stdout:
print(content)
else:
if edit_wiki:
Command.edit_wiki(page, content, comment)
@staticmethod
def refresh_human_readable_wiki_page(comment="refresh", debug=True):
def refresh_human_readable_wiki_page(comment="refresh", print_stdout=False, edit_wiki=False):
page, content = Command.get_human_readable_page()
if debug:
if print_stdout:
print(content)
else:
if edit_wiki:
Command.edit_wiki(page, content, comment)
def add_arguments(self, parser):
parser.add_argument("--human", "-H", action="store_true", help="Save human readable page")
parser.add_argument("--raw", "-r", action="store_true", help="Save raw page, for the calendar")
parser.add_argument("--comment", "-c", action="store", type=str, default="", help="Comment of the modification")
parser.add_argument("--debug", "-d", action="store_true", help="Don't commit to the wiki, render in stdout")
parser.add_argument("--stdout", "-o", action="store_true", help="Render the wiki page in stdout")
parser.add_argument("--wiki", "-w", action="store_true", help="Send modifications to the wiki")
def handle(self, *args, **options):
if options["raw"]:
Command.refresh_raw_wiki_page(options["comment"], options["debug"])
Command.refresh_raw_wiki_page(options["comment"], options["stdout"], options["wiki"])
if options["human"]:
Command.refresh_human_readable_wiki_page(options["comment"], options["debug"])
Command.refresh_human_readable_wiki_page(options["comment"], options["stdout"], options["wiki"])