aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFulgen301 <tokmajigeorge@gmailc.om>2017-06-15 11:59:39 +0200
committerFulgen301 <tokmajigeorge@gmail.com>2017-07-11 11:10:32 +0200
commit8973840bd12b86de5ff1b6588b46273b414ef984 (patch)
treea6d89c4d4c04f83df8b40374f0271cd5e34a78e2
parent9f910a0e935204653a23767fd8d22cee200bd417 (diff)
downloadpycrctrl-8973840bd12b86de5ff1b6588b46273b414ef984.tar.gz
pycrctrl-8973840bd12b86de5ff1b6588b46273b414ef984.zip
Remove plugin system; fix config loading
-rw-r--r--pycrctrl/__pycache__/plugin.cpython-36.pycbin1583 -> 0 bytes
-rw-r--r--pycrctrl/__pycache__/pycrctrl.cpython-36.pycbin20510 -> 0 bytes
-rw-r--r--pycrctrl/plugin.py48
-rw-r--r--pycrctrl/pycrctrl.py12
4 files changed, 2 insertions, 58 deletions
diff --git a/pycrctrl/__pycache__/plugin.cpython-36.pyc b/pycrctrl/__pycache__/plugin.cpython-36.pyc
deleted file mode 100644
index 16ed639..0000000
--- a/pycrctrl/__pycache__/plugin.cpython-36.pyc
+++ /dev/null
Binary files differ
diff --git a/pycrctrl/__pycache__/pycrctrl.cpython-36.pyc b/pycrctrl/__pycache__/pycrctrl.cpython-36.pyc
deleted file mode 100644
index 1d536d6..0000000
--- a/pycrctrl/__pycache__/pycrctrl.cpython-36.pyc
+++ /dev/null
Binary files differ
diff --git a/pycrctrl/plugin.py b/pycrctrl/plugin.py
deleted file mode 100644
index d6a43c2..0000000
--- a/pycrctrl/plugin.py
+++ /dev/null
@@ -1,48 +0,0 @@
-import sys
-import os
-import os.path
-import re
-
-import importlib.util
-
-if sys.version_info < (3,6):
- class ModuleNotFoundError(ImportError):
- pass
-
-class PluginError(Exception):
- """There is an error when loading a PyCRCtrl plugin."""
- pass
-
-def loadPlugin(name : str, directories : list):
- """Loads a plugin."""
-
- if not isinstance(directories, list):
- directories = [directories]
-
- found = None
- for dir in directories:
- if found == None:
- if os.path.isdir(os.path.join(dir, name)) or os.path.isfile(os.path.join(dir, ("{}.py".format(name) if name[-3:] != ".py" else name))):
- found = dir
- else:
- raise ImportError("Multiple modules named {} found!".format(name))
-
- if found == None:
- raise ModuleNotFoundError("Cannot find module {}".format(name)) from None
-
- spec = importlib.util.spec_from_file_location(name, os.path.join(dir, name))
-
- module = importlib.util.module_from_spec(spec)
- spec.loader.exec_module(module)
-
- sys.modules[module.__name__] = module
- return module
-
-def loadPluginClass(module):
- try:
- c = module.Class()
-
- except AttributeError:
- raise PluginError("The plugin \"{}\" does not have a Class attribute".format(module.__name__)) from None
-
- return c \ No newline at end of file
diff --git a/pycrctrl/pycrctrl.py b/pycrctrl/pycrctrl.py
index 749989b..09692b9 100644
--- a/pycrctrl/pycrctrl.py
+++ b/pycrctrl/pycrctrl.py
@@ -31,8 +31,6 @@ import json
import base64
import supybot.log
import supybot.ircmsgs as ircmsgs
-from . import plugin
-
from pickle import Pickler, Unpickler
from PyQt5.QtCore import *
from time import sleep
@@ -247,7 +245,6 @@ class PyCRCtrl(object):
_capa_old = {}
updater = None
- plugins = QList()
def __init__(self, irc=None, path=None, config="pycrctrl.conf"):
if sys.platform == "win32":
@@ -263,12 +260,6 @@ class PyCRCtrl(object):
self.queue = queue.Queue(5)
if self.config["Clonk"]["Updater"]["enabled"]:
self.updater = Updater(self)
-
- for p in os.listdir(os.path.join(self.path, "plugins")):
- try:
- self.plugins.append(plugins.loadPluginClass(plugins.loadPlugin(p, dir)))
- except Exception:
- pass
def __ostream__(self, ostream):
return "PyCRCtrl: commandline: {}, channel: {}, scenario: {}".format(self.commandline, self.config["Clonk"]["IRC"]["Channels"]["ingame"], (self.scenario if self.scenario != "" else "None"))
@@ -327,7 +318,8 @@ class PyCRCtrl(object):
return False
elif os.path.isfile(conf):
- self.config = json.load(open(conf, "r"))
+ self.config = self.setupConfig(json.load(open(conf, "r")))
+ return True
elif not os.path.exists(conf):
c = {