From 49e67a0bef134175162575efdd20e4afabafe129 Mon Sep 17 00:00:00 2001 From: Safihre Date: Mon, 11 Jan 2021 11:54:19 +0100 Subject: [PATCH] Change calls to parent class to super() --- sabnzbd/assembler.py | 2 +- sabnzbd/decoder.py | 6 +++--- sabnzbd/directunpacker.py | 2 +- sabnzbd/dirscanner.py | 2 +- sabnzbd/downloader.py | 2 +- sabnzbd/nzbstuff.py | 18 +++++++++--------- sabnzbd/postproc.py | 2 +- sabnzbd/rating.py | 2 +- sabnzbd/sabtray.py | 2 +- sabnzbd/urlgrabber.py | 2 +- sabnzbd/utils/kronos.py | 2 +- sabnzbd/utils/systrayiconthread.py | 2 +- tests/testhelper.py | 2 +- 13 files changed, 23 insertions(+), 23 deletions(-) diff --git a/sabnzbd/assembler.py b/sabnzbd/assembler.py index abb6f66..6e68e19 100644 --- a/sabnzbd/assembler.py +++ b/sabnzbd/assembler.py @@ -41,7 +41,7 @@ import sabnzbd.utils.rarfile as rarfile class Assembler(Thread): def __init__(self): - Thread.__init__(self) + super().__init__() self.queue: queue.Queue[Tuple[Optional[NzbObject], Optional[NzbFile], Optional[bool]]] = queue.Queue() def stop(self): diff --git a/sabnzbd/decoder.py b/sabnzbd/decoder.py index 41ec82e..2dd0904 100644 --- a/sabnzbd/decoder.py +++ b/sabnzbd/decoder.py @@ -47,7 +47,7 @@ except ImportError: class CrcError(Exception): def __init__(self, needcrc, gotcrc, data): - Exception.__init__(self) + super().__init__() self.needcrc = needcrc self.gotcrc = gotcrc self.data = data @@ -55,7 +55,7 @@ class CrcError(Exception): class BadYenc(Exception): def __init__(self): - Exception.__init__(self) + super().__init__() class Decoder: @@ -109,7 +109,7 @@ class DecoderWorker(Thread): """ The actuall workhorse that handles decoding! """ def __init__(self, decoder_queue): - Thread.__init__(self) + super().__init__() logging.debug("Initializing decoder %s", self.name) self.decoder_queue: queue.Queue[Tuple[Optional[Article], Optional[List[bytes]]]] = decoder_queue diff --git a/sabnzbd/directunpacker.py b/sabnzbd/directunpacker.py index 76afa88..75c4983 100644 --- a/sabnzbd/directunpacker.py +++ b/sabnzbd/directunpacker.py @@ -50,7 +50,7 @@ RAR_NR = re.compile(r"(.*?)(\.part(\d*).rar|\.r(\d*))$", re.IGNORECASE) class DirectUnpacker(threading.Thread): def __init__(self, nzo: NzbObject): - threading.Thread.__init__(self) + super().__init__() self.nzo: NzbObject = nzo self.active_instance: Optional[subprocess.Popen] = None diff --git a/sabnzbd/dirscanner.py b/sabnzbd/dirscanner.py index 8218ab5..b5c308f 100644 --- a/sabnzbd/dirscanner.py +++ b/sabnzbd/dirscanner.py @@ -66,7 +66,7 @@ class DirScanner(threading.Thread): """ def __init__(self): - threading.Thread.__init__(self) + super().__init__() self.newdir() try: diff --git a/sabnzbd/downloader.py b/sabnzbd/downloader.py index 92be3a4..e0b77e7 100644 --- a/sabnzbd/downloader.py +++ b/sabnzbd/downloader.py @@ -188,7 +188,7 @@ class Downloader(Thread): """ Singleton Downloader Thread """ def __init__(self, paused=False): - Thread.__init__(self) + super().__init__() logging.debug("Initializing downloader") diff --git a/sabnzbd/nzbstuff.py b/sabnzbd/nzbstuff.py index 9c18bd3..815acd3 100644 --- a/sabnzbd/nzbstuff.py +++ b/sabnzbd/nzbstuff.py @@ -150,7 +150,7 @@ class Article(TryList): __slots__ = ArticleSaver + ("fetcher", "fetcher_priority", "tries") def __init__(self, article, article_bytes, nzf): - TryList.__init__(self) + super().__init__() self.fetcher: Optional[Server] = None self.article: str = article self.art_id = None @@ -255,7 +255,7 @@ class Article(TryList): dict_ = {} for item in ArticleSaver: dict_[item] = getattr(self, item) - dict_["try_list"] = TryList.__getstate__(self) + dict_["try_list"] = super().__getstate__() return dict_ def __setstate__(self, dict_): @@ -266,7 +266,7 @@ class Article(TryList): except KeyError: # Handle new attributes setattr(self, item, None) - TryList.__setstate__(self, dict_.get("try_list", [])) + super().__setstate__(dict_.get("try_list", [])) self.fetcher_priority = 0 self.fetcher = None self.tries = 0 @@ -322,7 +322,7 @@ class NzbFile(TryList): def __init__(self, date, subject, raw_article_db, file_bytes, nzo): """ Setup object """ - TryList.__init__(self) + super().__init__() self.date: datetime.datetime = date self.subject: str = subject @@ -457,7 +457,7 @@ class NzbFile(TryList): dict_ = {} for item in NzbFileSaver: dict_[item] = getattr(self, item) - dict_["try_list"] = TryList.__getstate__(self) + dict_["try_list"] = super().__getstate__() return dict_ def __setstate__(self, dict_): @@ -468,7 +468,7 @@ class NzbFile(TryList): except KeyError: # Handle new attributes setattr(self, item, None) - TryList.__setstate__(self, dict_.get("try_list", [])) + super().__setstate__(dict_.get("try_list", [])) # Convert 2.x.x jobs if isinstance(self.decodetable, dict): @@ -584,7 +584,7 @@ class NzbObject(TryList): reuse=None, dup_check=True, ): - TryList.__init__(self) + super().__init__() self.filename = filename # Original filename if nzbname and nzb: @@ -1979,7 +1979,7 @@ class NzbObject(TryList): dict_ = {} for item in NzbObjectSaver: dict_[item] = getattr(self, item) - dict_["try_list"] = TryList.__getstate__(self) + dict_["try_list"] = super().__getstate__() return dict_ def __setstate__(self, dict_): @@ -1990,7 +1990,7 @@ class NzbObject(TryList): except KeyError: # Handle new attributes setattr(self, item, None) - TryList.__setstate__(self, dict_.get("try_list", [])) + super().__setstate__(dict_.get("try_list", [])) # Set non-transferable values self.pp_active = False diff --git a/sabnzbd/postproc.py b/sabnzbd/postproc.py index f933ba3..fabac36 100644 --- a/sabnzbd/postproc.py +++ b/sabnzbd/postproc.py @@ -102,7 +102,7 @@ class PostProcessor(Thread): def __init__(self): """ Initialize PostProcessor thread """ - Thread.__init__(self) + super().__init__() # This history queue is simply used to log what active items to display in the web_ui self.history_queue: List[NzbObject] = [] diff --git a/sabnzbd/rating.py b/sabnzbd/rating.py index 6c1fe3c..5ece771 100644 --- a/sabnzbd/rating.py +++ b/sabnzbd/rating.py @@ -120,7 +120,7 @@ class Rating(Thread): except: logging.info("Corrupt %s file, discarding", RATING_FILE_NAME) logging.info("Traceback: ", exc_info=True) - Thread.__init__(self) + super().__init__() def stop(self): self.shutdown = True diff --git a/sabnzbd/sabtray.py b/sabnzbd/sabtray.py index 7c6e908..9e6209a 100644 --- a/sabnzbd/sabtray.py +++ b/sabnzbd/sabtray.py @@ -82,7 +82,7 @@ class SABTrayThread(SysTrayIconThread): (T("Shutdown"), None, self.shutdown), ) - SysTrayIconThread.__init__(self, self.sabicons["default"], "SABnzbd", menu_options, None, 0, "SabTrayIcon") + super().__init__(self.sabicons["default"], "SABnzbd", menu_options, None, 0, "SabTrayIcon") def set_texts(self): """ Cache texts for performance, doUpdates is called often """ diff --git a/sabnzbd/urlgrabber.py b/sabnzbd/urlgrabber.py index c7b4e7e..cbf1205 100644 --- a/sabnzbd/urlgrabber.py +++ b/sabnzbd/urlgrabber.py @@ -61,7 +61,7 @@ _RARTING_FIELDS = ( class URLGrabber(Thread): def __init__(self): - Thread.__init__(self) + super().__init__() self.queue: queue.Queue[Tuple[Optional[str], Optional[NzbObject]]] = queue.Queue() for url_nzo_tup in sabnzbd.NzbQueue.get_urls(): self.queue.put(url_nzo_tup) diff --git a/sabnzbd/utils/kronos.py b/sabnzbd/utils/kronos.py index 5fbfc81..ae89425 100644 --- a/sabnzbd/utils/kronos.py +++ b/sabnzbd/utils/kronos.py @@ -407,7 +407,7 @@ class ThreadedScheduler(Scheduler): """A Scheduler that runs in its own thread.""" def __init__(self): - Scheduler.__init__(self) + super().__init__() # we require a lock around the task queue self._lock = threading.Lock() diff --git a/sabnzbd/utils/systrayiconthread.py b/sabnzbd/utils/systrayiconthread.py index 3f593d7..fc6feb7 100644 --- a/sabnzbd/utils/systrayiconthread.py +++ b/sabnzbd/utils/systrayiconthread.py @@ -26,7 +26,7 @@ class SysTrayIconThread(Thread): terminate = False def __init__(self, icon, hover_text, menu_options, on_quit=None, default_menu_index=None, window_class_name=None): - Thread.__init__(self) + super().__init__() self.icon = icon self.icons = {} self.hover_text = hover_text diff --git a/tests/testhelper.py b/tests/testhelper.py index 9f467dd..4f04c03 100644 --- a/tests/testhelper.py +++ b/tests/testhelper.py @@ -176,7 +176,7 @@ class FakeHistoryDB(db.HistoryDB): def __init__(self, db_path): db.HistoryDB.db_path = db_path - super(FakeHistoryDB, self).__init__() + super().__init__() def add_fake_history_jobs(self, number_of_entries=1): """ Generate a history db with any number of fake entries """