Skip to content

Plugin info update #176

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Jan 12, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Added class attribute defaults for prefix, instance, translations, an…
…d logger.

Removed unused description argument for SubCommandManager.
  • Loading branch information
satoon101 committed Dec 11, 2016
commit 5ae678d242562ae8b3cd15f9fd407078db43a848
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
from core import core_logger
from core.manager import core_plugin_manager
from core.version import VERSION
# Cvars
from cvars import ConVar
# Engines
from engines.server import execute_server_command
from engines.server import queue_command_string
Expand Down Expand Up @@ -139,7 +137,7 @@ def print_credits(self):
self._log_message(message + '=' * 61 + '\n\n')

# Get the _CoreCommandManager instance
_core_command = _CoreCommandManager('sp', 'Source.Python base command.')
_core_command = _CoreCommandManager('sp')


# =============================================================================
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class SubCommandManager(AutoUnload, list):
logger = plugins_command_logger
translations = _plugin_strings

def __init__(self, command, description='', prefix=''):
def __init__(self, command, prefix=''):
"""Called on instance initialization."""
# Re-call OrderedDict's __init__ to properly setup the object
super().__init__()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,15 @@
class LoadedPlugin(object):
"""Stores a plugin's instance."""

logger = None
translations = None
prefix = None

def __init__(self, plugin_name, base_import):
"""Called when a plugin's instance is initialized."""
self.file_path = None
self.import_name = None
self.globals = None
self.translations = None
self.base_import = base_import
self.plugin_name = plugin_name

Expand Down
11 changes: 7 additions & 4 deletions addons/source-python/packages/source-python/plugins/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@
class PluginManager(OrderedDict):
"""Stores plugins and their instances."""

instance = None
prefix = None

def __init__(self, base_import=''):
"""Called when the class instance is initialized."""
# Re-call OrderedDict's __init__ to properly setup the object
Expand Down Expand Up @@ -156,21 +159,21 @@ def __delitem__(self, plugin_name):
@property
def base_import(self):
"""Return the base import path for the manager.

:rtype: str
"""
return self._base_import

def is_loaded(self, plugin_name):
"""Return whether or not a plugin is loaded.

:rtype: bool
"""
return plugin_name in self

def get_plugin_instance(self, plugin_name):
"""Return a plugin's instance, if it is loaded.

:rtype: LoadedPlugin
"""
# Is the plugin loaded?
Expand Down Expand Up @@ -212,7 +215,7 @@ def _remove_modules(self, plugin_name):
@staticmethod
def _is_related_module(base_name, module):
"""Check if a plugin's base name is related to a module name.

:rtype: bool
"""
return (module.startswith('{}.'.format(base_name))
Expand Down