-
-
Notifications
You must be signed in to change notification settings - Fork 116
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Removed ------- * Remove `ClassLoader.py`. `importlib`, in the Python standard library, is sufficient. This also reduces the number of licenses in use in the repo. * Remove a reference to `ClassLoader.py` in the pre-commit config.
- Loading branch information
Showing
3 changed files
with
13 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,10 +6,6 @@ | |
Thinking in Python, Bruce Eckel, | ||
http://mindview.net/Books/TIPython | ||
The code to instantiate the reader Factory() has | ||
been updated to dynamically load the module with | ||
Robert Brewer ClassLoader.py. | ||
Copyright 2001-2012 gemalto | ||
Author: Jean-Daniel Aussel, mailto:[email protected] | ||
|
@@ -30,7 +26,8 @@ | |
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
""" | ||
|
||
from smartcard.ClassLoader import get_class | ||
import importlib | ||
|
||
from smartcard.pcsc.PCSCReader import PCSCReader | ||
|
||
|
||
|
@@ -42,14 +39,19 @@ class ReaderFactory: | |
|
||
# A Template Method: | ||
@staticmethod | ||
def createReader(clazz, readername): | ||
def createReader(clazz: str, readername: str): | ||
"""Static method to create a reader from a reader clazz. | ||
@param clazz: the reader class name | ||
@param readername: the reader name | ||
""" | ||
if not clazz in ReaderFactory.factories: | ||
ReaderFactory.factories[clazz] = get_class(clazz).Factory() | ||
|
||
if clazz not in ReaderFactory.factories: | ||
module_name, _, class_name = clazz.rpartition(".") | ||
imported_module = importlib.import_module(module_name) | ||
imported_class = getattr(imported_module, class_name) | ||
ReaderFactory.factories[clazz] = imported_class.Factory() | ||
|
||
return ReaderFactory.factories[clazz].create(readername) | ||
|
||
@staticmethod | ||
|