Browse Source

descpage: Implement inserting helptext in code

Add helping comments to beginning of gnuplot scripts explaining data
source

Issue #1 (https://git.golderweb.de/wiki/jogobot-euroexchange/issues/1)
Jonathan Golder 4 months ago
parent
commit
6572a89085
2 changed files with 9 additions and 0 deletions
  1. 1
    0
      euroexchange/config.py
  2. 8
    0
      euroexchange/descpage.py

+ 1
- 0
euroexchange/config.py View File

@@ -44,3 +44,4 @@ class Config():
44 44
     csv_file = jogobot.config["euroexchange"]["data_csv_filename"]
45 45
     upload_comment = jogobot.config["euroexchange"]["upload_comment"]
46 46
     gnuplot_script_comment = jogobot.config["euroexchange"]["gnuplot_script_comment"]
47
+    gnuplot_script_help = jogobot.config["euroexchange"]["gnuplot_script_help"]

+ 8
- 0
euroexchange/descpage.py View File

@@ -23,6 +23,7 @@
23 23
 #
24 24
 
25 25
 import os
26
+import re
26 27
 
27 28
 import pywikibot
28 29
 import mwparserfromhell as mwparser
@@ -85,6 +86,13 @@ class DescPageBot(pywikibot.bot.Bot):
85 86
             replace( "system(\"echo $OUTFILE\")",
86 87
                       "'{}'".format (os.path.basename( self.job.image ) ) )
87 88
 
89
+        # Locate first empty line
90
+        m = re.search(r"^\s*$", gnuplot_script, re.MULTILINE)
91
+        if m:
92
+            # Insert help lines
93
+            gnuplot_script = gnuplot_script[:m.end()] +\
94
+                Config.gnuplot_script_help + gnuplot_script[m.end():]
95
+
88 96
         return gnuplot_script
89 97
 
90 98
     def parse_page(self):