Support plugins with __init__.py files.
authorCMDR furrycat <elite@furrycat.net>
Thu, 6 Apr 2017 09:43:13 +0000 (10:43 +0100)
committerCMDR furrycat <elite@furrycat.net>
Mon, 10 Apr 2017 13:33:51 +0000 (14:33 +0100)
plugins.py

index 3071384..6da6f3c 100644 (file)
@@ -28,12 +28,18 @@ class Plugins(object):
     self.log_level(level)
 
   def refresh(self):
-    for py in glob.glob('plugin/*/*.py'):
+    seen = []
+    for py in glob.glob('plugin/*/__init__.py') + glob.glob('plugin/*/*.py'):
       path = py.split('.py')[0]
       plugin = os.path.basename(path)
       name = os.path.basename(os.path.dirname(py))
+      if name in seen:
+        continue
+      if plugin == '__init__':
+        plugin = name
       if name != plugin:
         continue
+      seen.append(name)
       lib = path.replace('/', '.')
       plugin = plugin[0].upper() + plugin[1:]
       try: