mirror of
https://github.com/jlu5/PyLink.git
synced 2024-11-01 09:19:23 +01:00
utils: add an IRCParser class based off argparse, modified from @IotaSpencer's code
Closes #6.
This commit is contained in:
parent
02faa3fcb6
commit
0125c544ee
14
utils.py
14
utils.py
@ -10,6 +10,7 @@ import re
|
|||||||
import importlib
|
import importlib
|
||||||
import os
|
import os
|
||||||
import collections
|
import collections
|
||||||
|
import argparse
|
||||||
|
|
||||||
from .log import log
|
from .log import log
|
||||||
from . import world, conf
|
from . import world, conf
|
||||||
@ -27,6 +28,11 @@ class NotAuthorizedError(Exception):
|
|||||||
"""
|
"""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
class InvalidArgumentsError(TypeError):
|
||||||
|
"""
|
||||||
|
Exception raised (by IRCParser and potentially others) when a bot command is given invalid arguments.
|
||||||
|
"""
|
||||||
|
|
||||||
class IncrementalUIDGenerator():
|
class IncrementalUIDGenerator():
|
||||||
"""
|
"""
|
||||||
Incremental UID Generator module, adapted from InspIRCd source:
|
Incremental UID Generator module, adapted from InspIRCd source:
|
||||||
@ -547,3 +553,11 @@ def wrapArguments(prefix, args, length, separator=' ', max_args_per_line=0):
|
|||||||
strings.append(buf)
|
strings.append(buf)
|
||||||
|
|
||||||
return strings
|
return strings
|
||||||
|
|
||||||
|
class IRCParser(argparse.ArgumentParser):
|
||||||
|
"""
|
||||||
|
Wrapper around argparse.ArgumentParser, without quitting on usage errors.
|
||||||
|
"""
|
||||||
|
|
||||||
|
def error(self, message):
|
||||||
|
raise InvalidArgumentsError(message)
|
||||||
|
Loading…
Reference in New Issue
Block a user