mirror of
https://github.com/jlu5/PyLink.git
synced 2024-11-27 13:09:23 +01:00
Remove structures.DeprecatedAttributesObject, it's vastly inefficient for what it accomplishes
This commit is contained in:
parent
fb6c3bf6d5
commit
91b86ce0e4
10
classes.py
10
classes.py
@ -44,14 +44,10 @@ class ChannelState(structures.IRCCaseInsensitiveDict):
|
|||||||
|
|
||||||
return self._data[key]
|
return self._data[key]
|
||||||
|
|
||||||
class PyLinkNetworkCore(structures.DeprecatedAttributesObject, structures.CamelCaseToSnakeCase):
|
class PyLinkNetworkCore(structures.CamelCaseToSnakeCase):
|
||||||
"""Base IRC object for PyLink."""
|
"""Base IRC object for PyLink."""
|
||||||
|
|
||||||
def __init__(self, netname):
|
def __init__(self, netname):
|
||||||
self.deprecated_attributes = {
|
|
||||||
'conf': 'Deprecated since 1.2; consider switching to conf.conf',
|
|
||||||
'botdata': "Deprecated since 1.2; consider switching to conf.conf['pylink']",
|
|
||||||
}
|
|
||||||
|
|
||||||
self.loghandlers = []
|
self.loghandlers = []
|
||||||
self.name = netname
|
self.name = netname
|
||||||
@ -1705,7 +1701,7 @@ class Server():
|
|||||||
|
|
||||||
IrcServer = Server
|
IrcServer = Server
|
||||||
|
|
||||||
class Channel(structures.DeprecatedAttributesObject, structures.CamelCaseToSnakeCase, structures.CopyWrapper):
|
class Channel(structures.CamelCaseToSnakeCase, structures.CopyWrapper):
|
||||||
"""PyLink IRC channel class."""
|
"""PyLink IRC channel class."""
|
||||||
|
|
||||||
def __init__(self, irc, name=None):
|
def __init__(self, irc, name=None):
|
||||||
@ -1725,8 +1721,6 @@ class Channel(structures.DeprecatedAttributesObject, structures.CamelCaseToSnake
|
|||||||
# Saves the channel name (may be useful to plugins, etc.)
|
# Saves the channel name (may be useful to plugins, etc.)
|
||||||
self.name = name
|
self.name = name
|
||||||
|
|
||||||
self.deprecated_attributes = {'removeuser': 'Deprecated in 2.0; use remove_user() instead!'}
|
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return 'Channel(%s)' % self.name
|
return 'Channel(%s)' % self.name
|
||||||
|
|
||||||
|
@ -158,23 +158,6 @@ class IRCCaseInsensitiveSet(CaseInsensitiveSet):
|
|||||||
def __copy__(self):
|
def __copy__(self):
|
||||||
return self.__class__(self._irc, data=self._data.copy())
|
return self.__class__(self._irc, data=self._data.copy())
|
||||||
|
|
||||||
class DeprecatedAttributesObject():
|
|
||||||
"""
|
|
||||||
Object implementing deprecated attributes and warnings on access.
|
|
||||||
"""
|
|
||||||
def __init__(self):
|
|
||||||
self.deprecated_attributes = {}
|
|
||||||
|
|
||||||
def __getattribute__(self, attr):
|
|
||||||
# Note: "self.deprecated_attributes" calls this too, so the != check is
|
|
||||||
# needed to prevent a recursive loop!
|
|
||||||
# Also ignore reserved names beginning with "__".
|
|
||||||
if attr != 'deprecated_attributes' and not attr.startswith('__') and attr in self.deprecated_attributes:
|
|
||||||
log.warning('Attribute %s.%s is deprecated: %s' % (self.__class__.__name__, attr,
|
|
||||||
self.deprecated_attributes.get(attr)))
|
|
||||||
|
|
||||||
return object.__getattribute__(self, attr)
|
|
||||||
|
|
||||||
class CamelCaseToSnakeCase():
|
class CamelCaseToSnakeCase():
|
||||||
"""
|
"""
|
||||||
Class which automatically converts missing attributes from camel case to snake case.
|
Class which automatically converts missing attributes from camel case to snake case.
|
||||||
|
Loading…
Reference in New Issue
Block a user