3
0
mirror of https://github.com/jlu5/PyLink.git synced 2024-12-24 03:33:10 +01:00

Tidy up imports and define __all__ in modules (#660)

This commit is contained in:
Celelibi 2020-06-19 00:47:20 +02:00 committed by GitHub
parent 9470e9329a
commit 84b73bb89f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
29 changed files with 88 additions and 28 deletions

View File

@ -22,9 +22,13 @@ import threading
import time import time
from . import __version__, conf, selectdriver, structures, utils, world from . import __version__, conf, selectdriver, structures, utils, world
from .log import * from .log import log, PyLinkChannelLogger
from .utils import ProtocolError # Compatibility with PyLink 1.x from .utils import ProtocolError # Compatibility with PyLink 1.x
__all__ = ['ChannelState', 'User', 'UserMapping', 'PyLinkNetworkCore',
'PyLinkNetworkCoreWithUtils', 'IRCNetwork', 'Server', 'Channel',
'PUIDGenerator']
QUEUE_FULL = queue.Full QUEUE_FULL = queue.Full

View File

@ -17,6 +17,9 @@ from collections import defaultdict
from . import world from . import world
__all__ = ['ConfigurationError', 'conf', 'confname', 'validate', 'load_conf',
'get_database_name']
class ConfigurationError(RuntimeError): class ConfigurationError(RuntimeError):
"""Error when config conditions aren't met.""" """Error when config conditions aren't met."""

View File

@ -4,13 +4,14 @@ control.py - Implements SHUTDOWN and REHASH functionality.
import atexit import atexit
import os import os
import signal import signal
import sys
import threading import threading
from pylinkirc import conf, utils, world # Do not import classes, it'll import loop from pylinkirc import conf, utils, world # Do not import classes, it'll import loop
from pylinkirc.log import _get_console_log_level, _make_file_logger, _stop_file_loggers, log from pylinkirc.log import _get_console_log_level, _make_file_logger, _stop_file_loggers, log
from . import login, permissions from . import login
__all__ = ['remove_network', 'shutdown', 'rehash']
def remove_network(ircobj): def remove_network(ircobj):

View File

@ -3,13 +3,14 @@ corecommands.py - Implements core PyLink commands.
""" """
import gc import gc
import importlib
import sys import sys
from pylinkirc import conf, utils, world from pylinkirc import utils, world
from pylinkirc.log import log from pylinkirc.log import log
from . import control, login, permissions from . import control, permissions
__all__ = []
# Essential, core commands go here so that the "commands" plugin with less-important, # Essential, core commands go here so that the "commands" plugin with less-important,
# but still generic functions can be reloaded. # but still generic functions can be reloaded.

View File

@ -5,6 +5,8 @@ exttargets.py - Implements extended targets like $account:xyz, $oper, etc.
from pylinkirc import world from pylinkirc import world
from pylinkirc.log import log from pylinkirc.log import log
__all__ = []
def bind(func): def bind(func):
""" """

View File

@ -6,6 +6,8 @@ import time
from pylinkirc import conf, utils from pylinkirc import conf, utils
from pylinkirc.log import log from pylinkirc.log import log
__all__ = []
def handle_whois(irc, source, command, args): def handle_whois(irc, source, command, args):
"""Handle WHOIS queries.""" """Handle WHOIS queries."""

View File

@ -2,9 +2,12 @@
login.py - Implement core login abstraction. login.py - Implement core login abstraction.
""" """
from pylinkirc import conf, utils, world from pylinkirc import conf, utils
from pylinkirc.log import log from pylinkirc.log import log
__all__ = ['pwd_context', 'check_login', 'verify_hash']
# PyLink's global password context # PyLink's global password context
pwd_context = None pwd_context = None

View File

@ -2,12 +2,14 @@
permissions.py - Permissions Abstraction for PyLink IRC Services. permissions.py - Permissions Abstraction for PyLink IRC Services.
""" """
import threading
from collections import defaultdict from collections import defaultdict
from pylinkirc import conf, utils from pylinkirc import conf, utils
from pylinkirc.log import log from pylinkirc.log import log
__all__ = ['default_permissions', 'add_default_permissions',
'remove_default_permissions', 'check_permissions']
# Global variables: these store mappings of hostmasks/exttargets to lists of permissions each target has. # Global variables: these store mappings of hostmasks/exttargets to lists of permissions each target has.
default_permissions = defaultdict(set) default_permissions = defaultdict(set)

View File

@ -5,6 +5,8 @@ service_support.py - Implements handlers for the PyLink ServiceBot API.
from pylinkirc import conf, utils, world from pylinkirc import conf, utils, world
from pylinkirc.log import log from pylinkirc.log import log
__all__ = []
def spawn_service(irc, source, command, args): def spawn_service(irc, source, command, args):
"""Handles new service bot introductions.""" """Handles new service bot introductions."""

2
log.py
View File

@ -12,6 +12,8 @@ import os
from . import conf, world from . import conf, world
__all__ = ['log']
# Stores a list of active file loggers. # Stores a list of active file loggers.
fileloggers = [] fileloggers = []

View File

@ -1,6 +1,6 @@
# antispam.py: Basic services-side spamfilters for IRC # antispam.py: Basic services-side spamfilters for IRC
from pylinkirc import conf, utils, world from pylinkirc import conf, utils
from pylinkirc.log import log from pylinkirc.log import log
mydesc = ("Provides anti-spam functionality.") mydesc = ("Provides anti-spam functionality.")

View File

@ -4,7 +4,6 @@ with things.
""" """
from pylinkirc import utils from pylinkirc import utils
from pylinkirc.coremods import permissions from pylinkirc.coremods import permissions
from pylinkirc.log import log
@utils.add_cmd @utils.add_cmd

View File

@ -5,7 +5,6 @@ import time
from pylinkirc import __version__, conf, real_version, utils, world from pylinkirc import __version__, conf, real_version, utils, world
from pylinkirc.coremods import permissions from pylinkirc.coremods import permissions
from pylinkirc.coremods.login import pwd_context from pylinkirc.coremods.login import pwd_context
from pylinkirc.log import log
default_permissions = {"*!*@*": ['commands.status', 'commands.showuser', 'commands.showchan', 'commands.shownet']} default_permissions = {"*!*@*": ['commands.status', 'commands.showuser', 'commands.showchan', 'commands.shownet']}

View File

@ -1,16 +1,12 @@
""" """
exec.py: Provides commands for executing raw code and debugging PyLink. exec.py: Provides commands for executing raw code and debugging PyLink.
""" """
import importlib
import pprint import pprint
# These imports are not strictly necessary, but make the following modules # These imports are not strictly necessary, but make the following modules
# easier to access through eval and exec. # easier to access through eval and exec.
import re
import threading import threading
import time
import pylinkirc from pylinkirc import utils, world
from pylinkirc import *
from pylinkirc.coremods import permissions from pylinkirc.coremods import permissions
from pylinkirc.log import log from pylinkirc.log import log

View File

@ -4,7 +4,6 @@ games.py: Creates a bot providing a few simple games.
import random import random
from pylinkirc import utils from pylinkirc import utils
from pylinkirc.log import log
mydesc = "The \x02Games\x02 plugin provides simple games for IRC." mydesc = "The \x02Games\x02 plugin provides simple games for IRC."

View File

@ -7,14 +7,17 @@ clientbot.py: Clientbot (regular IRC bot) protocol module for PyLink.
# works on most networks though! # works on most networks though!
import base64 import base64
import string
import threading import threading
import time import time
from pylinkirc import conf, utils from pylinkirc import utils, world
from pylinkirc.classes import * from pylinkirc.classes import *
from pylinkirc.log import log from pylinkirc.log import log
from pylinkirc.protocols.ircs2s_common import * from pylinkirc.protocols.ircs2s_common import *
__all__ = ['ClientbotBaseProtocol', 'ClientbotWrapperProtocol']
FALLBACK_REALNAME = 'PyLink Relay Mirror Client' FALLBACK_REALNAME = 'PyLink Relay Mirror Client'
# IRCv3 capabilities to request when available # IRCv3 capabilities to request when available

View File

@ -4,10 +4,12 @@ hybrid.py: IRCD-Hybrid protocol module for PyLink.
import time import time
from pylinkirc import conf, utils from pylinkirc import conf
from pylinkirc.classes import * from pylinkirc.classes import *
from pylinkirc.log import log from pylinkirc.log import log
from pylinkirc.protocols.ts6 import * from pylinkirc.protocols.ts6 import TS6Protocol
__all__ = ['HybridProtocol']
# This protocol module inherits from the TS6 protocol. # This protocol module inherits from the TS6 protocol.

View File

@ -5,10 +5,12 @@ inspircd.py: InspIRCd 2.0, 3.x protocol module for PyLink.
import threading import threading
import time import time
from pylinkirc import conf, utils from pylinkirc import conf
from pylinkirc.classes import * from pylinkirc.classes import *
from pylinkirc.log import log from pylinkirc.log import log
from pylinkirc.protocols.ts6_common import * from pylinkirc.protocols.ts6_common import TS6BaseProtocol
__all__ = ['InspIRCdProtocol']
class InspIRCdProtocol(TS6BaseProtocol): class InspIRCdProtocol(TS6BaseProtocol):

View File

@ -4,12 +4,13 @@ ircs2s_common.py: Common base protocol class with functions shared by TS6 and P1
import re import re
import time import time
from collections import defaultdict
from pylinkirc import conf, utils from pylinkirc import conf
from pylinkirc.classes import IRCNetwork, ProtocolError from pylinkirc.classes import IRCNetwork, ProtocolError
from pylinkirc.log import log from pylinkirc.log import log
__all__ = ['IncrementalUIDGenerator', 'IRCCommonProtocol', 'IRCS2SProtocol']
class IncrementalUIDGenerator(): class IncrementalUIDGenerator():
""" """

View File

@ -3,7 +3,9 @@ nefarious.py: Migration stub to the new P10 protocol module.
""" """
from pylinkirc.log import log from pylinkirc.log import log
from pylinkirc.protocols.p10 import * from pylinkirc.protocols.p10 import P10Protocol
__all__ = ['NefariousProtocol']
class NefariousProtocol(P10Protocol): class NefariousProtocol(P10Protocol):

View File

@ -15,6 +15,8 @@ from pylinkirc.classes import *
from pylinkirc.log import log from pylinkirc.log import log
from pylinkirc.protocols.ircs2s_common import * from pylinkirc.protocols.ircs2s_common import *
__all__ = ['NgIRCdProtocol']
class NgIRCdProtocol(IRCS2SProtocol): class NgIRCdProtocol(IRCS2SProtocol):
def __init__(self, irc): def __init__(self, irc):

View File

@ -3,6 +3,7 @@ p10.py: P10 protocol module for PyLink, supporting Nefarious IRCu and others.
""" """
import base64 import base64
import socket
import struct import struct
import time import time
from ipaddress import ip_address from ipaddress import ip_address
@ -12,6 +13,8 @@ from pylinkirc.classes import *
from pylinkirc.log import log from pylinkirc.log import log
from pylinkirc.protocols.ircs2s_common import * from pylinkirc.protocols.ircs2s_common import *
__all__ = ['P10Protocol']
class P10UIDGenerator(IncrementalUIDGenerator): class P10UIDGenerator(IncrementalUIDGenerator):
"""Implements an incremental P10 UID Generator.""" """Implements an incremental P10 UID Generator."""

View File

@ -8,7 +8,9 @@ import time
from pylinkirc import conf, utils from pylinkirc import conf, utils
from pylinkirc.classes import * from pylinkirc.classes import *
from pylinkirc.log import log from pylinkirc.log import log
from pylinkirc.protocols.ts6_common import * from pylinkirc.protocols.ts6_common import TS6BaseProtocol
__all__ = ['TS6Protocol']
class TS6Protocol(TS6BaseProtocol): class TS6Protocol(TS6BaseProtocol):

View File

@ -5,11 +5,13 @@ ts6_common.py: Common base protocol class with functions shared by the UnrealIRC
import string import string
import time import time
from pylinkirc import conf, structures, utils from pylinkirc import conf, structures
from pylinkirc.classes import * from pylinkirc.classes import *
from pylinkirc.log import log from pylinkirc.log import log
from pylinkirc.protocols.ircs2s_common import * from pylinkirc.protocols.ircs2s_common import *
__all__ = ['TS6BaseProtocol']
class TS6SIDGenerator(): class TS6SIDGenerator():
""" """

View File

@ -10,7 +10,10 @@ import time
from pylinkirc import conf, utils from pylinkirc import conf, utils
from pylinkirc.classes import * from pylinkirc.classes import *
from pylinkirc.log import log from pylinkirc.log import log
from pylinkirc.protocols.ts6_common import * from pylinkirc.protocols.ts6_common import TS6BaseProtocol
__all__ = ['UnrealProtocol']
SJOIN_PREFIXES = {'q': '*', 'a': '~', 'o': '@', 'h': '%', 'v': '+', 'b': '&', 'e': '"', 'I': "'"} SJOIN_PREFIXES = {'q': '*', 'a': '~', 'o': '@', 'h': '%', 'v': '+', 'b': '&', 'e': '"', 'I': "'"}

View File

@ -9,6 +9,9 @@ import threading
from pylinkirc import world from pylinkirc import world
from pylinkirc.log import log from pylinkirc.log import log
__all__ = ['register', 'unregister', 'start']
SELECT_TIMEOUT = 0.5 SELECT_TIMEOUT = 0.5
selector = selectors.DefaultSelector() selector = selectors.DefaultSelector()

View File

@ -16,6 +16,13 @@ from copy import copy, deepcopy
from . import conf from . import conf
from .log import log from .log import log
__all__ = ['KeyedDefaultdict', 'CopyWrapper', 'CaseInsensitiveFixedSet',
'CaseInsensitiveDict', 'IRCCaseInsensitiveDict',
'CaseInsensitiveSet', 'IRCCaseInsensitiveSet',
'CamelCaseToSnakeCase', 'DataStore', 'JSONDataStore',
'PickleDataStore']
_BLACKLISTED_COPY_TYPES = [] _BLACKLISTED_COPY_TYPES = []
class KeyedDefaultdict(collections.defaultdict): class KeyedDefaultdict(collections.defaultdict):

View File

@ -20,6 +20,15 @@ from pylinkirc import plugins, protocols
from . import conf, structures, world from . import conf, structures, world
from .log import log from .log import log
__all__ = ['PLUGIN_PREFIX', 'PROTOCOL_PREFIX', 'NORMALIZEWHITESPACE_RE',
'NotAuthorizedError', 'InvalidArgumentsError', 'ProtocolError',
'add_cmd', 'add_hook', 'expand_path', 'split_hostmask',
'ServiceBot', 'register_service', 'unregister_service',
'wrap_arguments', 'IRCParser', 'strip_irc_formatting',
'remove_range', 'get_hostname_type', 'parse_duration', 'match_text',
'merge_iterables']
PLUGIN_PREFIX = plugins.__name__ + '.' PLUGIN_PREFIX = plugins.__name__ + '.'
PROTOCOL_PREFIX = protocols.__name__ + '.' PROTOCOL_PREFIX = protocols.__name__ + '.'
NORMALIZEWHITESPACE_RE = re.compile(r'\s+') NORMALIZEWHITESPACE_RE = re.compile(r'\s+')

View File

@ -6,6 +6,10 @@ import threading
import time import time
from collections import defaultdict, deque from collections import defaultdict, deque
__all__ = ['testing', 'hooks', 'networkobjects', 'plugins', 'services',
'exttarget_handlers', 'started', 'start_ts', 'shutting_down',
'source', 'fallback_hostname', 'daemon']
# This indicates whether we're running in tests mode. What it actually does # This indicates whether we're running in tests mode. What it actually does
# though is control whether IRC connections should be threaded or not. # though is control whether IRC connections should be threaded or not.
testing = False testing = False