Commit ac5c1846 authored by Martin Matějek's avatar Martin Matějek

Revert to regular dictionaries

Dict preserve insertion order since python 3.6
From 3.7 it is officially part of language specs
parent 3a07841d
import os
from collections import OrderedDict
from datetime import datetime
from functools import lru_cache
......@@ -24,7 +23,6 @@ class NotificationStorage:
self.load(volatile_dir)
self.load(persistent_dir)
self._sort_notifications(self.notifications)
def store(self, n):
"""
......@@ -64,10 +62,6 @@ class NotificationStorage:
self.notifications[n.notif_id] = n
self.shortid_map[n.notif_id[:self.SHORTID_LENGTH]] = n.notif_id
def _sort_notifications(self, dictionary):
"""Sort notifications after load to maintain time-based order"""
self.notifications = OrderedDict(sorted(dictionary.items(), key=lambda kv: kv[0]))
def valid_id(self, msgid):
"""Check if msgid is valid and message with that id exists"""
if len(msgid) != self.SHORTID_LENGTH and len(msgid) != 32:
......@@ -116,12 +110,12 @@ class NotificationStorage:
def get_all_rendered(self, media_type, lang):
"""Get all notifications rendered in lang and in given media_type"""
od = OrderedDict()
notifications = {}
for msgid in self.notifications.keys():
od[msgid] = self.get_rendered(msgid, media_type, lang)
notifications[msgid] = self.get_rendered(msgid, media_type, lang)
return od
return notifications
def delete_invalid_messages(self):
"""Delete messages based on their timeout"""
......
import os
from collections import OrderedDict
from functools import lru_cache
from .plugin import Plugin
......@@ -90,7 +89,7 @@ class PluginStorage:
notification_args = {}
notification_args['plugin_name'] = plugin_name
skel_actions = OrderedDict()
skel_actions = {}
for action in skeleton['actions']:
if action in plugin_actions:
skel_actions[action] = plugin_actions[action]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment