mirror of
git://git.yoctoproject.org/yocto-autobuilder2.git
synced 2025-07-19 12:49:03 +02:00
wikilog: Ensure empty wiki page is handled correctly for page init
When a wiki page is empty, or only contains a single entry, ensure the code still works and use empty content to initialise it. Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
parent
646ff04e8c
commit
22d8500664
12
lib/wiki.py
12
lib/wiki.py
|
@ -136,11 +136,13 @@ class YPWiki(object):
|
|||
|
||||
parsed = self.parse_json(req)
|
||||
pageid = sorted(parsed['query']['pages'].keys())[-1]
|
||||
content = parsed['query']['pages'][pageid]['revisions'][0]['*']
|
||||
blurb, entries = content.split('==', 1)
|
||||
# ensure we keep only a single newline after the blurb
|
||||
blurb = blurb.strip() + "\n"
|
||||
entries = '=='+entries
|
||||
blurb, entries = "\n", ""
|
||||
if 'revisions' in parsed['query']['pages'][pageid]:
|
||||
content = parsed['query']['pages'][pageid]['revisions'][0]['*']
|
||||
blurb, entries = content.split('==', 1)
|
||||
# ensure we keep only a single newline after the blurb
|
||||
blurb = blurb.strip() + "\n"
|
||||
entries = '=='+entries
|
||||
|
||||
return blurb, entries
|
||||
|
||||
|
|
|
@ -252,9 +252,14 @@ class WikiLog(service.BuildbotService):
|
|||
entry_title = next(it)
|
||||
while entry_title.group(1) != title:
|
||||
entry_title = next(it)
|
||||
next_title = next(it)
|
||||
head = entries[:entry_title.start()]
|
||||
tail = entries[next_title.start():]
|
||||
try:
|
||||
next_title = next(it)
|
||||
tail = entries[next_title.start():]
|
||||
except StopIteration:
|
||||
# There was no following entry
|
||||
tail = ""
|
||||
|
||||
update = head + "==[" + new_title + "]==\n" + new_entry + tail
|
||||
|
||||
cookies = self.wiki.login()
|
||||
|
|
Loading…
Reference in New Issue
Block a user