Completed
Pull Request — master (#13)
by Jeffrey
03:21
created

get_plugins()   A

Complexity

Conditions 4

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 4
c 1
b 0
f 0
dl 0
loc 10
rs 9.2
1
# These imports are for python3 compatability inside python2
2
from __future__ import absolute_import
3
from __future__ import division
4
from __future__ import print_function
5
6
import importlib
7
import os
8
9
__author__ = 'Jeffrey Phillips Freeman (WI2ARD)'
10
__maintainer__ = 'Jeffrey Phillips Freeman (WI2ARD)'
11
__email__ = '[email protected]'
12
__license__ = 'Apache License, Version 2.0'
13
__copyright__ = 'Copyright 2016, Syncleus, Inc. and contributors'
14
__credits__ = []
15
16
PluginFolder = './plugins'
17
MainModule = '__init__'
18
19
20
def get_plugins():
21
    plugins = []
22
    possible_plugins = os.listdir(PluginFolder)
23
    for i in possible_plugins:
24
        location = os.path.join(PluginFolder, i)
25
        if not os.path.isdir(location) or not MainModule + '.py' in os.listdir(location):
26
            continue
27
28
        plugins.append(i)
29
    return plugins
30
31
32
def load_plugin(plugin):
33
    return importlib.import_module('plugins.' + plugin)
34