From 1d6408f0d46941ff4d4c466c52fa6b3d258b94ab Mon Sep 17 00:00:00 2001 From: Kurt McKee Date: Wed, 2 Oct 2024 08:56:40 -0500 Subject: [PATCH] Remove dead readergroups code * `DeleteSCardDefaultReaderGroupException` is unused in the codebase. Searching Google and GitHub further confirms it is unused. * `initlist` can only be `None` if `.getreadergroups()` returns `None`. Changing the code eliminates the condition. * Removing `if __name__ == '__main__'` eliminates junk code. Code coverage is now 100% for the file. --- src/smartcard/reader/ReaderGroups.py | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/src/smartcard/reader/ReaderGroups.py b/src/smartcard/reader/ReaderGroups.py index bfbc145a..1264e7da 100644 --- a/src/smartcard/reader/ReaderGroups.py +++ b/src/smartcard/reader/ReaderGroups.py @@ -33,14 +33,6 @@ def __init__(self): SmartcardException.__init__(self, 'Invalid reader group') -class DeleteSCardDefaultReaderGroupException(SmartcardException): - """Raised when trying to delete SCard$DefaultReaders reader group.""" - - def __init__(self): - SmartcardException.__init__( - self, 'SCard$DefaultReaders cannot be deleted') - - class innerreadergroups(ulist): """Smartcard readers groups private class. @@ -51,9 +43,8 @@ class innerreadergroups(ulist): def __init__(self, initlist=None): """Retrieve and store list of reader groups""" if initlist is None: - initlist = self.getreadergroups() - if initlist is not None: - ulist.__init__(self, initlist) + initlist = self.getreadergroups() or [] + ulist.__init__(self, initlist) self.unremovablegroups = [] def __onadditem__(self, item): @@ -112,7 +103,3 @@ def __init__(self, initlist=None): def __getattr__(self, name): return getattr(self.instance, name) - - -if __name__ == '__main__': - print(readergroups())