From 6abc898968a917b27e9ff1eed85700f7c2a2fdd2 Mon Sep 17 00:00:00 2001 From: Morgan Creekmore Date: Thu, 6 Aug 2015 05:20:08 -0600 Subject: [PATCH] Prevent RuntimeError with inheritance by removing self.__class__ and replacing it with the class name --- spock/mcmap/mapdata.py | 4 ++-- spock/mcmap/smpmap.py | 6 +++--- spock/mcp/yggdrasil.py | 2 +- spock/plugins/core/auth.py | 4 ++-- spock/plugins/core/event.py | 4 ++-- spock/plugins/core/net.py | 8 ++++---- spock/plugins/core/settings.py | 4 ++-- spock/plugins/core/timer.py | 10 +++++----- spock/plugins/helpers/clientinfo.py | 6 +++--- spock/plugins/helpers/entities.py | 4 ++-- spock/plugins/helpers/inventory.py | 26 +++++++++++++++----------- spock/plugins/helpers/move.py | 4 ++-- spock/plugins/helpers/physics.py | 4 ++-- spock/plugins/helpers/start.py | 2 +- spock/plugins/helpers/world.py | 6 +++--- spock/plugins/loader.py | 2 +- spock/utils.py | 4 ++-- spock/vector.py | 4 ++-- 18 files changed, 54 insertions(+), 50 deletions(-) diff --git a/spock/mcmap/mapdata.py b/spock/mcmap/mapdata.py index 100b86c..aeb2367 100644 --- a/spock/mcmap/mapdata.py +++ b/spock/mcmap/mapdata.py @@ -72,7 +72,7 @@ def get_block(block_id, meta=0, init=True): return blocks[block_id] if block_id < len(blocks) else None -class MapBlock: +class MapBlock(object): display_name = 'Map Block' name = 'map_block' hardness = 0 @@ -1736,7 +1736,7 @@ def get_biome(biome_id): return biomes[biome_id]() if biome_id in biomes else None -class MapBiome: +class MapBiome(object): name = 'Map Biome' temperature = 0.0 diff --git a/spock/mcmap/smpmap.py b/spock/mcmap/smpmap.py index bcbe549..8254884 100644 --- a/spock/mcmap/smpmap.py +++ b/spock/mcmap/smpmap.py @@ -25,7 +25,7 @@ DIMENSION_END = 0x01 -class ChunkData: +class ChunkData(object): length = 16 * 16 * 16 ty = 'B' data = None @@ -94,14 +94,14 @@ def set(self, x, y, z, data): self.data[i] = (self.data[i] & 0x0F) | ((data & 0x0F) << 4) -class Chunk: +class Chunk(object): def __init__(self): self.block_data = ChunkDataShort() self.light_block = ChunkDataNibble() self.light_sky = ChunkDataNibble() -class ChunkColumn: +class ChunkColumn(object): def __init__(self): self.chunks = [None] * 16 self.biome = BiomeData() diff --git a/spock/mcp/yggdrasil.py b/spock/mcp/yggdrasil.py index 9be8e77..8100c42 100644 --- a/spock/mcp/yggdrasil.py +++ b/spock/mcp/yggdrasil.py @@ -8,7 +8,7 @@ from urllib2 import HTTPError -class YggAuth: +class YggAuth(object): def __init__(self, client_token=None, access_token=None, username=None, password=None): self.username = username diff --git a/spock/plugins/core/auth.py b/spock/plugins/core/auth.py index c062fb1..cc08cf5 100644 --- a/spock/plugins/core/auth.py +++ b/spock/plugins/core/auth.py @@ -35,7 +35,7 @@ def java_hex_digest(digest): return d -class AuthCore: +class AuthCore(object): def __init__(self, authenticated, event): self.event = event self.authenticated = authenticated @@ -85,7 +85,7 @@ class AuthPlugin(PluginBase): } def __init__(self, ploader, settings): - super(self.__class__, self).__init__(ploader, settings) + super(PluginBase, self).__init__(ploader, settings) self.authenticated = self.settings['authenticated'] self.sess_quit = self.settings['sess_quit'] self.auth = AuthCore(self.authenticated, self.event) diff --git a/spock/plugins/core/event.py b/spock/plugins/core/event.py index ed8ecb3..bae45cd 100644 --- a/spock/plugins/core/event.py +++ b/spock/plugins/core/event.py @@ -11,7 +11,7 @@ logger = logging.getLogger('spock') -class EventCore: +class EventCore(object): def __init__(self): self.kill_event = False self.event_handlers = defaultdict(list) @@ -45,6 +45,6 @@ def kill(self, *args): @pl_announce('Event') -class EventPlugin: +class EventPlugin(object): def __init__(self, ploader, settings): ploader.provides('Event', EventCore()) diff --git a/spock/plugins/core/net.py b/spock/plugins/core/net.py index 1d8c0f5..c675739 100644 --- a/spock/plugins/core/net.py +++ b/spock/plugins/core/net.py @@ -19,7 +19,7 @@ logger = logging.getLogger('spock') -class AESCipher: +class AESCipher(object): def __init__(self, shared_secret): # Name courtesy of dx self.encryptifier = AES.new(shared_secret, AES.MODE_CFB, @@ -34,7 +34,7 @@ def decrypt(self, data): return self.decryptifier.decrypt(data) -class SelectSocket: +class SelectSocket(object): def __init__(self, timer): self.sending = False self.timer = timer @@ -76,7 +76,7 @@ def reset(self): self.sock.setblocking(False) -class NetCore: +class NetCore(object): def __init__(self, sock, event): self.sock = sock self.event = event @@ -187,7 +187,7 @@ class NetPlugin(PluginBase): } def __init__(self, ploader, settings): - super(self.__class__, self).__init__(ploader, settings) + super(PluginBase, self).__init__(ploader, settings) self.bufsize = self.settings['bufsize'] self.sock_quit = self.settings['sock_quit'] self.sock = SelectSocket(self.timers) diff --git a/spock/plugins/core/settings.py b/spock/plugins/core/settings.py index 5ae6f3b..c899c9e 100644 --- a/spock/plugins/core/settings.py +++ b/spock/plugins/core/settings.py @@ -2,7 +2,7 @@ from spock.utils import get_settings, pl_announce -class PloaderFetch: +class PloaderFetch(object): def __init__(self, plugins, plugin_settings): self.plugins = plugins self.plugin_settings = plugin_settings @@ -15,7 +15,7 @@ def get_plugin_settings(self, plugin): @pl_announce('PloaderFetch') -class SettingsPlugin: +class SettingsPlugin(object): def __init__(self, ploader, kwargs): settings = get_settings(kwargs.get('settings', {}), kwargs) plugin_list = settings.get('plugins', DefaultPlugins) diff --git a/spock/plugins/core/timer.py b/spock/plugins/core/timer.py index dd70fdf..92d9b6a 100644 --- a/spock/plugins/core/timer.py +++ b/spock/plugins/core/timer.py @@ -45,7 +45,7 @@ def reset(self): # Time based timer class EventTimer(BaseTimer): def __init__(self, wait_time, callback, runs=1): - super(self.__class__, self).__init__(callback, runs) + super(BaseTimer, self).__init__(callback, runs) self.wait_time = wait_time self.end_time = time.time() + self.wait_time @@ -65,7 +65,7 @@ def reset(self): # World tick based timer class TickTimer(BaseTimer): def __init__(self, world, wait_ticks, callback, runs=1): - super(self.__class__, self).__init__(callback, runs) + super(BaseTimer, self).__init__(callback, runs) self.world = world self.wait_ticks = wait_ticks self.end_tick = self.world.age + self.wait_ticks @@ -79,7 +79,7 @@ def reset(self): self.end_tick = self.world.age + self.wait_ticks -class TimerCore: +class TimerCore(object): def __init__(self, world): self.timers = [] self.persist_timers = [] @@ -106,7 +106,7 @@ def reg_tick_timer(self, wait_ticks, callback, runs=-1, persist=False): persist) -class WorldTick: +class WorldTick(object): def __init__(self): self.age = 0 @@ -120,7 +120,7 @@ class TimerPlugin(PluginBase): } def __init__(self, ploader, settings): - super(self.__class__, self).__init__(ploader, settings) + super(PluginBase, self).__init__(ploader, settings) if not self.world: self.world = WorldTick() ploader.reg_event_handler('PLAY