[config] Start refactoring by creating separate config class
Add a class that will hold all configuration and argument information and serve as central repository for this kind of information.
This commit is contained in:
parent
df27355977
commit
a58610f3ee
4 changed files with 100 additions and 2 deletions
|
@ -1,3 +1,35 @@
|
|||
import os
|
||||
import pkgutil
|
||||
import importlib
|
||||
|
||||
import bumblebee.modules
|
||||
|
||||
def modules():
|
||||
result = []
|
||||
path = os.path.dirname(bumblebee.modules.__file__)
|
||||
for mod in [ name for _, name, _ in pkgutil.iter_modules([path])]:
|
||||
result.append(ModuleDescription(mod))
|
||||
return result
|
||||
|
||||
class ModuleDescription(object):
|
||||
def __init__(self, name):
|
||||
self._name = name
|
||||
self._mod =importlib.import_module("bumblebee.modules.{}".format(name))
|
||||
|
||||
def name(self):
|
||||
return str(self._name)
|
||||
|
||||
def description(self):
|
||||
return getattr(self._mod, "description", self.na)()
|
||||
|
||||
def usage(self):
|
||||
return getattr(self._mod, "usage", self.na)()
|
||||
|
||||
def notes(self):
|
||||
return getattr(self._mod, "notes", self.na)()
|
||||
|
||||
def na(self):
|
||||
return "n/a"
|
||||
|
||||
class Module(object):
|
||||
def __init__(self, args):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue