Skip to content

Commit

Permalink
Finished moving commands sub-packages to modules.
Browse files Browse the repository at this point in the history
  • Loading branch information
satoon101 committed Nov 19, 2015
1 parent c2c052e commit 3859391
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 11 deletions.
36 changes: 32 additions & 4 deletions addons/source-python/packages/source-python/commands/client.py
Expand Up @@ -12,10 +12,9 @@
from _commands._client import get_client_command
from _commands._client import register_client_command_filter
from _commands._client import unregister_client_command_filter
from commands.client.command import ClientCommand
from commands.client.filter import ClientCommandFilter
from commands.client.manager import _ClientCommandManager
from commands.client.manager import client_command_manager
from commands.command import _BaseCommand
from commands.filter import _BaseFilter
from commands.player import _PlayerCommandManager


# =============================================================================
Expand All @@ -31,3 +30,32 @@
'register_client_command_filter',
'unregister_client_command_filter',
)


# =============================================================================
# >> CLASSES
# =============================================================================
class _ClientCommandManager(_PlayerCommandManager):
"""Registers client commands and client command filters."""

# Store the base functions
_get_command = staticmethod(get_client_command)
register_filter = staticmethod(register_client_command_filter)
unregister_filter = staticmethod(unregister_client_command_filter)

# The singleton object of the :class:`_ClientCommandManager` class
client_command_manager = _ClientCommandManager()


class ClientCommand(_BaseCommand):
"""Decorator class used to register a client command."""

# Store the class used to (un)register client commands
_manager_class = client_command_manager


class ClientCommandFilter(_BaseFilter):
"""Class used to register a client command filter."""

# Store the class used to (un)register client command filters
_manager_class = client_command_manager
36 changes: 32 additions & 4 deletions addons/source-python/packages/source-python/commands/say.py
Expand Up @@ -12,10 +12,9 @@
from _commands._say import get_say_command
from _commands._say import register_say_filter
from _commands._say import unregister_say_filter
from commands.say.command import SayCommand
from commands.say.filter import SayFilter
from commands.say.manager import _SayCommandManager
from commands.say.manager import say_command_manager
from commands.command import _BaseCommand
from commands.filter import _BaseFilter
from commands.player import _PlayerCommandManager


# =============================================================================
Expand All @@ -31,3 +30,32 @@
'say_command_manager',
'unregister_say_filter',
)


# =============================================================================
# >> CLASSES
# =============================================================================
class _SayCommandManager(_PlayerCommandManager):
"""Manager class used to register say commands and say filters."""

# Store the base functions
_get_command = staticmethod(get_say_command)
register_filter = staticmethod(register_say_filter)
unregister_filter = staticmethod(unregister_say_filter)

# The singleton object of the :class:`_SayCommandManager` class
say_command_manager = _SayCommandManager()


class SayCommand(_BaseCommand):
"""Decorator class used to register a say command."""

# Store the class used to (un)register say commands
_manager_class = say_command_manager


class SayFilter(_BaseFilter):
"""Class used to register a say filter."""

# Store the class used to (un)register say filters
_manager_class = say_command_manager
25 changes: 22 additions & 3 deletions addons/source-python/packages/source-python/commands/server.py
Expand Up @@ -10,9 +10,8 @@
from _commands._server import ServerCommandDispatcher
from _commands._server import ServerCommandGenerator
from _commands._server import get_server_command
from commands.server.command import ServerCommand
from commands.server.manager import _ServerCommandManager
from commands.server.manager import server_command_manager
from commands.command import _BaseCommand
from commands.manager import _BaseCommandManager


# =============================================================================
Expand All @@ -25,3 +24,23 @@
'get_server_command',
'server_command_manager',
)


# =============================================================================
# >> CLASSES
# =============================================================================
class _ServerCommandManager(_BaseCommandManager):
"""Manager class used to register server commands."""

# Store the base functions
_get_command = staticmethod(get_server_command)

# The singleton object of the :class:`_ServerCommandManager` class
server_command_manager = _ServerCommandManager()


class ServerCommand(_BaseCommand):
"""Decorator class used to register a server command."""

# Store the class used to (un)register server commands
_manager_class = server_command_manager

0 comments on commit 3859391

Please sign in to comment.