From 1500e8e02ec71f5c7fd8cd7f5661c4f94c839b8e Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Thu, 17 Dec 2020 17:46:19 +0000 Subject: [PATCH] Tidying --- daemon.py | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/daemon.py b/daemon.py index c04f9831a..8a1b15288 100644 --- a/daemon.py +++ b/daemon.py @@ -5591,12 +5591,13 @@ class PubServer(BaseHTTPRequestHandler): print('Newswire item date: ' + dateStr) if newswire.get(dateStr): if isModerator(baseDir, nickname): - print('Voting on newswire item: ' + str(newswire[dateStr])) + newswireItem = newswire[dateStr] + print('Voting on newswire item: ' + str(newswireItem)) votesIndex = 2 filenameIndex = 3 - if 'vote:' + nickname not in newswire[dateStr][votesIndex]: - newswire[dateStr][votesIndex].append('vote:' + nickname) - filename = newswire[dateStr][filenameIndex] + if 'vote:' + nickname not in newswireItem[votesIndex]: + newswireItem[votesIndex].append('vote:' + nickname) + filename = newswireItem[filenameIndex] newswireStateFilename = \ baseDir + '/accounts/.newswirestate.json' try: @@ -5604,7 +5605,7 @@ class PubServer(BaseHTTPRequestHandler): except Exception as e: print('ERROR saving newswire state, ' + str(e)) if filename: - saveJson(newswire[dateStr][votesIndex], + saveJson(newswireItem[votesIndex], filename + '.votes') else: print('No newswire item with date: ' + dateStr + ' ' + @@ -5648,9 +5649,10 @@ class PubServer(BaseHTTPRequestHandler): if isModerator(baseDir, nickname): votesIndex = 2 filenameIndex = 3 - if 'vote:' + nickname in newswire[dateStr][votesIndex]: - newswire[dateStr][votesIndex].remove('vote:' + nickname) - filename = newswire[dateStr][filenameIndex] + newswireItem = newswire[dateStr] + if 'vote:' + nickname in newswireItem[votesIndex]: + newswireItem[votesIndex].remove('vote:' + nickname) + filename = newswireItem[filenameIndex] newswireStateFilename = \ baseDir + '/accounts/.newswirestate.json' try: @@ -5658,7 +5660,7 @@ class PubServer(BaseHTTPRequestHandler): except Exception as e: print('ERROR saving newswire state, ' + str(e)) if filename: - saveJson(newswire[dateStr][votesIndex], + saveJson(newswireItem[votesIndex], filename + '.votes') else: print('No newswire item with date: ' + dateStr + ' ' +