diff --git a/lbrynet/analytics.py b/lbrynet/analytics.py index 6cf68de5e..4e2f60ae1 100644 --- a/lbrynet/analytics.py +++ b/lbrynet/analytics.py @@ -24,7 +24,7 @@ BLOB_BYTES_UPLOADED = 'Blob Bytes Uploaded' log = logging.getLogger(__name__) -class Manager(object): +class Manager: def __init__(self, analytics_api, context=None, installation_id=None, session_id=None): self.analytics_api = analytics_api self._tracked_data = collections.defaultdict(list) @@ -219,7 +219,7 @@ class Manager(object): callback(maybe_deferred, *args, **kwargs) -class Api(object): +class Api: def __init__(self, cookies, url, write_key, enabled): self.cookies = cookies self.url = url diff --git a/lbrynet/blob/blob_file.py b/lbrynet/blob/blob_file.py index 709a33df0..919b99894 100644 --- a/lbrynet/blob/blob_file.py +++ b/lbrynet/blob/blob_file.py @@ -13,7 +13,7 @@ log = logging.getLogger(__name__) MAX_BLOB_SIZE = 2 * 2 ** 20 -class BlobFile(object): +class BlobFile: """ A chunk of data available on the network which is specified by a hashsum diff --git a/lbrynet/blob/creator.py b/lbrynet/blob/creator.py index 72e24b657..a90117056 100644 --- a/lbrynet/blob/creator.py +++ b/lbrynet/blob/creator.py @@ -8,7 +8,7 @@ from lbrynet.core.cryptoutils import get_lbry_hash_obj log = logging.getLogger(__name__) -class BlobFileCreator(object): +class BlobFileCreator: """ This class is used to create blobs on the local filesystem when we do not know the blob hash beforehand (i.e, when creating diff --git a/lbrynet/blob/reader.py b/lbrynet/blob/reader.py index afd62e57e..364bf4575 100644 --- a/lbrynet/blob/reader.py +++ b/lbrynet/blob/reader.py @@ -3,7 +3,7 @@ import logging log = logging.getLogger(__name__) -class HashBlobReader(object): +class HashBlobReader: """ This is a file like reader class that supports read(size) and close() diff --git a/lbrynet/blob/writer.py b/lbrynet/blob/writer.py index e30a6d417..71e84e53e 100644 --- a/lbrynet/blob/writer.py +++ b/lbrynet/blob/writer.py @@ -7,7 +7,7 @@ from lbrynet.core.cryptoutils import get_lbry_hash_obj log = logging.getLogger(__name__) -class HashBlobWriter(object): +class HashBlobWriter: def __init__(self, length_getter, finished_cb): self.write_handle = BytesIO() self.length_getter = length_getter diff --git a/lbrynet/conf.py b/lbrynet/conf.py index 64a200a3a..4723352c0 100644 --- a/lbrynet/conf.py +++ b/lbrynet/conf.py @@ -164,11 +164,11 @@ class Env(envparse.Env): self._convert_key(key): self._convert_value(value) for key, value in schema.items() } - envparse.Env.__init__(self, **my_schema) + super().__init__(**my_schema) def __call__(self, key, *args, **kwargs): my_key = self._convert_key(key) - return super(Env, self).__call__(my_key, *args, **kwargs) + return super().__call__(my_key, *args, **kwargs) @staticmethod def _convert_key(key): @@ -289,7 +289,7 @@ ADJUSTABLE_SETTINGS = { } -class Config(object): +class Config: def __init__(self, fixed_defaults, adjustable_defaults, persisted_settings=None, environment=None, cli_settings=None): diff --git a/lbrynet/core/BlobAvailability.py b/lbrynet/core/BlobAvailability.py index cc9d446d1..36fb92a27 100644 --- a/lbrynet/core/BlobAvailability.py +++ b/lbrynet/core/BlobAvailability.py @@ -9,7 +9,7 @@ from decimal import Decimal log = logging.getLogger(__name__) -class BlobAvailabilityTracker(object): +class BlobAvailabilityTracker: """ Class to track peer counts for known blobs, and to discover new popular blobs diff --git a/lbrynet/core/BlobInfo.py b/lbrynet/core/BlobInfo.py index a15d2bc03..787ef65de 100644 --- a/lbrynet/core/BlobInfo.py +++ b/lbrynet/core/BlobInfo.py @@ -1,4 +1,4 @@ -class BlobInfo(object): +class BlobInfo: """ This structure is used to represent the metadata of a blob. diff --git a/lbrynet/core/BlobManager.py b/lbrynet/core/BlobManager.py index 7f3bea192..903614b22 100644 --- a/lbrynet/core/BlobManager.py +++ b/lbrynet/core/BlobManager.py @@ -8,7 +8,7 @@ from lbrynet.blob.creator import BlobFileCreator log = logging.getLogger(__name__) -class DiskBlobManager(object): +class DiskBlobManager: def __init__(self, blob_dir, storage, node_datastore=None): """ This class stores blobs on the hard disk diff --git a/lbrynet/core/DownloadOption.py b/lbrynet/core/DownloadOption.py index 6a4446b20..d256e9be8 100644 --- a/lbrynet/core/DownloadOption.py +++ b/lbrynet/core/DownloadOption.py @@ -1,4 +1,4 @@ -class DownloadOptionChoice(object): +class DownloadOptionChoice: """A possible choice that can be picked for some option. An option can have one or more choices that can be picked from. @@ -10,7 +10,7 @@ class DownloadOptionChoice(object): self.bool_options_description = bool_options_description -class DownloadOption(object): +class DownloadOption: """An option for a user to select a value from several different choices.""" def __init__(self, option_types, long_description, short_description, default_value, default_value_description): diff --git a/lbrynet/core/Error.py b/lbrynet/core/Error.py index 68a6df78e..4ce2c933b 100644 --- a/lbrynet/core/Error.py +++ b/lbrynet/core/Error.py @@ -12,19 +12,19 @@ class DownloadCanceledError(Exception): class DownloadSDTimeout(Exception): def __init__(self, download): - Exception.__init__(self, 'Failed to download sd blob {} within timeout'.format(download)) + super().__init__('Failed to download sd blob {} within timeout'.format(download)) self.download = download class DownloadTimeoutError(Exception): def __init__(self, download): - Exception.__init__(self, 'Failed to download {} within timeout'.format(download)) + super().__init__('Failed to download {} within timeout'.format(download)) self.download = download class DownloadDataTimeout(Exception): def __init__(self, download): - Exception.__init__(self, 'Failed to download data blobs for sd hash ' + super().__init__('Failed to download data blobs for sd hash ' '{} within timeout'.format(download)) self.download = download @@ -55,39 +55,39 @@ class KeyFeeAboveMaxAllowed(Exception): class InvalidExchangeRateResponse(Exception): def __init__(self, source, reason): - Exception.__init__(self, 'Failed to get exchange rate from {}:{}'.format(source, reason)) + super().__init__('Failed to get exchange rate from {}:{}'.format(source, reason)) self.source = source self.reason = reason class UnknownNameError(Exception): def __init__(self, name): - Exception.__init__(self, 'Name {} is unknown'.format(name)) + super().__init__('Name {} is unknown'.format(name)) self.name = name class UnknownClaimID(Exception): def __init__(self, claim_id): - Exception.__init__(self, 'Claim {} is unknown'.format(claim_id)) + super().__init__('Claim {} is unknown'.format(claim_id)) self.claim_id = claim_id class UnknownURI(Exception): def __init__(self, uri): - Exception.__init__(self, 'URI {} cannot be resolved'.format(uri)) + super().__init__('URI {} cannot be resolved'.format(uri)) self.name = uri class UnknownOutpoint(Exception): def __init__(self, outpoint): - Exception.__init__(self, 'Outpoint {} cannot be resolved'.format(outpoint)) + super().__init__('Outpoint {} cannot be resolved'.format(outpoint)) self.outpoint = outpoint class InvalidName(Exception): def __init__(self, name, invalid_characters): self.name = name self.invalid_characters = invalid_characters - Exception.__init__( - self, 'URI contains invalid characters: {}'.format(','.join(invalid_characters))) + super().__init__( + 'URI contains invalid characters: {}'.format(','.join(invalid_characters))) class UnknownStreamTypeError(Exception): @@ -105,7 +105,7 @@ class InvalidStreamDescriptorError(Exception): class InvalidStreamInfoError(Exception): def __init__(self, name, stream_info): msg = '{} has claim with invalid stream info: {}'.format(name, stream_info) - Exception.__init__(self, msg) + super().__init__(msg) self.name = name self.stream_info = stream_info @@ -159,14 +159,14 @@ class NegotiationError(Exception): class InvalidCurrencyError(Exception): def __init__(self, currency): self.currency = currency - Exception.__init__( - self, 'Invalid currency: {} is not a supported currency.'.format(currency)) + super().__init__( + 'Invalid currency: {} is not a supported currency.'.format(currency)) class NoSuchDirectoryError(Exception): def __init__(self, directory): self.directory = directory - Exception.__init__(self, 'No such directory {}'.format(directory)) + super().__init__('No such directory {}'.format(directory)) class ComponentStartConditionNotMet(Exception): diff --git a/lbrynet/core/Offer.py b/lbrynet/core/Offer.py index fb4641d57..883655ef6 100644 --- a/lbrynet/core/Offer.py +++ b/lbrynet/core/Offer.py @@ -1,7 +1,7 @@ from decimal import Decimal -class Offer(object): +class Offer: """A rate offer to download blobs from a host.""" RATE_ACCEPTED = "RATE_ACCEPTED" diff --git a/lbrynet/core/PaymentRateManager.py b/lbrynet/core/PaymentRateManager.py index 1d3320390..f395e5bfb 100644 --- a/lbrynet/core/PaymentRateManager.py +++ b/lbrynet/core/PaymentRateManager.py @@ -3,14 +3,14 @@ from lbrynet import conf from decimal import Decimal -class BasePaymentRateManager(object): +class BasePaymentRateManager: def __init__(self, rate=None, info_rate=None): self.min_blob_data_payment_rate = rate if rate is not None else conf.settings['data_rate'] self.min_blob_info_payment_rate = ( info_rate if info_rate is not None else conf.settings['min_info_rate']) -class PaymentRateManager(object): +class PaymentRateManager: def __init__(self, base, rate=None): """ @param base: a BasePaymentRateManager @@ -36,7 +36,7 @@ class PaymentRateManager(object): self.points_paid += amount -class NegotiatedPaymentRateManager(object): +class NegotiatedPaymentRateManager: def __init__(self, base, availability_tracker, generous=None): """ @param base: a BasePaymentRateManager @@ -84,7 +84,7 @@ class NegotiatedPaymentRateManager(object): return False -class OnlyFreePaymentsManager(object): +class OnlyFreePaymentsManager: def __init__(self, **kwargs): """ A payment rate manager that will only ever accept and offer a rate of 0.0, diff --git a/lbrynet/core/Peer.py b/lbrynet/core/Peer.py index a65f7048a..51370c6c3 100644 --- a/lbrynet/core/Peer.py +++ b/lbrynet/core/Peer.py @@ -3,7 +3,7 @@ from collections import defaultdict from lbrynet.core import utils # Do not create this object except through PeerManager -class Peer(object): +class Peer: def __init__(self, host, port): self.host = host self.port = port diff --git a/lbrynet/core/PeerManager.py b/lbrynet/core/PeerManager.py index 1c5816158..66e6214df 100644 --- a/lbrynet/core/PeerManager.py +++ b/lbrynet/core/PeerManager.py @@ -1,7 +1,7 @@ from lbrynet.core.Peer import Peer -class PeerManager(object): +class PeerManager: def __init__(self): self.peers = [] diff --git a/lbrynet/core/PriceModel.py b/lbrynet/core/PriceModel.py index aad6eb42f..3021566c9 100644 --- a/lbrynet/core/PriceModel.py +++ b/lbrynet/core/PriceModel.py @@ -9,7 +9,7 @@ def get_default_price_model(blob_tracker, base_price, **kwargs): return MeanAvailabilityWeightedPrice(blob_tracker, base_price, **kwargs) -class ZeroPrice(object): +class ZeroPrice: def __init__(self): self.base_price = 0.0 @@ -17,7 +17,7 @@ class ZeroPrice(object): return 0.0 -class MeanAvailabilityWeightedPrice(object): +class MeanAvailabilityWeightedPrice: """Calculate mean-blob-availability and stream-position weighted price for a blob Attributes: diff --git a/lbrynet/core/RateLimiter.py b/lbrynet/core/RateLimiter.py index aa531da7f..136b533b0 100644 --- a/lbrynet/core/RateLimiter.py +++ b/lbrynet/core/RateLimiter.py @@ -6,7 +6,7 @@ from twisted.internet import task log = logging.getLogger(__name__) -class DummyRateLimiter(object): +class DummyRateLimiter: def __init__(self): self.dl_bytes_this_second = 0 self.ul_bytes_this_second = 0 @@ -44,7 +44,7 @@ class DummyRateLimiter(object): self.total_ul_bytes += num_bytes -class RateLimiter(object): +class RateLimiter: """This class ensures that upload and download rates don't exceed specified maximums""" #implements(IRateLimiter) diff --git a/lbrynet/core/SinglePeerDownloader.py b/lbrynet/core/SinglePeerDownloader.py index 904927080..8ec6c8880 100644 --- a/lbrynet/core/SinglePeerDownloader.py +++ b/lbrynet/core/SinglePeerDownloader.py @@ -19,7 +19,7 @@ log = logging.getLogger(__name__) class SinglePeerFinder(DummyPeerFinder): def __init__(self, peer): - DummyPeerFinder.__init__(self) + super().__init__() self.peer = peer def find_peers_for_blob(self, blob_hash, timeout=None, filter_self=False): @@ -28,7 +28,7 @@ class SinglePeerFinder(DummyPeerFinder): class BlobCallback(BlobFile): def __init__(self, blob_dir, blob_hash, timeout): - BlobFile.__init__(self, blob_dir, blob_hash) + super().__init__(blob_dir, blob_hash) self.callback = defer.Deferred() reactor.callLater(timeout, self._cancel) @@ -43,7 +43,7 @@ class BlobCallback(BlobFile): return result -class SingleBlobDownloadManager(object): +class SingleBlobDownloadManager: def __init__(self, blob): self.blob = blob @@ -57,7 +57,7 @@ class SingleBlobDownloadManager(object): return self.blob.blob_hash -class SinglePeerDownloader(object): +class SinglePeerDownloader: def __init__(self): self._payment_rate_manager = OnlyFreePaymentsManager() self._rate_limiter = DummyRateLimiter() diff --git a/lbrynet/core/Strategy.py b/lbrynet/core/Strategy.py index 0ee0d1efd..d8eb62749 100644 --- a/lbrynet/core/Strategy.py +++ b/lbrynet/core/Strategy.py @@ -10,7 +10,7 @@ def get_default_strategy(blob_tracker, **kwargs): return BasicAvailabilityWeightedStrategy(blob_tracker, **kwargs) -class Strategy(object): +class Strategy: """ Base for negotiation strategies """ @@ -109,7 +109,7 @@ class BasicAvailabilityWeightedStrategy(Strategy): base_price=0.0001, alpha=1.0): price_model = MeanAvailabilityWeightedPrice( blob_tracker, base_price=base_price, alpha=alpha) - Strategy.__init__(self, price_model, max_rate, min_rate, is_generous) + super().__init__(price_model, max_rate, min_rate, is_generous) self._acceleration = Decimal(acceleration) # rate of how quickly to ramp offer self._deceleration = Decimal(deceleration) @@ -140,7 +140,7 @@ class OnlyFreeStrategy(Strategy): implementer(INegotiationStrategy) def __init__(self, *args, **kwargs): price_model = ZeroPrice() - Strategy.__init__(self, price_model, 0.0, 0.0, True) + super().__init__(price_model, 0.0, 0.0, True) def _get_mean_rate(self, rates): return 0.0 diff --git a/lbrynet/core/StreamDescriptor.py b/lbrynet/core/StreamDescriptor.py index 0d0b2a4c2..1bafbed5d 100644 --- a/lbrynet/core/StreamDescriptor.py +++ b/lbrynet/core/StreamDescriptor.py @@ -12,7 +12,7 @@ from lbrynet.core.HTTPBlobDownloader import HTTPBlobDownloader log = logging.getLogger(__name__) -class StreamDescriptorReader(object): +class StreamDescriptorReader: """Classes which derive from this class read a stream descriptor file return a dictionary containing the fields in the file""" def __init__(self): @@ -33,7 +33,7 @@ class StreamDescriptorReader(object): class PlainStreamDescriptorReader(StreamDescriptorReader): """Read a stream descriptor file which is not a blob but a regular file""" def __init__(self, stream_descriptor_filename): - StreamDescriptorReader.__init__(self) + super().__init__() self.stream_descriptor_filename = stream_descriptor_filename def _get_raw_data(self): @@ -49,7 +49,7 @@ class PlainStreamDescriptorReader(StreamDescriptorReader): class BlobStreamDescriptorReader(StreamDescriptorReader): """Read a stream descriptor file which is a blob""" def __init__(self, blob): - StreamDescriptorReader.__init__(self) + super().__init__() self.blob = blob def _get_raw_data(self): @@ -76,7 +76,7 @@ def bytes2unicode(value): return value -class StreamDescriptorWriter(object): +class StreamDescriptorWriter: """Classes which derive from this class write fields from a dictionary of fields to a stream descriptor""" def __init__(self): @@ -94,7 +94,7 @@ class StreamDescriptorWriter(object): class PlainStreamDescriptorWriter(StreamDescriptorWriter): def __init__(self, sd_file_name): - StreamDescriptorWriter.__init__(self) + super().__init__() self.sd_file_name = sd_file_name def _write_stream_descriptor(self, raw_data): @@ -110,7 +110,7 @@ class PlainStreamDescriptorWriter(StreamDescriptorWriter): class BlobStreamDescriptorWriter(StreamDescriptorWriter): def __init__(self, blob_manager): - StreamDescriptorWriter.__init__(self) + super().__init__() self.blob_manager = blob_manager @defer.inlineCallbacks @@ -124,7 +124,7 @@ class BlobStreamDescriptorWriter(StreamDescriptorWriter): defer.returnValue(sd_hash) -class StreamMetadata(object): +class StreamMetadata: FROM_BLOB = 1 FROM_PLAIN = 2 @@ -137,7 +137,7 @@ class StreamMetadata(object): self.source_file = None -class StreamDescriptorIdentifier(object): +class StreamDescriptorIdentifier: """Tries to determine the type of stream described by the stream descriptor using the 'stream_type' field. Keeps a list of StreamDescriptorValidators and StreamDownloaderFactorys and returns the appropriate ones based on the type of the stream descriptor given @@ -407,7 +407,7 @@ def validate_descriptor(stream_info): return True -class EncryptedFileStreamDescriptorValidator(object): +class EncryptedFileStreamDescriptorValidator: def __init__(self, raw_info): self.raw_info = raw_info diff --git a/lbrynet/core/Wallet.py b/lbrynet/core/Wallet.py index e2e633c45..9a66ba115 100644 --- a/lbrynet/core/Wallet.py +++ b/lbrynet/core/Wallet.py @@ -30,7 +30,7 @@ from lbrynet.core.Error import DownloadCanceledError, RequestCanceledError log = logging.getLogger(__name__) -class ReservedPoints(object): +class ReservedPoints: def __init__(self, identifier, amount): self.identifier = identifier self.amount = amount @@ -62,7 +62,7 @@ class ClaimOutpoint(dict): return not self.__eq__(compare) -class Wallet(object): +class Wallet: """This class implements the Wallet interface for the LBRYcrd payment system""" implements(IWallet) @@ -819,7 +819,7 @@ class Wallet(object): class LBRYumWallet(Wallet): def __init__(self, storage, config=None): - Wallet.__init__(self, storage) + super().__init__(storage) self._config = config self.config = make_config(self._config) self.network = None @@ -1228,7 +1228,7 @@ class LBRYumWallet(Wallet): return not self.wallet.use_encryption -class LBRYcrdAddressRequester(object): +class LBRYcrdAddressRequester: implements([IRequestCreator]) def __init__(self, wallet): @@ -1266,7 +1266,7 @@ class LBRYcrdAddressRequester(object): return err -class LBRYcrdAddressQueryHandlerFactory(object): +class LBRYcrdAddressQueryHandlerFactory: implements(IQueryHandlerFactory) def __init__(self, wallet): @@ -1285,7 +1285,7 @@ class LBRYcrdAddressQueryHandlerFactory(object): return "LBRYcrd Address - an address for receiving payments via LBRYcrd" -class LBRYcrdAddressQueryHandler(object): +class LBRYcrdAddressQueryHandler: implements(IQueryHandler) def __init__(self, wallet): diff --git a/lbrynet/core/call_later_manager.py b/lbrynet/core/call_later_manager.py index d82b456ee..eba08450e 100644 --- a/lbrynet/core/call_later_manager.py +++ b/lbrynet/core/call_later_manager.py @@ -8,7 +8,7 @@ DELAY_INCREMENT = 0.0001 QUEUE_SIZE_THRESHOLD = 100 -class CallLaterManager(object): +class CallLaterManager: def __init__(self, callLater): """ :param callLater: (IReactorTime.callLater) diff --git a/lbrynet/core/client/BlobRequester.py b/lbrynet/core/client/BlobRequester.py index ddf9149c0..c838e455d 100644 --- a/lbrynet/core/client/BlobRequester.py +++ b/lbrynet/core/client/BlobRequester.py @@ -37,7 +37,7 @@ def cache(fn): return helper -class BlobRequester(object): +class BlobRequester: #implements(IRequestCreator) def __init__(self, blob_manager, peer_finder, payment_rate_manager, wallet, download_manager): @@ -193,7 +193,7 @@ class BlobRequester(object): self._peers[peer] += amount -class RequestHelper(object): +class RequestHelper: def __init__(self, requestor, peer, protocol, payment_rate_manager): self.requestor = requestor self.peer = peer @@ -427,7 +427,7 @@ class PriceRequest(RequestHelper): class DownloadRequest(RequestHelper): """Choose a blob and download it from a peer and also pay the peer for the data.""" def __init__(self, requester, peer, protocol, payment_rate_manager, wallet, head_blob_hash): - RequestHelper.__init__(self, requester, peer, protocol, payment_rate_manager) + super().__init__(requester, peer, protocol, payment_rate_manager) self.wallet = wallet self.head_blob_hash = head_blob_hash @@ -576,7 +576,7 @@ class DownloadRequest(RequestHelper): return reason -class BlobDownloadDetails(object): +class BlobDownloadDetails: """Contains the information needed to make a ClientBlobRequest from an open blob""" def __init__(self, blob, deferred, write_func, cancel_func, peer): self.blob = blob diff --git a/lbrynet/core/client/ClientRequest.py b/lbrynet/core/client/ClientRequest.py index 9f9854e6f..a485a9980 100644 --- a/lbrynet/core/client/ClientRequest.py +++ b/lbrynet/core/client/ClientRequest.py @@ -1,7 +1,7 @@ from lbrynet.blob.blob_file import MAX_BLOB_SIZE -class ClientRequest(object): +class ClientRequest: def __init__(self, request_dict, response_identifier=None): self.request_dict = request_dict self.response_identifier = response_identifier @@ -9,7 +9,7 @@ class ClientRequest(object): class ClientPaidRequest(ClientRequest): def __init__(self, request_dict, response_identifier, max_pay_units): - ClientRequest.__init__(self, request_dict, response_identifier) + super().__init__(request_dict, response_identifier) self.max_pay_units = max_pay_units @@ -20,7 +20,7 @@ class ClientBlobRequest(ClientPaidRequest): max_pay_units = MAX_BLOB_SIZE else: max_pay_units = blob.length - ClientPaidRequest.__init__(self, request_dict, response_identifier, max_pay_units) + super().__init__(request_dict, response_identifier, max_pay_units) self.write = write_func self.finished_deferred = finished_deferred self.cancel = cancel_func diff --git a/lbrynet/core/client/ConnectionManager.py b/lbrynet/core/client/ConnectionManager.py index 357567e3c..a84f9b257 100644 --- a/lbrynet/core/client/ConnectionManager.py +++ b/lbrynet/core/client/ConnectionManager.py @@ -9,14 +9,14 @@ from lbrynet.core import utils log = logging.getLogger(__name__) -class PeerConnectionHandler(object): +class PeerConnectionHandler: def __init__(self, request_creators, factory): self.request_creators = request_creators self.factory = factory self.connection = None -class ConnectionManager(object): +class ConnectionManager: #implements(interfaces.IConnectionManager) MANAGE_CALL_INTERVAL_SEC = 5 TCP_CONNECT_TIMEOUT = 15 diff --git a/lbrynet/core/client/DownloadManager.py b/lbrynet/core/client/DownloadManager.py index 9c1673fe9..a42016d66 100644 --- a/lbrynet/core/client/DownloadManager.py +++ b/lbrynet/core/client/DownloadManager.py @@ -5,7 +5,7 @@ from twisted.internet import defer log = logging.getLogger(__name__) -class DownloadManager(object): +class DownloadManager: #implements(interfaces.IDownloadManager) def __init__(self, blob_manager): diff --git a/lbrynet/core/client/StandaloneBlobDownloader.py b/lbrynet/core/client/StandaloneBlobDownloader.py index 45bd30f8b..a0b52ef48 100644 --- a/lbrynet/core/client/StandaloneBlobDownloader.py +++ b/lbrynet/core/client/StandaloneBlobDownloader.py @@ -12,7 +12,7 @@ from twisted.internet.task import LoopingCall log = logging.getLogger(__name__) -class SingleBlobMetadataHandler(object): +class SingleBlobMetadataHandler: #implements(interfaces.IMetadataHandler) def __init__(self, blob_hash, download_manager): @@ -29,7 +29,7 @@ class SingleBlobMetadataHandler(object): return 0 -class SingleProgressManager(object): +class SingleProgressManager: def __init__(self, download_manager, finished_callback, timeout_callback, timeout): self.finished_callback = finished_callback self.timeout_callback = timeout_callback @@ -72,7 +72,7 @@ class SingleProgressManager(object): return [b for b in blobs.values() if not b.get_is_verified()] -class DummyBlobHandler(object): +class DummyBlobHandler: def __init__(self): pass @@ -80,7 +80,7 @@ class DummyBlobHandler(object): pass -class StandaloneBlobDownloader(object): +class StandaloneBlobDownloader: def __init__(self, blob_hash, blob_manager, peer_finder, rate_limiter, payment_rate_manager, wallet, timeout=None): diff --git a/lbrynet/core/client/StreamProgressManager.py b/lbrynet/core/client/StreamProgressManager.py index b8cf32811..f7749b666 100644 --- a/lbrynet/core/client/StreamProgressManager.py +++ b/lbrynet/core/client/StreamProgressManager.py @@ -5,7 +5,7 @@ from twisted.internet import defer log = logging.getLogger(__name__) -class StreamProgressManager(object): +class StreamProgressManager: #implements(IProgressManager) def __init__(self, finished_callback, blob_manager, @@ -80,8 +80,8 @@ class StreamProgressManager(object): class FullStreamProgressManager(StreamProgressManager): def __init__(self, finished_callback, blob_manager, download_manager, delete_blob_after_finished=False): - StreamProgressManager.__init__(self, finished_callback, blob_manager, download_manager, - delete_blob_after_finished) + super().__init__(finished_callback, blob_manager, download_manager, + delete_blob_after_finished) self.outputting_d = None ######### IProgressManager ######### diff --git a/lbrynet/core/log_support.py b/lbrynet/core/log_support.py index 7b192136f..50444d125 100644 --- a/lbrynet/core/log_support.py +++ b/lbrynet/core/log_support.py @@ -14,7 +14,7 @@ from lbrynet.core import utils class HTTPSHandler(logging.Handler): def __init__(self, url, fqdn=False, localname=None, facility=None, cookies=None): - logging.Handler.__init__(self) + super().__init__() self.url = url self.fqdn = fqdn self.localname = localname @@ -243,7 +243,7 @@ def configure_twisted(): observer.start() -class LoggerNameFilter(object): +class LoggerNameFilter: """Filter a log record based on its name. Allows all info level and higher records to pass thru. diff --git a/lbrynet/core/looping_call_manager.py b/lbrynet/core/looping_call_manager.py index fa7b9a924..fb4c460b4 100644 --- a/lbrynet/core/looping_call_manager.py +++ b/lbrynet/core/looping_call_manager.py @@ -1,4 +1,4 @@ -class LoopingCallManager(object): +class LoopingCallManager: def __init__(self, calls=None): self.calls = calls or {} diff --git a/lbrynet/core/server/BlobAvailabilityHandler.py b/lbrynet/core/server/BlobAvailabilityHandler.py index e8530d612..4e8183a88 100644 --- a/lbrynet/core/server/BlobAvailabilityHandler.py +++ b/lbrynet/core/server/BlobAvailabilityHandler.py @@ -7,7 +7,7 @@ from lbrynet.interfaces import IQueryHandlerFactory, IQueryHandler log = logging.getLogger(__name__) -class BlobAvailabilityHandlerFactory(object): +class BlobAvailabilityHandlerFactory: implements(IQueryHandlerFactory) def __init__(self, blob_manager): @@ -26,7 +26,7 @@ class BlobAvailabilityHandlerFactory(object): return "Blob Availability - blobs that are available to be uploaded" -class BlobAvailabilityHandler(object): +class BlobAvailabilityHandler: implements(IQueryHandler) def __init__(self, blob_manager): diff --git a/lbrynet/core/server/BlobRequestHandler.py b/lbrynet/core/server/BlobRequestHandler.py index d6a4edb5b..405402c9a 100644 --- a/lbrynet/core/server/BlobRequestHandler.py +++ b/lbrynet/core/server/BlobRequestHandler.py @@ -10,7 +10,7 @@ from lbrynet.core.Offer import Offer log = logging.getLogger(__name__) -class BlobRequestHandlerFactory(object): +class BlobRequestHandlerFactory: #implements(IQueryHandlerFactory) def __init__(self, blob_manager, wallet, payment_rate_manager, analytics_manager): @@ -33,7 +33,7 @@ class BlobRequestHandlerFactory(object): return "Blob Uploader - uploads blobs" -class BlobRequestHandler(object): +class BlobRequestHandler: #implements(IQueryHandler, IBlobSender) PAYMENT_RATE_QUERY = 'blob_data_payment_rate' BLOB_QUERY = 'requested_blob' diff --git a/lbrynet/core/server/ServerRequestHandler.py b/lbrynet/core/server/ServerRequestHandler.py index 3ed65023e..f7485b66c 100644 --- a/lbrynet/core/server/ServerRequestHandler.py +++ b/lbrynet/core/server/ServerRequestHandler.py @@ -6,7 +6,7 @@ from twisted.internet import defer log = logging.getLogger(__name__) -class ServerRequestHandler(object): +class ServerRequestHandler: """This class handles requests from clients. It can upload blobs and return request for information about more blobs that are associated with streams. diff --git a/lbrynet/core/utils.py b/lbrynet/core/utils.py index 72eacee55..f05b6cc45 100644 --- a/lbrynet/core/utils.py +++ b/lbrynet/core/utils.py @@ -155,7 +155,7 @@ def json_dumps_pretty(obj, **kwargs): return json.dumps(obj, sort_keys=True, indent=2, separators=(',', ': '), **kwargs) -class DeferredLockContextManager(object): +class DeferredLockContextManager: def __init__(self, lock): self._lock = lock @@ -181,7 +181,7 @@ def DeferredDict(d, consumeErrors=False): defer.returnValue(response) -class DeferredProfiler(object): +class DeferredProfiler: def __init__(self): self.profile_results = {} diff --git a/lbrynet/cryptstream/CryptBlob.py b/lbrynet/cryptstream/CryptBlob.py index eb6ab8404..089139352 100644 --- a/lbrynet/cryptstream/CryptBlob.py +++ b/lbrynet/cryptstream/CryptBlob.py @@ -16,7 +16,7 @@ backend = default_backend() class CryptBlobInfo(BlobInfo): def __init__(self, blob_hash, blob_num, length, iv): - BlobInfo.__init__(self, blob_hash, blob_num, length) + super().__init__(blob_hash, blob_num, length) self.iv = iv def get_dict(self): @@ -30,7 +30,7 @@ class CryptBlobInfo(BlobInfo): return info -class StreamBlobDecryptor(object): +class StreamBlobDecryptor: def __init__(self, blob, key, iv, length): """ This class decrypts blob @@ -99,7 +99,7 @@ class StreamBlobDecryptor(object): return d -class CryptStreamBlobMaker(object): +class CryptStreamBlobMaker: def __init__(self, key, iv, blob_num, blob): """ This class encrypts data and writes it to a new blob diff --git a/lbrynet/cryptstream/CryptStreamCreator.py b/lbrynet/cryptstream/CryptStreamCreator.py index b41545601..ce15f2f07 100644 --- a/lbrynet/cryptstream/CryptStreamCreator.py +++ b/lbrynet/cryptstream/CryptStreamCreator.py @@ -12,7 +12,7 @@ from lbrynet.cryptstream.CryptBlob import CryptStreamBlobMaker log = logging.getLogger(__name__) -class CryptStreamCreator(object): +class CryptStreamCreator: """ Create a new stream with blobs encrypted by a symmetric cipher. diff --git a/lbrynet/cryptstream/client/CryptBlobHandler.py b/lbrynet/cryptstream/client/CryptBlobHandler.py index b6e2c413c..6f7ae2adb 100644 --- a/lbrynet/cryptstream/client/CryptBlobHandler.py +++ b/lbrynet/cryptstream/client/CryptBlobHandler.py @@ -3,7 +3,7 @@ from twisted.internet import defer from lbrynet.cryptstream.CryptBlob import StreamBlobDecryptor -class CryptBlobHandler(object): +class CryptBlobHandler: #implements(IBlobHandler) def __init__(self, key, write_func): diff --git a/lbrynet/cryptstream/client/CryptStreamDownloader.py b/lbrynet/cryptstream/client/CryptStreamDownloader.py index 5b1dc049d..6439d9247 100644 --- a/lbrynet/cryptstream/client/CryptStreamDownloader.py +++ b/lbrynet/cryptstream/client/CryptStreamDownloader.py @@ -32,7 +32,7 @@ class CurrentlyStartingError(Exception): pass -class CryptStreamDownloader(object): +class CryptStreamDownloader: #implements(IStreamDownloader) diff --git a/lbrynet/daemon/Component.py b/lbrynet/daemon/Component.py index 051189f40..03f03ddf5 100644 --- a/lbrynet/daemon/Component.py +++ b/lbrynet/daemon/Component.py @@ -14,7 +14,7 @@ class ComponentType(type): return klass -class Component(object, metaclass=ComponentType): +class Component(metaclass=ComponentType): """ lbrynet-daemon component helper diff --git a/lbrynet/daemon/Components.py b/lbrynet/daemon/Components.py index 424290ed4..8e5f615c3 100644 --- a/lbrynet/daemon/Components.py +++ b/lbrynet/daemon/Components.py @@ -68,7 +68,7 @@ def get_wallet_config(): return config -class ConfigSettings(object): +class ConfigSettings: @staticmethod def get_conf_setting(setting_name): return conf.settings[setting_name] @@ -101,7 +101,7 @@ class DatabaseComponent(Component): component_name = DATABASE_COMPONENT def __init__(self, component_manager): - Component.__init__(self, component_manager) + super().__init__(component_manager) self.storage = None @property @@ -306,7 +306,7 @@ class WalletComponent(Component): depends_on = [DATABASE_COMPONENT, HEADERS_COMPONENT] def __init__(self, component_manager): - Component.__init__(self, component_manager) + super().__init__(component_manager) self.wallet = None @property @@ -329,6 +329,7 @@ class WalletComponent(Component): @defer.inlineCallbacks def start(self): + log.info("Starting torba wallet") storage = self.component_manager.get_component(DATABASE_COMPONENT) lbryschema.BLOCKCHAIN_NAME = conf.settings['blockchain_name'] self.wallet = LbryWalletManager.from_old_config(conf.settings) @@ -346,7 +347,7 @@ class BlobComponent(Component): depends_on = [DATABASE_COMPONENT, DHT_COMPONENT] def __init__(self, component_manager): - Component.__init__(self, component_manager) + super().__init__(component_manager) self.blob_manager = None @property @@ -377,7 +378,7 @@ class DHTComponent(Component): depends_on = [UPNP_COMPONENT] def __init__(self, component_manager): - Component.__init__(self, component_manager) + super().__init__(component_manager) self.dht_node = None self.upnp_component = None self.external_udp_port = None @@ -427,7 +428,7 @@ class HashAnnouncerComponent(Component): depends_on = [DHT_COMPONENT, DATABASE_COMPONENT] def __init__(self, component_manager): - Component.__init__(self, component_manager) + super().__init__(component_manager) self.hash_announcer = None @property @@ -455,7 +456,7 @@ class RateLimiterComponent(Component): component_name = RATE_LIMITER_COMPONENT def __init__(self, component_manager): - Component.__init__(self, component_manager) + super().__init__(component_manager) self.rate_limiter = RateLimiter() @property @@ -476,7 +477,7 @@ class StreamIdentifierComponent(Component): depends_on = [DHT_COMPONENT, RATE_LIMITER_COMPONENT, BLOB_COMPONENT, DATABASE_COMPONENT, WALLET_COMPONENT] def __init__(self, component_manager): - Component.__init__(self, component_manager) + super().__init__(component_manager) self.sd_identifier = StreamDescriptorIdentifier() @property @@ -510,7 +511,7 @@ class PaymentRateComponent(Component): component_name = PAYMENT_RATE_COMPONENT def __init__(self, component_manager): - Component.__init__(self, component_manager) + super().__init__(component_manager) self.payment_rate_manager = OnlyFreePaymentsManager() @property @@ -530,7 +531,7 @@ class FileManagerComponent(Component): STREAM_IDENTIFIER_COMPONENT, PAYMENT_RATE_COMPONENT] def __init__(self, component_manager): - Component.__init__(self, component_manager) + super().__init__(component_manager) self.file_manager = None @property @@ -570,7 +571,7 @@ class PeerProtocolServerComponent(Component): PAYMENT_RATE_COMPONENT] def __init__(self, component_manager): - Component.__init__(self, component_manager) + super().__init__(component_manager) self.lbry_server_port = None @property @@ -622,7 +623,7 @@ class ReflectorComponent(Component): depends_on = [DHT_COMPONENT, BLOB_COMPONENT, FILE_MANAGER_COMPONENT] def __init__(self, component_manager): - Component.__init__(self, component_manager) + super().__init__(component_manager) self.reflector_server_port = GCS('reflector_port') self.reflector_server = None @@ -656,7 +657,7 @@ class UPnPComponent(Component): component_name = UPNP_COMPONENT def __init__(self, component_manager): - Component.__init__(self, component_manager) + super().__init__(component_manager) self._int_peer_port = GCS('peer_port') self._int_dht_node_port = GCS('dht_node_port') self.use_upnp = GCS('use_upnp') diff --git a/lbrynet/daemon/Daemon.py b/lbrynet/daemon/Daemon.py index cfe21382f..1e679b651 100644 --- a/lbrynet/daemon/Daemon.py +++ b/lbrynet/daemon/Daemon.py @@ -77,8 +77,7 @@ DIRECTION_ASCENDING = 'asc' DIRECTION_DESCENDING = 'desc' DIRECTIONS = DIRECTION_ASCENDING, DIRECTION_DESCENDING - -class IterableContainer(object): +class IterableContainer: def __iter__(self): for attr in dir(self): if not attr.startswith("_"): @@ -91,7 +90,7 @@ class IterableContainer(object): return False -class Checker(object): +class Checker: """The looping calls the daemon runs""" INTERNET_CONNECTION = 'internet_connection_checker', 300 # CONNECTION_STATUS = 'connection_status_checker' @@ -123,7 +122,7 @@ class NoValidSearch(Exception): pass -class CheckInternetConnection(object): +class CheckInternetConnection: def __init__(self, daemon): self.daemon = daemon @@ -131,7 +130,7 @@ class CheckInternetConnection(object): self.daemon.connected_to_internet = utils.check_connection() -class AlwaysSend(object): +class AlwaysSend: def __init__(self, value_generator, *args, **kwargs): self.value_generator = value_generator self.args = args diff --git a/lbrynet/daemon/Downloader.py b/lbrynet/daemon/Downloader.py index e554e9455..51a38a59b 100644 --- a/lbrynet/daemon/Downloader.py +++ b/lbrynet/daemon/Downloader.py @@ -29,7 +29,7 @@ STREAM_STAGES = [ log = logging.getLogger(__name__) -class GetStream(object): +class GetStream: def __init__(self, sd_identifier, wallet, exchange_rate_manager, blob_manager, peer_finder, rate_limiter, payment_rate_manager, storage, max_key_fee, disable_max_key_fee, data_rate=None, timeout=None): diff --git a/lbrynet/daemon/ExchangeRateManager.py b/lbrynet/daemon/ExchangeRateManager.py index acafe77d4..527d9eb91 100644 --- a/lbrynet/daemon/ExchangeRateManager.py +++ b/lbrynet/daemon/ExchangeRateManager.py @@ -15,7 +15,7 @@ BITTREX_FEE = 0.0025 COINBASE_FEE = 0.0 # add fee -class ExchangeRate(object): +class ExchangeRate: def __init__(self, market, spot, ts): if not int(time.time()) - ts < 600: raise ValueError('The timestamp is too dated.') @@ -34,7 +34,7 @@ class ExchangeRate(object): return {'spot': self.spot, 'ts': self.ts} -class MarketFeed(object): +class MarketFeed: REQUESTS_TIMEOUT = 20 EXCHANGE_RATE_UPDATE_RATE_SEC = 300 @@ -96,8 +96,7 @@ class MarketFeed(object): class BittrexFeed(MarketFeed): def __init__(self): - MarketFeed.__init__( - self, + super().__init__( "BTCLBC", "Bittrex", "https://bittrex.com/api/v1.1/public/getmarkethistory", @@ -122,8 +121,7 @@ class BittrexFeed(MarketFeed): class LBRYioFeed(MarketFeed): def __init__(self): - MarketFeed.__init__( - self, + super().__init__( "BTCLBC", "lbry.io", "https://api.lbry.io/lbc/exchange_rate", @@ -140,8 +138,7 @@ class LBRYioFeed(MarketFeed): class LBRYioBTCFeed(MarketFeed): def __init__(self): - MarketFeed.__init__( - self, + super().__init__( "USDBTC", "lbry.io", "https://api.lbry.io/lbc/exchange_rate", @@ -161,8 +158,7 @@ class LBRYioBTCFeed(MarketFeed): class CryptonatorBTCFeed(MarketFeed): def __init__(self): - MarketFeed.__init__( - self, + super().__init__( "USDBTC", "cryptonator.com", "https://api.cryptonator.com/api/ticker/usd-btc", @@ -183,8 +179,7 @@ class CryptonatorBTCFeed(MarketFeed): class CryptonatorFeed(MarketFeed): def __init__(self): - MarketFeed.__init__( - self, + super().__init__( "BTCLBC", "cryptonator.com", "https://api.cryptonator.com/api/ticker/btc-lbc", @@ -203,7 +198,7 @@ class CryptonatorFeed(MarketFeed): return defer.succeed(float(json_response['ticker']['price'])) -class ExchangeRateManager(object): +class ExchangeRateManager: def __init__(self): self.market_feeds = [ LBRYioBTCFeed(), diff --git a/lbrynet/daemon/Publisher.py b/lbrynet/daemon/Publisher.py index 9456d7f23..ee7045cfc 100644 --- a/lbrynet/daemon/Publisher.py +++ b/lbrynet/daemon/Publisher.py @@ -12,7 +12,7 @@ from lbrynet.wallet.account import get_certificate_lookup log = logging.getLogger(__name__) -class Publisher(object): +class Publisher: def __init__(self, blob_manager, payment_rate_manager, storage, lbry_file_manager, wallet, certificate): self.blob_manager = blob_manager self.payment_rate_manager = payment_rate_manager diff --git a/lbrynet/daemon/auth/auth.py b/lbrynet/daemon/auth/auth.py index 368a4ccde..061e5b55f 100644 --- a/lbrynet/daemon/auth/auth.py +++ b/lbrynet/daemon/auth/auth.py @@ -9,7 +9,7 @@ log = logging.getLogger(__name__) @implementer(portal.IRealm) -class HttpPasswordRealm(object): +class HttpPasswordRealm: def __init__(self, resource): self.resource = resource @@ -21,7 +21,7 @@ class HttpPasswordRealm(object): @implementer(checkers.ICredentialsChecker) -class PasswordChecker(object): +class PasswordChecker: credentialInterfaces = (credentials.IUsernamePassword,) def __init__(self, passwords): diff --git a/lbrynet/daemon/auth/client.py b/lbrynet/daemon/auth/client.py index 6c81eb686..a9c375080 100644 --- a/lbrynet/daemon/auth/client.py +++ b/lbrynet/daemon/auth/client.py @@ -23,11 +23,11 @@ def copy_cookies(cookies): class JSONRPCException(Exception): def __init__(self, rpc_error): - Exception.__init__(self) + super().__init__() self.error = rpc_error -class AuthAPIClient(object): +class AuthAPIClient: def __init__(self, key, timeout, connection, count, cookies, url, login_url): self.__api_key = key self.__service_url = login_url @@ -130,7 +130,7 @@ class AuthAPIClient(object): return cls(api_key, timeout, conn, id_count, cookies, url, service_url) -class LBRYAPIClient(object): +class LBRYAPIClient: @staticmethod def get_client(): if not conf.settings: diff --git a/lbrynet/daemon/auth/server.py b/lbrynet/daemon/auth/server.py index 74766e262..a8916528e 100644 --- a/lbrynet/daemon/auth/server.py +++ b/lbrynet/daemon/auth/server.py @@ -27,7 +27,7 @@ log = logging.getLogger(__name__) EMPTY_PARAMS = [{}] -class JSONRPCError(object): +class JSONRPCError: # http://www.jsonrpc.org/specification#error_object CODE_PARSE_ERROR = -32700 # Invalid JSON. Error while parsing the JSON text. CODE_INVALID_REQUEST = -32600 # The JSON sent is not a valid Request object. @@ -129,7 +129,7 @@ class JSONRPCServerType(type): return klass -class AuthorizedBase(object, metaclass=JSONRPCServerType): +class AuthorizedBase(metaclass=JSONRPCServerType): @staticmethod def deprecated(new_command=None): diff --git a/lbrynet/daemon/auth/util.py b/lbrynet/daemon/auth/util.py index 3e12d2b51..ade95c3bd 100644 --- a/lbrynet/daemon/auth/util.py +++ b/lbrynet/daemon/auth/util.py @@ -24,7 +24,7 @@ def generate_key(x=None): return sha(x) -class APIKey(object): +class APIKey: def __init__(self, secret, name, expiration=None): self.secret = secret self.name = name diff --git a/lbrynet/database/storage.py b/lbrynet/database/storage.py index fc3804671..9784c34b5 100644 --- a/lbrynet/database/storage.py +++ b/lbrynet/database/storage.py @@ -85,11 +85,11 @@ def rerun_if_locked(f): class SqliteConnection(adbapi.ConnectionPool): def __init__(self, db_path): - adbapi.ConnectionPool.__init__(self, 'sqlite3', db_path, check_same_thread=False) + super().__init__('sqlite3', db_path, check_same_thread=False) @rerun_if_locked def runInteraction(self, interaction, *args, **kw): - return adbapi.ConnectionPool.runInteraction(self, interaction, *args, **kw) + return super().runInteraction(interaction, *args, **kw) @classmethod def set_reactor(cls, reactor): diff --git a/lbrynet/dht/contact.py b/lbrynet/dht/contact.py index ae6881e95..9497cfa70 100644 --- a/lbrynet/dht/contact.py +++ b/lbrynet/dht/contact.py @@ -13,7 +13,7 @@ def is_valid_ipv4(address): return False -class _Contact(object): +class _Contact: """ Encapsulation for remote contact This class contains information on a single remote contact, and also @@ -167,7 +167,7 @@ class _Contact(object): return _sendRPC -class ContactManager(object): +class ContactManager: def __init__(self, get_time=None): if not get_time: from twisted.internet import reactor diff --git a/lbrynet/dht/distance.py b/lbrynet/dht/distance.py index f603c7c2d..917928211 100644 --- a/lbrynet/dht/distance.py +++ b/lbrynet/dht/distance.py @@ -6,7 +6,7 @@ if sys.version_info > (3,): long = int -class Distance(object): +class Distance: """Calculate the XOR result between two string variables. Frequently we re-use one of the points so as an optimization diff --git a/lbrynet/dht/encoding.py b/lbrynet/dht/encoding.py index b39636638..e868ca582 100644 --- a/lbrynet/dht/encoding.py +++ b/lbrynet/dht/encoding.py @@ -7,7 +7,7 @@ if sys.version_info > (3,): else: raw = lambda x: x -class Encoding(object): +class Encoding: """ Interface for RPC message encoders/decoders All encoding implementations used with this library should inherit and diff --git a/lbrynet/dht/error.py b/lbrynet/dht/error.py index 7816a836d..f61b7944f 100644 --- a/lbrynet/dht/error.py +++ b/lbrynet/dht/error.py @@ -37,7 +37,7 @@ class TimeoutError(Exception): msg = 'Timeout connecting to {}'.format(binascii.hexlify(remote_contact_id)) else: msg = 'Timeout connecting to uninitialized node' - Exception.__init__(self, msg) + super().__init__(msg) self.remote_contact_id = remote_contact_id diff --git a/lbrynet/dht/hashannouncer.py b/lbrynet/dht/hashannouncer.py index 9f8995da5..d78e56ad2 100644 --- a/lbrynet/dht/hashannouncer.py +++ b/lbrynet/dht/hashannouncer.py @@ -8,7 +8,7 @@ from lbrynet import conf log = logging.getLogger(__name__) -class DHTHashAnnouncer(object): +class DHTHashAnnouncer: def __init__(self, dht_node, storage, concurrent_announcers=None): self.dht_node = dht_node self.storage = storage diff --git a/lbrynet/dht/iterativefind.py b/lbrynet/dht/iterativefind.py index eb901df22..d6039d5dd 100644 --- a/lbrynet/dht/iterativefind.py +++ b/lbrynet/dht/iterativefind.py @@ -22,7 +22,7 @@ def expand_peer(compact_peer_info): return (peer_node_id, host, port) -class _IterativeFind(object): +class _IterativeFind: # TODO: use polymorphism to search for a value or node # instead of using a find_value flag def __init__(self, node, shortlist, key, rpc, exclude=None): diff --git a/lbrynet/dht/kbucket.py b/lbrynet/dht/kbucket.py index d064fb60e..4fe424bee 100644 --- a/lbrynet/dht/kbucket.py +++ b/lbrynet/dht/kbucket.py @@ -11,7 +11,7 @@ if sys.version_info > (3,): log = logging.getLogger(__name__) -class KBucket(object): +class KBucket: """ Description - later """ diff --git a/lbrynet/dht/msgformat.py b/lbrynet/dht/msgformat.py index 3ab1c91d3..fc4381d1c 100644 --- a/lbrynet/dht/msgformat.py +++ b/lbrynet/dht/msgformat.py @@ -10,7 +10,7 @@ from . import msgtypes -class MessageTranslator(object): +class MessageTranslator: """ Interface for RPC message translators/formatters Classes inheriting from this should provide a translation services between diff --git a/lbrynet/dht/msgtypes.py b/lbrynet/dht/msgtypes.py index 10bc784ad..b33f0c035 100644 --- a/lbrynet/dht/msgtypes.py +++ b/lbrynet/dht/msgtypes.py @@ -11,7 +11,7 @@ from lbrynet.core.utils import generate_id from . import constants -class Message(object): +class Message: """ Base class for messages - all "unknown" messages use this class """ def __init__(self, rpcID, nodeID): @@ -29,7 +29,7 @@ class RequestMessage(Message): def __init__(self, nodeID, method, methodArgs, rpcID=None): if rpcID is None: rpcID = generate_id()[:constants.rpc_id_length] - Message.__init__(self, rpcID, nodeID) + super().__init__(rpcID, nodeID) self.request = method self.args = methodArgs @@ -38,7 +38,7 @@ class ResponseMessage(Message): """ Message containing the result from a successful RPC request """ def __init__(self, rpcID, nodeID, response): - Message.__init__(self, rpcID, nodeID) + super().__init__(rpcID, nodeID) self.response = response @@ -46,7 +46,7 @@ class ErrorMessage(ResponseMessage): """ Message containing the error from an unsuccessful RPC request """ def __init__(self, rpcID, nodeID, exceptionType, errorMessage): - ResponseMessage.__init__(self, rpcID, nodeID, errorMessage) + super().__init__(rpcID, nodeID, errorMessage) if isinstance(exceptionType, type): exceptionType = ('%s.%s' % (exceptionType.__module__, exceptionType.__name__)).encode() self.exceptionType = exceptionType diff --git a/lbrynet/dht/node.py b/lbrynet/dht/node.py index d32a3e5ed..118872844 100644 --- a/lbrynet/dht/node.py +++ b/lbrynet/dht/node.py @@ -47,7 +47,7 @@ def rpcmethod(func): return func -class MockKademliaHelper(object): +class MockKademliaHelper: def __init__(self, clock=None, callLater=None, resolve=None, listenUDP=None): if not listenUDP or not resolve or not callLater or not clock: from twisted.internet import reactor @@ -127,7 +127,7 @@ class Node(MockKademliaHelper): @param peerPort: the port at which this node announces it has a blob for """ - MockKademliaHelper.__init__(self, clock, callLater, resolve, listenUDP) + super().__init__(clock, callLater, resolve, listenUDP) self.node_id = node_id or self._generateID() self.port = udpPort self._listen_interface = interface diff --git a/lbrynet/dht/peerfinder.py b/lbrynet/dht/peerfinder.py index 4929e6b94..8ddb846da 100644 --- a/lbrynet/dht/peerfinder.py +++ b/lbrynet/dht/peerfinder.py @@ -8,7 +8,7 @@ from lbrynet import conf log = logging.getLogger(__name__) -class DummyPeerFinder(object): +class DummyPeerFinder: """This class finds peers which have announced to the DHT that they have certain blobs""" def find_peers_for_blob(self, blob_hash, timeout=None, filter_self=True): diff --git a/lbrynet/dht/protocol.py b/lbrynet/dht/protocol.py index 464a254ca..a8a9ab91d 100644 --- a/lbrynet/dht/protocol.py +++ b/lbrynet/dht/protocol.py @@ -15,7 +15,7 @@ from . import msgformat log = logging.getLogger(__name__) -class PingQueue(object): +class PingQueue: """ Schedules a 15 minute delayed ping after a new node sends us a query. This is so the new node gets added to the routing table after having been given enough time for a pinhole to expire. diff --git a/lbrynet/dht/routingtable.py b/lbrynet/dht/routingtable.py index e2ade251f..6f228c532 100644 --- a/lbrynet/dht/routingtable.py +++ b/lbrynet/dht/routingtable.py @@ -16,7 +16,7 @@ import logging log = logging.getLogger(__name__) -class TreeRoutingTable(object): +class TreeRoutingTable: """ This class implements a routing table used by a Node class. The Kademlia routing table is a binary tree whFose leaves are k-buckets, diff --git a/lbrynet/file_manager/EncryptedFileCreator.py b/lbrynet/file_manager/EncryptedFileCreator.py index 91ab26d93..888c7fec7 100644 --- a/lbrynet/file_manager/EncryptedFileCreator.py +++ b/lbrynet/file_manager/EncryptedFileCreator.py @@ -24,7 +24,7 @@ class EncryptedFileStreamCreator(CryptStreamCreator): def __init__(self, blob_manager, lbry_file_manager, stream_name=None, key=None, iv_generator=None): - CryptStreamCreator.__init__(self, blob_manager, stream_name, key, iv_generator) + super().__init__(blob_manager, stream_name, key, iv_generator) self.lbry_file_manager = lbry_file_manager self.stream_hash = None self.blob_infos = [] diff --git a/lbrynet/file_manager/EncryptedFileDownloader.py b/lbrynet/file_manager/EncryptedFileDownloader.py index af7f3af58..afe394784 100644 --- a/lbrynet/file_manager/EncryptedFileDownloader.py +++ b/lbrynet/file_manager/EncryptedFileDownloader.py @@ -37,8 +37,8 @@ class ManagedEncryptedFileDownloader(EncryptedFileSaver): def __init__(self, rowid, stream_hash, peer_finder, rate_limiter, blob_manager, storage, lbry_file_manager, payment_rate_manager, wallet, download_directory, file_name, stream_name, sd_hash, key, suggested_file_name, download_mirrors=None): - EncryptedFileSaver.__init__( - self, stream_hash, peer_finder, rate_limiter, blob_manager, storage, payment_rate_manager, wallet, + super().__init__( + stream_hash, peer_finder, rate_limiter, blob_manager, storage, payment_rate_manager, wallet, download_directory, key, stream_name, file_name ) self.sd_hash = sd_hash @@ -160,7 +160,7 @@ class ManagedEncryptedFileDownloader(EncryptedFileSaver): self.blob_manager, download_manager) -class ManagedEncryptedFileDownloaderFactory(object): +class ManagedEncryptedFileDownloaderFactory: #implements(IStreamDownloaderFactory) def __init__(self, lbry_file_manager, blob_manager): diff --git a/lbrynet/file_manager/EncryptedFileManager.py b/lbrynet/file_manager/EncryptedFileManager.py index e2175ee39..81e453f74 100644 --- a/lbrynet/file_manager/EncryptedFileManager.py +++ b/lbrynet/file_manager/EncryptedFileManager.py @@ -19,7 +19,7 @@ from lbrynet import conf log = logging.getLogger(__name__) -class EncryptedFileManager(object): +class EncryptedFileManager: """ Keeps track of currently opened LBRY Files, their options, and their LBRY File specific metadata. diff --git a/lbrynet/file_manager/EncryptedFileStatusReport.py b/lbrynet/file_manager/EncryptedFileStatusReport.py index 61d61a2a3..467f965dd 100644 --- a/lbrynet/file_manager/EncryptedFileStatusReport.py +++ b/lbrynet/file_manager/EncryptedFileStatusReport.py @@ -1,4 +1,4 @@ -class EncryptedFileStatusReport(object): +class EncryptedFileStatusReport: def __init__(self, name, num_completed, num_known, running_status): self.name = name self.num_completed = num_completed diff --git a/lbrynet/lbry_file/client/EncryptedFileDownloader.py b/lbrynet/lbry_file/client/EncryptedFileDownloader.py index a0507cda5..e84e91119 100644 --- a/lbrynet/lbry_file/client/EncryptedFileDownloader.py +++ b/lbrynet/lbry_file/client/EncryptedFileDownloader.py @@ -18,8 +18,8 @@ class EncryptedFileDownloader(CryptStreamDownloader): def __init__(self, stream_hash, peer_finder, rate_limiter, blob_manager, storage, payment_rate_manager, wallet, key, stream_name, file_name): - CryptStreamDownloader.__init__(self, peer_finder, rate_limiter, blob_manager, - payment_rate_manager, wallet, key, stream_name) + super().__init__(peer_finder, rate_limiter, blob_manager, + payment_rate_manager, wallet, key, stream_name) self.stream_hash = stream_hash self.storage = storage self.file_name = os.path.basename(binascii.unhexlify(file_name)) @@ -87,7 +87,7 @@ class EncryptedFileDownloader(CryptStreamDownloader): self.storage, download_manager) -class EncryptedFileDownloaderFactory(object): +class EncryptedFileDownloaderFactory: #implements(IStreamDownloaderFactory) def __init__(self, peer_finder, rate_limiter, blob_manager, storage, wallet): @@ -125,9 +125,9 @@ class EncryptedFileDownloaderFactory(object): class EncryptedFileSaver(EncryptedFileDownloader): def __init__(self, stream_hash, peer_finder, rate_limiter, blob_manager, storage, payment_rate_manager, wallet, download_directory, key, stream_name, file_name): - EncryptedFileDownloader.__init__(self, stream_hash, peer_finder, rate_limiter, - blob_manager, storage, payment_rate_manager, - wallet, key, stream_name, file_name) + super().__init__(stream_hash, peer_finder, rate_limiter, + blob_manager, storage, payment_rate_manager, + wallet, key, stream_name, file_name) self.download_directory = binascii.unhexlify(download_directory) self.file_written_to = os.path.join(self.download_directory, binascii.unhexlify(file_name)) self.file_handle = None @@ -180,7 +180,7 @@ class EncryptedFileSaver(EncryptedFileDownloader): class EncryptedFileSaverFactory(EncryptedFileDownloaderFactory): def __init__(self, peer_finder, rate_limiter, blob_manager, storage, wallet, download_directory): - EncryptedFileDownloaderFactory.__init__(self, peer_finder, rate_limiter, blob_manager, storage, wallet) + super().__init__(peer_finder, rate_limiter, blob_manager, storage, wallet) self.download_directory = binascii.hexlify(download_directory.encode()) def _make_downloader(self, stream_hash, payment_rate_manager, stream_info): diff --git a/lbrynet/lbry_file/client/EncryptedFileMetadataHandler.py b/lbrynet/lbry_file/client/EncryptedFileMetadataHandler.py index 12de48292..ec763fabc 100644 --- a/lbrynet/lbry_file/client/EncryptedFileMetadataHandler.py +++ b/lbrynet/lbry_file/client/EncryptedFileMetadataHandler.py @@ -5,7 +5,7 @@ from twisted.internet import defer log = logging.getLogger(__name__) -class EncryptedFileMetadataHandler(object): +class EncryptedFileMetadataHandler: def __init__(self, stream_hash, storage, download_manager): self.stream_hash = stream_hash diff --git a/lbrynet/lbry_file/client/EncryptedFileOptions.py b/lbrynet/lbry_file/client/EncryptedFileOptions.py index 963e5b69d..fbc0d93b6 100644 --- a/lbrynet/lbry_file/client/EncryptedFileOptions.py +++ b/lbrynet/lbry_file/client/EncryptedFileOptions.py @@ -8,7 +8,7 @@ def add_lbry_file_to_sd_identifier(sd_identifier): EncryptedFileOptions()) -class EncryptedFileOptions(object): +class EncryptedFileOptions: def __init__(self): pass diff --git a/lbrynet/wallet/account.py b/lbrynet/wallet/account.py index 69e16e2ac..656447e72 100644 --- a/lbrynet/wallet/account.py +++ b/lbrynet/wallet/account.py @@ -28,7 +28,7 @@ def get_certificate_lookup(tx_or_hash, nout): class Account(BaseAccount): def __init__(self, *args, **kwargs): - super(Account, self).__init__(*args, **kwargs) + super().__init__(*args, **kwargs) self.certificates = {} def add_certificate_private_key(self, tx_or_hash, nout, private_key): @@ -73,20 +73,20 @@ class Account(BaseAccount): def get_balance(self, confirmations=6, include_claims=False, **constraints): if not include_claims: constraints.update({'is_claim': 0, 'is_update': 0, 'is_support': 0}) - return super(Account, self).get_balance(confirmations, **constraints) + return super().get_balance(confirmations, **constraints) def get_unspent_outputs(self, include_claims=False, **constraints): if not include_claims: constraints.update({'is_claim': 0, 'is_update': 0, 'is_support': 0}) - return super(Account, self).get_unspent_outputs(**constraints) + return super().get_unspent_outputs(**constraints) @classmethod def from_dict(cls, ledger, d): # type: (torba.baseledger.BaseLedger, Dict) -> BaseAccount - account = super(Account, cls).from_dict(ledger, d) + account = super().from_dict(ledger, d) account.certificates = d['certificates'] return account def to_dict(self): - d = super(Account, self).to_dict() + d = super().to_dict() d['certificates'] = self.certificates return d diff --git a/lbrynet/wallet/database.py b/lbrynet/wallet/database.py index a2bdd595a..565fd0e45 100644 --- a/lbrynet/wallet/database.py +++ b/lbrynet/wallet/database.py @@ -32,7 +32,7 @@ class WalletDatabase(BaseDatabase): ) def txo_to_row(self, tx, address, txo): - row = super(WalletDatabase, self).txo_to_row(tx, address, txo) + row = super().txo_to_row(tx, address, txo) row.update({ 'is_claim': txo.script.is_claim_name, 'is_update': txo.script.is_update_claim, diff --git a/lbrynet/wallet/ledger.py b/lbrynet/wallet/ledger.py index c0cdb0434..8aab1248b 100644 --- a/lbrynet/wallet/ledger.py +++ b/lbrynet/wallet/ledger.py @@ -125,13 +125,13 @@ class MainNetLedger(BaseLedger): default_fee_per_name_char = 200000 def __init__(self, *args, **kwargs): - super(MainNetLedger, self).__init__(*args, **kwargs) + super().__init__(*args, **kwargs) self.fee_per_name_char = self.config.get('fee_per_name_char', self.default_fee_per_name_char) def get_transaction_base_fee(self, tx): """ Fee for the transaction header and all outputs; without inputs. """ return max( - super(MainNetLedger, self).get_transaction_base_fee(tx), + super().get_transaction_base_fee(tx), self.get_transaction_claim_name_fee(tx) ) @@ -156,7 +156,7 @@ class MainNetLedger(BaseLedger): @defer.inlineCallbacks def start(self): - yield super(MainNetLedger, self).start() + yield super().start() yield defer.DeferredList([ a.maybe_migrate_certificates() for a in self.accounts ]) diff --git a/lbrynet/wallet/manager.py b/lbrynet/wallet/manager.py index 2c2c41a88..f8d5a7668 100644 --- a/lbrynet/wallet/manager.py +++ b/lbrynet/wallet/manager.py @@ -20,7 +20,7 @@ if six.PY3: buffer = memoryview -class BackwardsCompatibleNetwork(object): +class BackwardsCompatibleNetwork: def __init__(self, manager): self.manager = manager @@ -232,19 +232,19 @@ class LbryWalletManager(BaseWalletManager): wallet.save() -class ReservedPoints(object): +class ReservedPoints: def __init__(self, identifier, amount): self.identifier = identifier self.amount = amount -class ClientRequest(object): +class ClientRequest: def __init__(self, request_dict, response_identifier=None): self.request_dict = request_dict self.response_identifier = response_identifier -class LBRYcrdAddressRequester(object): +class LBRYcrdAddressRequester: def __init__(self, wallet): self.wallet = wallet @@ -277,7 +277,7 @@ class LBRYcrdAddressRequester(object): ) -class LBRYcrdAddressQueryHandlerFactory(object): +class LBRYcrdAddressQueryHandlerFactory: def __init__(self, wallet): self.wallet = wallet @@ -293,7 +293,7 @@ class LBRYcrdAddressQueryHandlerFactory(object): return "LBRYcrd Address - an address for receiving payments via LBRYcrd" -class LBRYcrdAddressQueryHandler(object): +class LBRYcrdAddressQueryHandler: def __init__(self, wallet): self.wallet = wallet diff --git a/lbrynet/wallet/resolve.py b/lbrynet/wallet/resolve.py index 1e1e62eb6..ef40df800 100644 --- a/lbrynet/wallet/resolve.py +++ b/lbrynet/wallet/resolve.py @@ -16,7 +16,7 @@ from .claim_proofs import verify_proof, InvalidProofError log = logging.getLogger(__name__) -class Resolver(object): +class Resolver: def __init__(self, claim_trie_root, height, transaction_class, hash160_to_address, network): self.claim_trie_root = claim_trie_root diff --git a/lbrynet/winhelpers/knownpaths.py b/lbrynet/winhelpers/knownpaths.py index c35004419..ebb68a393 100644 --- a/lbrynet/winhelpers/knownpaths.py +++ b/lbrynet/winhelpers/knownpaths.py @@ -14,14 +14,14 @@ class GUID(ctypes.Structure): ] def __init__(self, uuid_): - ctypes.Structure.__init__(self) + super().__init__() self.Data1, self.Data2, self.Data3, self.Data4[0], self.Data4[1], rest = uuid_.fields for i in range(2, 8): self.Data4[i] = rest>>(8 - i - 1)*8 & 0xff # http://msdn.microsoft.com/en-us/library/windows/desktop/dd378457.aspx -class FOLDERID(object): +class FOLDERID: # pylint: disable=bad-whitespace AccountPictures = UUID('{008ca0b1-55b4-4c56-b8a8-4de4b299d3be}') AdminTools = UUID('{724EF170-A42D-4FEF-9F26-B60E846FBA4F}') @@ -120,7 +120,7 @@ class FOLDERID(object): # http://msdn.microsoft.com/en-us/library/windows/desktop/bb762188.aspx -class UserHandle(object): +class UserHandle: current = wintypes.HANDLE(0) common = wintypes.HANDLE(-1)