-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Settings overhaul, probably breaks all sorts of things
- Loading branch information
Showing
7 changed files
with
61 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
*.pyc | ||
*.log | ||
*.swp | ||
config.yaml | ||
login.py | ||
run.py | ||
contrib/ | ||
/build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,25 @@ | ||
from spock.utils import pl_announce | ||
from spock.utils import pl_announce, get_settings | ||
from spock.plugins import DefaultPlugins | ||
|
||
#2 values = Attribute&Setting name, default value | ||
#3 values = Attribute name, setting name, default value | ||
default_settings = [ | ||
('plugins', DefaultPlugins), | ||
('plugin_settings', {}), | ||
('mc_username', 'username', 'Bot'), | ||
('mc_password', 'password', ''), | ||
('authenticated', True), | ||
('bufsize', 4096), | ||
('sock_quit', True), | ||
('sess_quit', True), | ||
] | ||
|
||
for index, setting in enumerate(default_settings): | ||
if len(setting) == 2: | ||
default_settings[index] = (setting[0], setting[0], setting[1]) | ||
|
||
class PloaderFetch: | ||
def __init__(self, final_settings): | ||
self.plugins = final_settings['plugins'] | ||
self.plugin_settings = final_settings['plugin_settings'] | ||
def __init__(self, plugins, plugin_settings): | ||
self.plugins = plugins | ||
self.plugin_settings = plugin_settings | ||
|
||
def get_plugins(self): | ||
return self.plugins | ||
|
||
def get_plugin_settings(self, plugin): | ||
return self.plugin_settings.get(plugin, {}) | ||
|
||
@pl_announce('Settings', 'PloaderFetch') | ||
@pl_announce('PloaderFetch') | ||
class SettingsPlugin: | ||
def __init__(self, ploader, kwargs): | ||
settings = kwargs.get('settings', {}) | ||
final_settings = {} | ||
for setting in default_settings: | ||
val = kwargs.get(setting[1], settings.get(setting[1], setting[2])) | ||
final_settings[setting[0]] = val | ||
ploader.provides('PloaderFetch', PloaderFetch(final_settings)) | ||
del final_settings['plugins'] | ||
del final_settings['plugin_settings'] | ||
ploader.provides('Settings', final_settings) | ||
settings = get_settings(kwargs, kwargs.get('settings', {})) | ||
plugin_list = settings.get('plugins', DefaultPlugins) | ||
plugins = [] | ||
plugin_settings = {} | ||
for plugin in plugin_list: | ||
plugins.append(plugin[1]) | ||
plugin_settings[plugin[1]] = settings.get(plugin[0], {}) | ||
ploader.provides('PloaderFetch', PloaderFetch(plugins, plugin_settings)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters