aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarald Welte <laforge@osmocom.org>2021-10-14 17:48:25 +0200
committerHarald Welte <laforge@osmocom.org>2021-10-14 19:10:16 +0200
commit4c1dca04a57f1f46c262868729805e832db334a2 (patch)
treed2922ee64c629a55d131b9da78ccd35de5b19e4a
parentf898c28284428e0c561a47679c0d600afae86973 (diff)
CardModel: Document how this 'magic' works in some comments.
-rwxr-xr-xpySim-shell.py3
-rw-r--r--pySim/filesystem.py7
2 files changed, 9 insertions, 1 deletions
diff --git a/pySim-shell.py b/pySim-shell.py
index 871c45e..5aa311c 100755
--- a/pySim-shell.py
+++ b/pySim-shell.py
@@ -48,6 +48,9 @@ from pySim.ts_102_221 import CardProfileUICC
from pySim.ts_31_102 import CardApplicationUSIM
from pySim.ts_31_103 import CardApplicationISIM
+# we need to import this module so that the SysmocomSJA2 sub-class of
+# CardModel is created, which will add the ATR-based matching and
+# calling of SysmocomSJA2.add_files. See CardModel.apply_matching_models
import pySim.sysmocom_sja2
from pySim.card_key_provider import CardKeyProviderCsv, card_key_provider_register, card_key_provider_get_field
diff --git a/pySim/filesystem.py b/pySim/filesystem.py
index 8edac41..fe781de 100644
--- a/pySim/filesystem.py
+++ b/pySim/filesystem.py
@@ -1435,7 +1435,9 @@ class CardProfile(object):
class CardModel(abc.ABC):
- """A specific card model, typically having some additional vendor-specific files"""
+ """A specific card model, typically having some additional vendor-specific files. All
+ you need to do is to define a sub-class with a list of ATRs or an overridden match
+ method."""
_atrs = []
@classmethod
@@ -1456,6 +1458,9 @@ class CardModel(abc.ABC):
@staticmethod
def apply_matching_models(scc:SimCardCommands, rs:RuntimeState):
+ """Check if any of the CardModel sub-classes 'match' the currently inserted card
+ (by ATR or overriding the 'match' method). If so, call their 'add_files'
+ method."""
for m in CardModel.__subclasses__():
if m.match(scc):
m.add_files(rs)