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

Update/reword docstrings

parent 9420eb54
......@@ -27,7 +27,7 @@ class Api:
return self.notifications.get_all()
def get_rendered_notification(self, msgid, media_type, lang):
"""Show notification of one specific by id"""
"""Get rendered notification of specific media type by id"""
self.notifications.delete_invalid_messages()
return self.notifications.get_rendered(msgid, media_type, lang)
......
......@@ -32,7 +32,7 @@ class Notification:
@classmethod
def new(cls, skel, **opts):
"""Generate some mandatory params during creation"""
"""Generate mandatory params during creation and return new instance"""
nid = cls._generate_id()
ts = int(datetime.utcnow().timestamp())
......@@ -42,7 +42,7 @@ class Notification:
@classmethod
def from_file(cls, path):
"""Load notification from it's file"""
"""Load notification from it's file and return new instance"""
try:
with open(path, 'r') as f:
json_data = json.load(f)
......
......@@ -57,7 +57,7 @@ class NotificationSkeleton:
Init jinja environment
Prepare template for later use
For now it will be initiated in when creating new skeleton instance
For now it will be initiated when creating new skeleton instance
"""
template_loader = jinja2.FileSystemLoader(searchpath=self.template_dir)
template_env = jinja2.Environment(loader=template_loader)
......
......@@ -26,8 +26,8 @@ class NotificationStorage:
"""
Store in memory
serializate to disk
render fallback in default languages
Serializate to disk
Render fallback in default languages
"""
self.notifications[n.notif_id] = n
......@@ -45,7 +45,7 @@ class NotificationStorage:
f.write(json_data)
def load(self, storage_dir):
"""Deserialize from FS"""
"""Deserialize all notifications from FS"""
logger.debug("Deserializing notifications from '%s'", storage_dir)
for _, _, files in os.walk(storage_dir):
for f in files:
......@@ -68,7 +68,8 @@ class NotificationStorage:
def get_all(self):
"""Get all notifications as strings"""
return {k: str(v) for k, v in self.notifications.items()}
# TODO: return dict, handle it in api
return self.notifications
def delete_invalid_messages(self):
"""Delete messages based on their timeout"""
......
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