descpage: Implement gnuplot script update
Replace the current wiki script with local variant Issue #1 (#1)
This commit is contained in:
@@ -49,6 +49,9 @@ class DescPageBot(pywikibot.bot.Bot):
|
||||
# Parse filepage
|
||||
self.parse_page()
|
||||
|
||||
# Update gnuplot script
|
||||
self.update_gnuplot_script()
|
||||
|
||||
# Update wiki page
|
||||
self.update_page()
|
||||
|
||||
@@ -90,6 +93,19 @@ class DescPageBot(pywikibot.bot.Bot):
|
||||
"""
|
||||
self.current_page.wikicode = mwparser.parse(self.current_page.text)
|
||||
|
||||
def update_gnuplot_script(self):
|
||||
"""
|
||||
Update the gnuplot script embedded in page
|
||||
"""
|
||||
|
||||
# Get source tag with gnuplot script
|
||||
gnuplot_script = next(
|
||||
self.current_page.wikicode.ifilter_tags(
|
||||
matches="<source lang=\"gnuplot\">" ) )
|
||||
|
||||
# Replace script
|
||||
gnuplot_script.contents = "\n" + self.prepare_gnuplot_script() + "\n"
|
||||
|
||||
def update_page(self):
|
||||
"""
|
||||
Put updated content to wiki
|
||||
|
||||
Reference in New Issue
Block a user