deluge/deluge/plugins/pluginbase.py
Calum Lind 84802da29b [Py2to3] Force unicode_literals and fix related issues
* Added `from __future__ import unicode_literals` to every file so
   now all strings in code are forced to be unicode strings unless
   marked as byte string `b'str'` or encoded to byte string `'str'.encode('utf-8')`.

   This is a large change but we have been working towards the goal of unicode
   strings passed in the code so decoding external input and encoding
   output as byte strings (where applicable).

   Note that in Python 2 the `str` type still refers to byte strings.

 * Replaced the use of `str` for `basestring` in isinstance comparison as
   this was the original intention but breaks code when encoutering unicode strings.

 * Marked byte strings in gtkui as the conversion to utf8 is not always handled, mostly
   related to gobject signal names.
2017-02-22 12:36:32 +00:00

84 lines
2.1 KiB
Python

# -*- coding: utf-8 -*-
#
# Copyright (C) 2007-2010 Andrew Resch <andrewresch@gmail.com>
#
# This file is part of Deluge and is licensed under GNU General Public License 3.0, or later, with
# the additional special exception to link portions of this program with the OpenSSL library.
# See LICENSE for more details.
#
from __future__ import unicode_literals
import logging
import deluge.component as component
log = logging.getLogger(__name__)
class PluginBase(component.Component):
update_interval = 1
def __init__(self, name):
super(PluginBase, self).__init__(name, self.update_interval)
def enable(self):
raise NotImplementedError('Need to define an enable method!')
def disable(self):
raise NotImplementedError('Need to define a disable method!')
class CorePluginBase(PluginBase):
def __init__(self, plugin_name):
super(CorePluginBase, self).__init__('CorePlugin.' + plugin_name)
# Register RPC methods
component.get('RPCServer').register_object(self, plugin_name.lower())
log.debug('CorePlugin initialized..')
def __del__(self):
component.get('RPCServer').deregister_object(self)
def enable(self):
super(CorePluginBase, self).enable()
def disable(self):
super(CorePluginBase, self).disable()
class GtkPluginBase(PluginBase):
def __init__(self, plugin_name):
super(GtkPluginBase, self).__init__('GtkPlugin.' + plugin_name)
log.debug('GtkPlugin initialized..')
def enable(self):
super(GtkPluginBase, self).enable()
def disable(self):
super(GtkPluginBase, self).disable()
class WebPluginBase(PluginBase):
scripts = []
debug_scripts = []
stylesheets = []
debug_stylesheets = []
def __init__(self, plugin_name):
super(WebPluginBase, self).__init__('WebPlugin.' + plugin_name)
# Register JSON rpc methods
component.get('JSON').register_object(self, plugin_name.lower())
log.debug('WebPlugin initialized..')
def enable(self):
pass
def disable(self):
pass