Beispiel #1
0
 def _create_public_convar(self):
     """Create a public convar if :attr:`public_convar` is set to True."""
     name = '{}_version'.format(self.name)
     description = '{} version.'.format(self.verbose_name)
     if self.public_convar is True:
         self.public_convar = PublicConVar(name, self.version, description)
     elif isinstance(self.public_convar, dict):
         self.public_convar = PublicConVar(
             self.public_convar.pop('name', name),
             self.public_convar.pop('value', self.version),
             self.public_convar.pop('description', description),
             **self.public_convar)
 def _create_public_convar(self):
     """Create a public convar if :attr:`public_convar` is set to True."""
     name = '{}_version'.format(self.name)
     description = '{} version.'.format(self.verbose_name)
     if self.public_convar is True:
         self.public_convar = PublicConVar(
             name,
             self.version,
             description
         )
     elif isinstance(self.public_convar, dict):
         self.public_convar = PublicConVar(
             self.public_convar.pop('name', name),
             self.public_convar.pop('value', self.version),
             self.public_convar.pop('description', description),
             **self.public_convar)
from translations.strings import LangStrings

# =============================================================================
# >> PLUGIN INFO
# =============================================================================
info = PluginInfo("simple_teleport")
info.basename = "simple_teleport"
info.name = "Simple Teleport"
info.description = "Easily teleport players"
info.author = "Kill, iPlayer"
info.version = "1.0"
info.url = "https://steamcommunity.com/id/killtmwc | " \
           "https://steamcommunity.com/id/its_iPlayer"

PublicConVar(name=info.basename + "_version",
             value=info.version,
             description=info.description)

# =============================================================================
# >> CONSTANTS
# =============================================================================
STUCK_RELEASE_TIMEOUT = 4.0
VEC_P2P_OFFSET = Vector(0, 0, 80)

# =============================================================================
# >> GLOBAL VARIABLES
# =============================================================================
saved_locs = PlayerDictionary(lambda index: None)
selected_p2p_first = PlayerDictionary(lambda index: None)

# =============================================================================
Beispiel #4
0
# =============================================================================
# >> CONSTANTS
# =============================================================================
#: Version of the Source.Python intallation.
VERSION = None

#: The Github commit this Source.Python version was built with.
GIT_COMMIT = None

LAST_SUCCESSFUL_BUILD_NUMBER_URL = (
    'http://downloads.sourcepython.com/version.txt')

# =============================================================================
# >> GLOBAL VARIABLES
# =============================================================================
_sp_version = PublicConVar('sp_version', str(VERSION), 'Source.Python version')


# =============================================================================
# >> FUNCTIONS
# =============================================================================
def get_last_successful_build_number(timeout=3):
    """Return the latest successful build number as an integer.

    :param float timeout:
        Number of seconds that need to pass until a timeout occurs.
    :rtype: int
    """
    with urlopen(LAST_SUCCESSFUL_BUILD_NUMBER_URL, timeout=timeout) as url:
        return int(url.read().decode('utf-8'))
Beispiel #5
0
from cvars.public import PublicConVar
from plugins.info import PluginInfo


info = PluginInfo()
info.name = "LimitZones (Editor)"
info.basename = 'limit_zones_editor'
info.author = 'Kirill "iPlayer" Mysnik'
info.version = '1.0'
info.variable = '{}_version'.format(info.basename)
info.convar = PublicConVar(
    info.variable, info.version, "{} version".format(info.name))

info.url = "https://github.com/KirillMysnik/SP-LimitZones"
Beispiel #6
0
class PluginInfo(dict):
    """Store information for a plugin."""
    def __init__(self,
                 name,
                 verbose_name=None,
                 author=None,
                 description=None,
                 version=None,
                 url=None,
                 permissions=None,
                 public_convar=True,
                 display_in_listing=None,
                 **kwargs):
        """Initialize the instance.

        :param str name:
            Name of the plugin on the file system.
        :param str verbose_name:
            A verbose name for the plugin (e.g. GunGame).
        :param str author:
            Name of the author.
        :param str description:
            A short description of what the plugin does.
        :param str version:
            Current version of the plugin.
        :param str url:
            A link to a thread in the 'Plugin Releases' forum section or the
            plugin's SPPM link.
        :param list permissions:
            A list of permissions defined or used by the plugin. The list
            should contain tuples that define the permission and a short
            description of the permission.
        :param public_convar:
            If set to ``True``, a public convar will be generated based on the
            plugin name, verbose name and version. Set it to ``False`` if you
            don't want a public convar or set it to a dictionary containing
            the parameters to create a :class:`cvars.public.PublicConvar`
            instance.
        :param list display_in_listing:
            A list that contains custom attributes that should appear in the
            plugin listing (e.g. sp plugin list).
        :param kwargs:
            Any additional attributes you want to set. If you want those
            attributes to appear in the plugin listing, update
            :attr:`display_in_listing`.
        """
        super().__init__(**kwargs)
        self.name = name
        self._verbose_name = verbose_name
        self.author = author
        self.description = description
        self._version = version
        self.url = url

        # All permissions defined by this plugin
        # A list that contains tuples:
        # Example:
        # [('test1.kick', 'Permission to kick players.'),
        #  ('test1.ban', 'Permission to ban players.'),
        #  ('test1.start_vote', 'Permission to start a vote.')]
        self.permissions = [] if permissions is None else permissions
        self.public_convar = public_convar

        self.display_in_listing = [] if display_in_listing is None else display_in_listing

    def _create_public_convar(self):
        """Create a public convar if :attr:`public_convar` is set to True."""
        name = '{}_version'.format(self.name)
        description = '{} version.'.format(self.verbose_name)
        if self.public_convar is True:
            self.public_convar = PublicConVar(name, self.version, description)
        elif isinstance(self.public_convar, dict):
            self.public_convar = PublicConVar(
                self.public_convar.pop('name', name),
                self.public_convar.pop('value', self.version),
                self.public_convar.pop('description', description),
                **self.public_convar)

    def get_verbose_name(self):
        """Return the verbose name of the plugin.

        If no verbose name has been set, the plugin name will be titled.

        :rtype: str
        """
        if self._verbose_name is None:
            return self.name.replace('_', ' ').title()

        return self._verbose_name

    def set_verbose_name(self, value):
        """Set the verbose name of the plugin."""
        self._verbose_name = value

    verbose_name = property(get_verbose_name, set_verbose_name)

    def get_version(self):
        """Return the plugin's version.

        :rtype: str
        """
        if self._version is None:
            return 'unversioned'

        return self._version

    def set_version(self, value):
        """Set the plugin's version."""
        self._version = value

    version = property(get_version, set_version)

    # Redirect __getitem__ and __setitem__ to __getattr__ and __setattr__
    __getattr__ = dict.__getitem__
    __setattr__ = dict.__setitem__
Beispiel #7
0
# ../cut_wire/info.py
"""Provides/stores information about the plugin."""

# =============================================================================
# >> IMPORTS
# =============================================================================
# Source.Python Imports
#   Cvars
from cvars.public import PublicConVar
#   Plugins
from plugins.info import PluginInfo

# =============================================================================
# >> PLUGIN INFO
# =============================================================================
info = PluginInfo()
info.name = 'Cut Wire'
info.author = 'Satoon101'
info.version = '1.1'
info.basename = 'cut_wire'
info.variable = info.basename + '_version'
info.url = 'http://forums.sourcepython.com/showthread.php?779'
info.convar = PublicConVar(info.variable, info.version, 0,
                           info.name + ' Version')
class PluginInfo(dict):
    """Store information for a plugin."""

    def __init__(self, name, verbose_name=None, author=None, description=None,
            version=None, url=None, permissions=None, public_convar=True,
            display_in_listing=None, **kwargs):
        """Initialize the instance.

        :param str name:
            Name of the plugin on the file system.
        :param str verbose_name:
            A verbose name for the plugin (e.g. GunGame).
        :param str author:
            Name of the author.
        :param str description:
            A short description of what the plugin does.
        :param str version:
            Current version of the plugin.
        :param str url:
            A link to a thread in the 'Plugin Releases' forum section or the
            plugin's SPPM link.
        :param list permissions:
            A list of permissions defined or used by the plugin. The list
            should contain tuples that define the permission and a short
            description of the permission.
        :param public_convar:
            If set to ``True``, a public convar will be generated based on the
            plugin name, verbose name and version. Set it to ``False`` if you
            don't want a public convar or set it to a dictionary containing
            the parameters to create a :class:`cvars.public.PublicConvar`
            instance.
        :param list display_in_listing:
            A list that contains custom attributes that should appear in the
            plugin listing (e.g. sp plugin list).
        :param kwargs:
            Any additional attributes you want to set. If you want those
            attributes to appear in the plugin listing, update
            :attr:`display_in_listing`.
        """
        super().__init__(**kwargs)
        self.name = name
        self._verbose_name = verbose_name
        self.author = author
        self.description = description
        self._version = version
        self.url = url

        # All permissions defined by this plugin
        # A list that contains tuples:
        # Example:
        # [('test1.kick', 'Permission to kick players.'),
        #  ('test1.ban', 'Permission to ban players.'),
        #  ('test1.start_vote', 'Permission to start a vote.')]
        self.permissions = [] if permissions is None else permissions
        self.public_convar = public_convar

        self.display_in_listing = [] if display_in_listing is None else display_in_listing

    def _create_public_convar(self):
        """Create a public convar if :attr:`public_convar` is set to True."""
        name = '{}_version'.format(self.name)
        description = '{} version.'.format(self.verbose_name)
        if self.public_convar is True:
            self.public_convar = PublicConVar(
                name,
                self.version,
                description
            )
        elif isinstance(self.public_convar, dict):
            self.public_convar = PublicConVar(
                self.public_convar.pop('name', name),
                self.public_convar.pop('value', self.version),
                self.public_convar.pop('description', description),
                **self.public_convar)

    def get_verbose_name(self):
        """Return the verbose name of the plugin.

        If no verbose name has been set, the plugin name will be titled.

        :rtype: str
        """
        if self._verbose_name is None:
            return self.name.replace('_', ' ').title()

        return self._verbose_name

    def set_verbose_name(self, value):
        """Set the verbose name of the plugin."""
        self._verbose_name = value

    verbose_name = property(get_verbose_name, set_verbose_name)

    def get_version(self):
        """Return the plugin's version.

        :rtype: str
        """
        if self._version is None:
            return 'unversioned'

        return self._version

    def set_version(self, value):
        """Set the plugin's version."""
        self._version = value

    version = property(get_version, set_version)

    # Redirect __getitem__ and __setitem__ to __getattr__ and __setattr__
    __getattr__ = dict.__getitem__
    __setattr__ = dict.__setitem__
import os

from glob import glob

from cvars.public import PublicConVar
from plugins.info import PluginInfo

from . import bans, commands
from .utils import utils

info = PluginInfo()
info.name = "Admin Commands"
info.author = "necavi"
info.version = "0.1"
info.basename = "admin_commands"
info.variable = info.basename + "_version"
info.convar = PublicConVar(info.variable, info.version, info.name + " Version")

cwd = os.getcwd()
os.chdir(os.path.dirname(os.path.abspath(__file__)))
for module in glob("commands/*.py"):
    name = "admin_commands.commands." + os.path.splitext(
        os.path.basename(module))[0]
    loader = importlib.machinery.SourceFileLoader(name, module)
    loader.load_module(name)
os.chdir(cwd)


def unload():
    utils.unload()