3
0
mirror of https://github.com/jlu5/PyLink.git synced 2024-11-27 04:59:24 +01:00

Sort imports via isort

This commit is contained in:
James Lu 2019-07-14 15:12:29 -07:00
parent 19d794a6f5
commit 80188c3673
47 changed files with 141 additions and 114 deletions

2
.isort.cfg Normal file
View File

@ -0,0 +1,2 @@
[settings]
line_length=100

View File

@ -7,25 +7,27 @@ connections and objects used to represent IRC servers, users, and channels.
Here be dragons.
"""
import threading
import time
import socket
import ssl
import collections
import collections.abc
import functools
import hashlib
import ipaddress
import queue
QUEUE_FULL = queue.Full
import functools
import string
import re
import collections
import collections.abc
import socket
import ssl
import string
import textwrap
import threading
import time
from . import world, utils, structures, conf, __version__, selectdriver
from . import __version__, conf, selectdriver, structures, utils, world
from .log import *
from .utils import ProtocolError # Compatibility with PyLink 1.x
QUEUE_FULL = queue.Full
### Internal classes (users, servers, channels)
class ChannelState(structures.IRCCaseInsensitiveDict):

View File

@ -10,13 +10,14 @@ try:
except ImportError:
raise ImportError("PyLink requires PyYAML to function; please install it and try again.")
import sys
import os.path
import logging
import os.path
import sys
from collections import defaultdict
from . import world
class ConfigurationError(RuntimeError):
"""Error when config conditions aren't met."""

View File

@ -1,15 +1,17 @@
"""
control.py - Implements SHUTDOWN and REHASH functionality.
"""
import signal
import os
import threading
import sys
import atexit
import os
import signal
import sys
import threading
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 . import login, permissions
from pylinkirc import world, utils, conf # Do not import classes, it'll import loop
from pylinkirc.log import log, _make_file_logger, _stop_file_loggers, _get_console_log_level
from . import permissions, login
def remove_network(ircobj):
"""Removes a network object from the pool."""

View File

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

View File

@ -5,6 +5,7 @@ exttargets.py - Implements extended targets like $account:xyz, $oper, etc.
from pylinkirc import world
from pylinkirc.log import log
def bind(func):
"""
Binds an exttarget with the given name.

View File

@ -3,9 +3,10 @@ handlers.py - Implements miscellaneous IRC command handlers (WHOIS, services log
"""
import time
from pylinkirc import utils, conf
from pylinkirc import conf, utils
from pylinkirc.log import log
def handle_whois(irc, source, command, args):
"""Handle WHOIS queries."""
target = args['target']

View File

@ -2,14 +2,15 @@
permissions.py - Permissions Abstraction for PyLink IRC Services.
"""
from collections import defaultdict
import threading
from collections import defaultdict
from pylinkirc import conf, utils
from pylinkirc.log import log
# Global variables: these store mappings of hostmasks/exttargets to lists of permissions each target has.
default_permissions = defaultdict(set)
from pylinkirc import conf, utils
from pylinkirc.log import log
def add_default_permissions(perms):
"""Adds default permissions to the index."""

View File

@ -2,9 +2,10 @@
service_support.py - Implements handlers for the PyLink ServiceBot API.
"""
from pylinkirc import utils, world, conf
from pylinkirc import conf, utils, world
from pylinkirc.log import log
def spawn_service(irc, source, command, args):
"""Handles new service bot introductions."""

View File

@ -3,9 +3,9 @@
Generates HTML versions of the mode list .csv definitions.
"""
import csv
import os
import os.path
import csv
os.chdir(os.path.dirname(__file__))

View File

@ -4,10 +4,11 @@ PyLink IRC Services launcher.
"""
import os
import sys
import signal
import sys
import time
from pylinkirc import world, conf, __version__, real_version
from pylinkirc import __version__, conf, real_version, world
try:
import psutil

3
log.py
View File

@ -10,7 +10,7 @@ import logging
import logging.handlers
import os
from . import world, conf
from . import conf, world
# Stores a list of active file loggers.
fileloggers = []
@ -153,4 +153,3 @@ class PyLinkChannelLogger(logging.Handler):
return
else:
self.called = False

View File

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

View File

@ -4,9 +4,9 @@ hostmasks or exttargets.
"""
import collections
from pylinkirc import utils, conf, world, structures
from pylinkirc.log import log
from pylinkirc import conf, structures, utils, world
from pylinkirc.coremods import permissions
from pylinkirc.log import log
mydesc = ("The \x02Automode\x02 plugin provides simple channel ACL management by giving prefix modes "
"to users matching hostmasks or exttargets.")

View File

@ -3,8 +3,9 @@ bots.py: Spawn virtual users/bots on a PyLink server and make them interact
with things.
"""
from pylinkirc import utils
from pylinkirc.log import log
from pylinkirc.coremods import permissions
from pylinkirc.log import log
@utils.add_cmd
def spawnclient(irc, source, args):

View File

@ -1,12 +1,12 @@
"""
Changehost plugin - automatically changes the hostname of matching users.
"""
from pylinkirc import utils, world, conf
from pylinkirc.log import log
from pylinkirc.coremods import permissions
import string
from pylinkirc import conf, utils, world
from pylinkirc.coremods import permissions
from pylinkirc.log import log
# Characters allowed in a hostname.
allowed_chars = string.ascii_letters + '-./:' + string.digits

View File

@ -1,11 +1,10 @@
# commands.py: base PyLink commands
import time
from pylinkirc import conf, utils, __version__, world, real_version
from pylinkirc.log import log
from pylinkirc import __version__, conf, real_version, utils, world
from pylinkirc.coremods import permissions
from pylinkirc.coremods.login import pwd_context
from pylinkirc.log import log
default_permissions = {"*!*@*": ['commands.status', 'commands.showuser', 'commands.showchan', 'commands.shownet']}

View File

@ -1,10 +1,11 @@
# ctcp.py: Handles basic CTCP requests.
import random
import datetime
import random
from pylinkirc import utils
from pylinkirc.log import log
def handle_ctcp(irc, source, command, args):
"""
CTCP event handler.

View File

@ -1,9 +1,9 @@
# example.py: An example PyLink plugin.
import random
from pylinkirc import utils
from pylinkirc.log import log
import random
# Example PRIVMSG hook that returns "hi there!" when PyLink's nick is mentioned
# in a channel.

View File

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

View File

@ -1,7 +1,8 @@
# fantasy.py: Adds FANTASY command support, to allow calling commands in channels
from pylinkirc import utils, world, conf
from pylinkirc import conf, utils, world
from pylinkirc.log import log
def handle_fantasy(irc, source, command, args):
"""Fantasy command handler."""

View File

@ -3,8 +3,8 @@
import string
from pylinkirc import conf, utils, world
from pylinkirc.log import log
from pylinkirc.coremods import permissions
from pylinkirc.log import log
DEFAULT_FORMAT = "[$sender@$fullnetwork] $text"

View File

@ -1,12 +1,12 @@
"""Networks plugin - allows you to manipulate connections to various configured networks."""
import importlib
import types
import threading
import types
import pylinkirc
from pylinkirc import utils, world
from pylinkirc.log import log
from pylinkirc.coremods import control, permissions
from pylinkirc.log import log
REMOTE_IN_USE = threading.Event()

View File

@ -4,8 +4,8 @@ opercmds.py: Provides a subset of network management commands.
import argparse
from pylinkirc import utils, world
from pylinkirc.log import log
from pylinkirc.coremods import permissions
from pylinkirc.log import log
# Having a hard limit here is sensible because otherwise it can flood the client or server off.
CHECKBAN_MAX_RESULTS = 200

View File

@ -1,9 +1,10 @@
"""
raw.py: Provides a 'raw' command for sending raw text to IRC.
"""
from pylinkirc.log import log
from pylinkirc.coremods import permissions
from pylinkirc import utils
from pylinkirc.coremods import permissions
from pylinkirc.log import log
@utils.add_cmd
def raw(irc, source, args):

View File

@ -1,14 +1,14 @@
# relay.py: PyLink Relay plugin
import time
import threading
import string
from collections import defaultdict
import inspect
import base64
import inspect
import string
import threading
import time
from collections import defaultdict
from pylinkirc import utils, world, conf, structures
from pylinkirc.log import log
from pylinkirc import conf, structures, utils, world
from pylinkirc.coremods import permissions
from pylinkirc.log import log
CHANNEL_DELINKED_MSG = "Channel delinked."
RELAY_UNLOADED_MSG = "Relay plugin unloaded."

View File

@ -1,9 +1,9 @@
# relay_clientbot.py: Clientbot extensions for Relay
import shlex
import string
import time
import shlex
from pylinkirc import utils, conf, world
from pylinkirc import conf, utils, world
from pylinkirc.log import log
# Clientbot default styles:

View File

@ -1,11 +1,11 @@
# servermaps.py: Maps out connected IRC servers.
from pylinkirc import utils, world
from pylinkirc.log import log
from pylinkirc.coremods import permissions
import collections
from pylinkirc import utils, world
from pylinkirc.coremods import permissions
from pylinkirc.log import log
DEFAULT_PERMISSIONS = {"$ircop": ['servermaps.localmap']}
def main(irc=None):

View File

@ -2,7 +2,7 @@
import threading
from pylinkirc import utils, conf
from pylinkirc import conf, utils
from pylinkirc.log import log
try:

View File

@ -1,12 +1,13 @@
"""
stats.py: Simple statistics for PyLink IRC Services.
"""
import time
import datetime
import time
from pylinkirc import utils, world, conf
from pylinkirc.log import log
from pylinkirc import conf, utils, world
from pylinkirc.coremods import permissions
from pylinkirc.log import log
def timediff(before, now):
"""

View File

@ -6,14 +6,14 @@ clientbot.py: Clientbot (regular IRC bot) protocol module for PyLink.
# that a regular server would have (e.g. spawning virtual users for things like Relay). Somehow it
# works on most networks though!
import time
import threading
import base64
import threading
import time
from pylinkirc import utils, conf
from pylinkirc import conf, utils
from pylinkirc.classes import *
from pylinkirc.log import log
from pylinkirc.protocols.ircs2s_common import *
from pylinkirc.classes import *
FALLBACK_REALNAME = 'PyLink Relay Mirror Client'

View File

@ -4,11 +4,12 @@ hybrid.py: IRCD-Hybrid protocol module for PyLink.
import time
from pylinkirc import utils, conf
from pylinkirc.log import log
from pylinkirc import conf, utils
from pylinkirc.classes import *
from pylinkirc.log import log
from pylinkirc.protocols.ts6 import *
# This protocol module inherits from the TS6 protocol.
class HybridProtocol(TS6Protocol):
def __init__(self, *args, **kwargs):

View File

@ -2,14 +2,15 @@
inspircd.py: InspIRCd 2.0, 3.0 protocol module for PyLink.
"""
import time
import threading
import time
from pylinkirc import utils, conf
from pylinkirc import conf, utils
from pylinkirc.classes import *
from pylinkirc.log import log
from pylinkirc.protocols.ts6_common import *
class InspIRCdProtocol(TS6BaseProtocol):
S2S_BUFSIZE = 0 # InspIRCd allows infinitely long S2S messages, so set bufsize to infinite

View File

@ -2,13 +2,14 @@
ircs2s_common.py: Common base protocol class with functions shared by TS6 and P10-based protocols.
"""
import time
import re
import time
from collections import defaultdict
from pylinkirc import conf, utils
from pylinkirc.classes import IRCNetwork, ProtocolError
from pylinkirc.log import log
from pylinkirc import utils, conf
class IncrementalUIDGenerator():
"""

View File

@ -5,6 +5,7 @@ nefarious.py: Migration stub to the new P10 protocol module.
from pylinkirc.log import log
from pylinkirc.protocols.p10 import *
class NefariousProtocol(P10Protocol):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)

View File

@ -7,14 +7,15 @@ ngircd.py: PyLink protocol module for ngIRCd.
# and https://tools.ietf.org/html/rfc2813
##
import time
import re
import time
from pylinkirc import utils, conf, __version__
from pylinkirc import __version__, conf, utils
from pylinkirc.classes import *
from pylinkirc.log import log
from pylinkirc.protocols.ircs2s_common import *
class NgIRCdProtocol(IRCS2SProtocol):
def __init__(self, irc):
super().__init__(irc)

View File

@ -4,14 +4,15 @@ p10.py: P10 protocol module for PyLink, supporting Nefarious IRCu and others.
import base64
import struct
from ipaddress import ip_address
import time
from ipaddress import ip_address
from pylinkirc import utils, structures, conf
from pylinkirc import conf, structures, utils
from pylinkirc.classes import *
from pylinkirc.log import log
from pylinkirc.protocols.ircs2s_common import *
class P10UIDGenerator(IncrementalUIDGenerator):
"""Implements an incremental P10 UID Generator."""

View File

@ -2,14 +2,15 @@
ts6.py: PyLink protocol module for TS6-based IRCds (charybdis, elemental-ircd).
"""
import time
import re
import time
from pylinkirc import utils, conf
from pylinkirc import conf, utils
from pylinkirc.classes import *
from pylinkirc.log import log
from pylinkirc.protocols.ts6_common import *
class TS6Protocol(TS6BaseProtocol):
SUPPORTED_IRCDS = ('charybdis', 'elemental', 'chatircd', 'ratbox')

View File

@ -5,11 +5,12 @@ ts6_common.py: Common base protocol class with functions shared by the UnrealIRC
import string
import time
from pylinkirc import utils, structures, conf
from pylinkirc import conf, structures, utils
from pylinkirc.classes import *
from pylinkirc.log import log
from pylinkirc.protocols.ircs2s_common import *
class TS6SIDGenerator():
"""
TS6 SID Generator. <query> is a 3 character string with any combination of

View File

@ -2,12 +2,12 @@
unreal.py: UnrealIRCd 4.x protocol module for PyLink.
"""
import time
import codecs
import socket
import re
import socket
import time
from pylinkirc import utils, conf
from pylinkirc import conf, utils
from pylinkirc.classes import *
from pylinkirc.log import log
from pylinkirc.protocols.ts6_common import *

1
pylink
View File

@ -1,5 +1,6 @@
#!/usr/bin/env python3
import sys
try:
from pylinkirc import launcher
except ImportError:

View File

@ -3,9 +3,10 @@
Password hashing utility for PyLink IRC Services.
"""
from pylinkirc.coremods.login import pwd_context
import getpass
from pylinkirc.coremods.login import pwd_context
if __name__ == '__main__':
import argparse

View File

@ -1,6 +1,8 @@
"""Setup module for PyLink IRC Services."""
import subprocess
import sys
from codecs import open
if sys.version_info < (3, 4):
raise RuntimeError("PyLink requires Python 3.4 or higher.")
@ -9,8 +11,6 @@ try:
from setuptools import setup, find_packages
except ImportError:
raise ImportError("Please install Setuptools and try again.")
from codecs import open
import subprocess
with open('VERSION', encoding='utf-8') as f:
version = f.read().strip()

View File

@ -7,14 +7,14 @@ This module contains custom data structures that may be useful in various situat
import collections
import collections.abc
import json
import pickle
import os
import pickle
import string
import threading
from copy import copy, deepcopy
import string
from .log import log
from . import conf
from .log import log
_BLACKLISTED_COPY_TYPES = []

View File

@ -3,8 +3,10 @@ Test cases for utils.py
"""
import unittest
from pylinkirc import utils
class UtilsTestCase(unittest.TestCase):
def test_strip_irc_formatting(self):

View File

@ -5,20 +5,20 @@ This module contains various utility functions related to IRC and/or the PyLink
framework.
"""
import string
import re
import importlib
import os
import collections
import argparse
import ipaddress
import collections
import functools
from .log import log
from . import world, conf, structures
import importlib
import ipaddress
import os
import re
import string
# Load the protocol and plugin packages.
from pylinkirc import protocols, plugins
from pylinkirc import plugins, protocols
from . import conf, structures, world
from .log import log
PLUGIN_PREFIX = plugins.__name__ + '.'
PROTOCOL_PREFIX = protocols.__name__ + '.'

View File

@ -2,9 +2,9 @@
world.py: Stores global variables for PyLink, including lists of active IRC objects and plugins.
"""
from collections import defaultdict, deque
import threading
import time
from collections import defaultdict, deque
# This indicates whether we're running in tests mode. What it actually does
# though is control whether IRC connections should be threaded or not.