3
0
mirror of https://github.com/jlu5/PyLink.git synced 2024-11-01 01:09:22 +01:00

New import paths for properly installed pylinkirc

This commit is contained in:
James Lu 2016-06-20 18:18:54 -07:00
parent 5f9c14ca18
commit 481d70eff8
25 changed files with 61 additions and 157 deletions

View File

@ -17,10 +17,8 @@ import hashlib
from copy import deepcopy
import inspect
from log import *
import world
import utils
import structures
from . import world, utils, structures
from .log import *
### Exceptions

View File

@ -17,7 +17,7 @@ import yaml
import sys
from collections import defaultdict
import world
from . import world
global testconf
testconf = {'bot':

View File

@ -7,11 +7,8 @@ import sys
import signal
import os
import utils
import conf
import classes
from log import log
import world
from . import utils, conf, classes, world
from .log import log
def _shutdown(irc=None):
"""Shuts down the Pylink daemon."""

4
log.py
View File

@ -9,9 +9,9 @@ access the global logger object by importing "log" from this module
import logging
import sys
import os
import world
from conf import conf, confname
from . import world
from .conf import conf, confname
stdout_level = conf['logging'].get('stdout') or 'INFO'

View File

@ -2,13 +2,8 @@
bots.py: Spawn virtual users/bots on a PyLink server and make them interact
with things.
"""
import sys
import os
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
import utils
from log import log
from pylinkirc import utils
from pylinkirc.log import log
@utils.add_cmd
def spawnclient(irc, source, args):

View File

@ -1,11 +1,8 @@
"""
Changehost plugin - automatically changes the hostname of matching users.
"""
# Import hacks to access utils and log.
import sys
import os
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from pylinkirc import utils, world
from pylinkirc.log import log
import string
@ -13,10 +10,6 @@ import string
# (pip install ircmatch)
import ircmatch
import utils
import world
from log import log
# Characters allowed in a hostname.
allowed_chars = string.ascii_letters + '-./:' + string.digits

View File

@ -1,12 +1,8 @@
# commands.py: base PyLink commands
import sys
import os
from time import ctime
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
import utils
from log import log
import world
from pylinkirc import utils
from pylinkirc.log import log
@utils.add_cmd
def status(irc, source, args):

View File

@ -1,10 +1,6 @@
# ctcp.py: Handles basic CTCP requests.
import sys
import os
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
import utils
from log import log
from pylinkirc import utils
from pylinkirc.log import log
def handle_ctcpversion(irc, source, args):
"""

View File

@ -1,12 +1,6 @@
# example.py: An example PyLink plugin.
# These two lines add PyLink's root directory to the PATH, so that importing things like
# 'utils' and 'log' work.
import sys, os
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
import utils
from log import log
from pylinkirc import utils
from pylinkirc.log import log
import random

View File

@ -2,16 +2,11 @@
exec.py: Provides commands for executing raw code and debugging PyLink.
"""
import sys
import os
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
import utils
from log import log
from pylinkirc import utils, world
from pylinkirc.log import log
# These imports are not strictly necessary, but make the following modules
# easier to access through eval and exec.
import world
import threading
import re
import time

View File

@ -1,11 +1,6 @@
# fantasy.py: Adds FANTASY command support, to allow calling commands in channels
import sys
import os
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
import utils
import world
from log import log
from pylinkirc import utils, world
from pylinkirc.log import log
def handle_fantasy(irc, source, command, args):
"""Fantasy command handler."""

View File

@ -1,18 +1,13 @@
"""
games.py: Create a bot that provides game functionality (dice, 8ball, etc).
"""
import sys
import os
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
import random
import urllib.request
import urllib.error
from xml.etree import ElementTree
import utils
from log import log
import world
from pylinkirc import utils
from pylinkirc.log import log
gameclient = utils.registerService("Games", manipulatable=True)
reply = gameclient.reply # TODO find a better syntax for ServiceBot.reply()

View File

@ -1,14 +1,8 @@
"""Networks plugin - allows you to manipulate connections to various configured networks."""
import sys
import os
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
import threading
import utils
import world
from log import log
from pylinkirc import utils, world
from pylinkirc.log import log
@utils.add_cmd
def disconnect(irc, source, args):

View File

@ -2,11 +2,6 @@
opercmds.py: Provides a subset of network management commands.
"""
import sys
import os
# Add the base PyLink folder to path, so we can import utils and log.
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
# ircmatch library from https://github.com/mammon-ircd/ircmatch
# (pip install ircmatch)
try:
@ -14,8 +9,8 @@ try:
except ImportError:
ircmatch = None
import utils
from log import log
from pylinkirc import utils
from pylinkirc.log import log
@utils.add_cmd
def checkban(irc, source, args):

View File

@ -1,17 +1,12 @@
# relay.py: PyLink Relay plugin
import sys
import os
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
import pickle
import time
import threading
import string
from collections import defaultdict
import utils
from log import log
import world
from pylinkirc import utils, world
from pylinkirc.log import log
### GLOBAL (statekeeping) VARIABLES
relayusers = defaultdict(dict)

View File

@ -1,12 +1,8 @@
# servprotect.py: Protects against KILL and nick collision floods
import sys
import os
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from expiringdict import ExpiringDict
import utils
from log import log
from pylinkirc import utils
from pylinkirc.log import log
# TODO: make length and time configurable
savecache = ExpiringDict(max_len=5, max_age_seconds=10)

View File

@ -3,13 +3,10 @@ import sys
import os
import re
curdir = os.path.dirname(__file__)
sys.path += [curdir, os.path.dirname(curdir)]
import utils
from log import log
from classes import *
from ts6 import *
from pylinkirc import utils
from pylinkirc.log import log
from pylinkirc.classes import *
from pylinkirc.protocols.ts6 import *
class HybridProtocol(TS6Protocol):
def __init__(self, irc):

View File

@ -8,14 +8,10 @@ import os
import re
import threading
# Import hacks to access utils and classes...
curdir = os.path.dirname(__file__)
sys.path += [curdir, os.path.dirname(curdir)]
import utils
from log import log
from classes import *
from ts6_common import *
from pylinkirc import utils
from pylinkirc.classes import *
from pylinkirc.log import log
from pylinkirc.protocols.ts6_common import *
class InspIRCdProtocol(TS6BaseProtocol):
def __init__(self, irc):

View File

@ -8,13 +8,9 @@ import base64
import struct
from ipaddress import ip_address
# Import hacks to access utils and classes...
curdir = os.path.dirname(__file__)
sys.path += [curdir, os.path.dirname(curdir)]
import utils
from log import log
from classes import *
from pylinkirc import utils
from pylinkirc.classes import *
from pylinkirc.log import log
class P10UIDGenerator(utils.IncrementalUIDGenerator):
"""Implements an incremental P10 UID Generator."""

View File

@ -7,14 +7,10 @@ import sys
import os
import re
# Import hacks to access utils and classes...
curdir = os.path.dirname(__file__)
sys.path += [curdir, os.path.dirname(curdir)]
import utils
from log import log
from classes import *
from ts6_common import *
from pylinkirc import utils
from pylinkirc.classes import *
from pylinkirc.log import log
from pylinkirc.protocols.ts6_common import *
class TS6Protocol(TS6BaseProtocol):
def __init__(self, irc):

View File

@ -6,14 +6,9 @@ import sys
import os
import string
# Import hacks to access utils and classes...
curdir = os.path.dirname(__file__)
sys.path += [curdir, os.path.dirname(curdir)]
import utils
from log import log
from classes import *
import structures
from pylinkirc import utils, structures
from pylinkirc.classes import *
from pylinkirc.log import log
class TS6SIDGenerator():
"""

View File

@ -9,14 +9,10 @@ import codecs
import socket
import re
# Import hacks to access utils and classes...
curdir = os.path.dirname(__file__)
sys.path += [curdir, os.path.dirname(curdir)]
import utils
from log import log
from classes import *
from ts6_common import *
from pylinkirc import utils
from pylinkirc.classes import *
from pylinkirc.log import log
from pylinkirc.protocols.ts6_common import *
class UnrealProtocol(TS6BaseProtocol):
def __init__(self, irc):

13
pylink
View File

@ -1,20 +1,13 @@
#!/usr/bin/env python3
import os
import sys
# Change directory to the folder containing PyLink's source
os.chdir(os.path.dirname(os.path.abspath(__file__)))
# This must be done before conf imports, so we get the real conf instead of testing one.
import world
from pylinkirc import world
world.testing = False
import conf
from log import log
import classes
import utils
import coreplugin
from pylinkirc import conf, classes, utils, coreplugin
from pylinkirc.log import log
if __name__ == '__main__':
log.info('PyLink %s starting...', world.version)

View File

@ -45,7 +45,7 @@ setup(
install_requires=['pyyaml'],
# Folders (packages of code)
packages=find_packages(exclude=['log', 'docs', 'tests']),
packages=['pylinkirc', 'pylinkirc.protocols', 'pylinkirc.plugins'],
# Single modules. TODO: consider organizing this into a pylink/ folder
py_modules=["classes", "conf", "coreplugin", "log", "structures", "utils", "world"],
@ -55,6 +55,8 @@ setup(
'': ['example-conf.yml'],
},
package_dir = {'pylinkirc': '.'},
# Executable scripts
scripts=["pylink"],
)

View File

@ -11,9 +11,8 @@ import importlib
import os
import collections
from log import log
import world
import conf
from .log import log
from . import world, conf
class NotAuthenticatedError(Exception):
"""