From ec67f5af61569611f153e3877e844af419357490 Mon Sep 17 00:00:00 2001 From: Laurent Peuch Date: Sun, 19 May 2019 03:17:18 +0200 Subject: [PATCH] [mod] add a main function --- doc/generate_manpages.py | 52 +++++++++++++++++++++------------------- 1 file changed, 28 insertions(+), 24 deletions(-) diff --git a/doc/generate_manpages.py b/doc/generate_manpages.py index a8c40f754..e2fc25787 100644 --- a/doc/generate_manpages.py +++ b/doc/generate_manpages.py @@ -110,29 +110,33 @@ def ordered_yaml_load(stream): return yaml.load(stream, OrderedLoader) -# creates output directory -if not os.path.exists(OUTPUT_DIR): - os.makedirs(OUTPUT_DIR) +def main(): + # creates output directory + if not os.path.exists(OUTPUT_DIR): + os.makedirs(OUTPUT_DIR) + + # man pages of "yunohost *" + with open(ACTIONSMAP_FILE, 'r') as actionsmap: + + # Getting the dictionary containning what actions are possible per domain + actionsmap = ordered_yaml_load(actionsmap) + + for i in actionsmap.keys(): + if i.startswith("_"): + del actionsmap[i] + + today = date.today() + + result = template.render( + month=today.strftime("%B"), + year=today.year, + categories=actionsmap, + str=str, + ) + + with open(os.path.join(OUTPUT_DIR, "yunohost"), "w") as output: + output.write(result) -# man pages of "yunohost *" -with open(ACTIONSMAP_FILE, 'r') as actionsmap: - - # Getting the dictionary containning what actions are possible per domain - actionsmap = ordered_yaml_load(actionsmap) - - for i in actionsmap.keys(): - if i.startswith("_"): - del actionsmap[i] - - today = date.today() - - result = template.render( - month=today.strftime("%B"), - year=today.year, - categories=actionsmap, - str=str, - ) - -with open(os.path.join(OUTPUT_DIR, "yunohost"), "w") as output: - output.write(result) +if __name__ == '__main__': + main()