v0.1.3 - add overwrite option

This commit is contained in:
sneakers-the-rat 2023-10-16 14:56:02 -07:00
parent 01b1860e4d
commit 578d889395
3 changed files with 11 additions and 4 deletions

3
docs/changelog.md Normal file
View File

@ -0,0 +1,3 @@
# 0.1.3
- Add overwrite option to append_text in wiki interface

View File

@ -1,6 +1,6 @@
[tool.poetry] [tool.poetry]
name = "wiki-postbot" name = "wiki-postbot"
version = "0.1.2" version = "0.1.3"
description = "Add posts to the wiki!" description = "Add posts to the wiki!"
authors = ["sneakers-the-rat <JLSaunders987@gmail.com>"] authors = ["sneakers-the-rat <JLSaunders987@gmail.com>"]
license = "GPL-3.0" license = "GPL-3.0"

View File

@ -86,7 +86,11 @@ class Wiki:
self.logger.debug(content) self.logger.debug(content)
return WikiPage.from_source(title=content['parse']['title'], source=content['parse']['wikitext']) return WikiPage.from_source(title=content['parse']['title'], source=content['parse']['wikitext'])
def insert_text(self, page, section, text): def insert_text(self, page, section, text, overwrite:bool=False):
if overwrite:
operation_key = 'text'
else:
operation_key = 'appendtext'
# TODO: Move finding section IDs into the page class! # TODO: Move finding section IDs into the page class!
page_text = self.get_page(page) page_text = self.get_page(page)
@ -119,7 +123,7 @@ class Wiki:
"action":"edit", "action":"edit",
"title":page, "title":page,
"section":str(matching_section), "section":str(matching_section),
"appendtext":text, operation_key:text,
"format":"json", "format":"json",
"token":token "token":token
} }
@ -133,7 +137,7 @@ class Wiki:
"title":page, "title":page,
"section":"new", "section":"new",
"sectiontitle":section, "sectiontitle":section,
"appendtext":text, operation_key:text,
"format":"json", "format":"json",
"token":token "token":token
} }