diff options
Diffstat (limited to 'deluge/component.py')
-rw-r--r-- | deluge/component.py | 27 |
1 files changed, 12 insertions, 15 deletions
diff --git a/deluge/component.py b/deluge/component.py index c7ba83d..5646e8b 100644 --- a/deluge/component.py +++ b/deluge/component.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # # Copyright (C) 2007-2010 Andrew Resch <andrewresch@gmail.com> # @@ -7,13 +6,10 @@ # See LICENSE for more details. # -from __future__ import unicode_literals - import logging import traceback from collections import defaultdict -from six import string_types from twisted.internet import reactor from twisted.internet.defer import DeferredList, fail, maybeDeferred, succeed from twisted.internet.task import LoopingCall, deferLater @@ -27,13 +23,13 @@ class ComponentAlreadyRegistered(Exception): class ComponentException(Exception): def __init__(self, message, tb): - super(ComponentException, self).__init__(message) + super().__init__(message) self.message = message self.tb = tb def __str__(self): - s = super(ComponentException, self).__str__() - return '%s\n%s' % (s, ''.join(self.tb)) + s = super().__str__() + return '{}\n{}'.format(s, ''.join(self.tb)) def __eq__(self, other): if isinstance(other, self.__class__): @@ -45,7 +41,7 @@ class ComponentException(Exception): return not self.__eq__(other) -class Component(object): +class Component: """Component objects are singletons managed by the :class:`ComponentRegistry`. When a new Component object is instantiated, it will be automatically @@ -250,7 +246,7 @@ class Component(object): pass -class ComponentRegistry(object): +class ComponentRegistry: """The ComponentRegistry holds a list of currently registered :class:`Component` objects. It is used to manage the Components by starting, stopping, pausing and shutting them down. @@ -293,7 +289,8 @@ class ComponentRegistry(object): obj (Component): a component object to deregister Returns: - Deferred: a deferred object that will fire once the Component has been sucessfully deregistered + Deferred: a deferred object that will fire once the Component has been + successfully deregistered """ if obj in self.components.values(): @@ -324,7 +321,7 @@ class ComponentRegistry(object): # Start all the components if names is empty if not names: names = list(self.components) - elif isinstance(names, string_types): + elif isinstance(names, str): names = [names] def on_depends_started(result, name): @@ -358,7 +355,7 @@ class ComponentRegistry(object): """ if not names: names = list(self.components) - elif isinstance(names, string_types): + elif isinstance(names, str): names = [names] def on_dependents_stopped(result, name): @@ -398,7 +395,7 @@ class ComponentRegistry(object): """ if not names: names = list(self.components) - elif isinstance(names, string_types): + elif isinstance(names, str): names = [names] deferreds = [] @@ -424,7 +421,7 @@ class ComponentRegistry(object): """ if not names: names = list(self.components) - elif isinstance(names, string_types): + elif isinstance(names, str): names = [names] deferreds = [] @@ -448,7 +445,7 @@ class ComponentRegistry(object): def on_stopped(result): return DeferredList( - [comp._component_shutdown() for comp in self.components.values()] + [comp._component_shutdown() for comp in list(self.components.values())] ) return self.stop(list(self.components)).addCallback(on_stopped) |