Commit 067b72c7 authored by Martin Matějek's avatar Martin Matějek

Simplify file loading with glob

parent 1042945a
import glob
import os
import logging
......@@ -52,10 +53,7 @@ class NotificationStorage:
def load(self, storage_dir):
"""Deserialize all notifications from FS"""
logger.debug("Deserializing notifications from '%s'", storage_dir)
for _, _, files in os.walk(storage_dir):
for f in files:
if not f.startswith('.') and f.endswith('.json'):
filepath = os.path.join(storage_dir, f)
for filepath in glob.glob(os.path.join(storage_dir, '*.json')):
n = Notification.from_file(filepath)
if n:
......
import glob
import os
import logging
......@@ -22,16 +23,10 @@ class PluginStorage:
self.load()
def plugin_file_path(self, f):
"""Return full path of plugin file"""
return os.path.join(self.plugin_dir, f)
def load(self):
"""Load plugins from FS"""
for _, _, files in os.walk(self.plugin_dir):
for f in files:
if not f.startswith('.') and f.endswith('.yml'):
p = Plugin.from_file(self.plugin_file_path(f))
for filepath in glob.glob(os.path.join(self.plugin_dir, '*.yml')):
p = Plugin.from_file(filepath)
if p:
self.plugins[p.name] = p
......
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