mirror of https://gerrit.osmocom.org/pysim
CardModel: Document how this 'magic' works in some comments.
Change-Id: If16ade6e1098a87f749259bad6dea805ddb61ede
This commit is contained in:
parent
f898c28284
commit
4c1dca04a5
|
@ -48,6 +48,9 @@ from pySim.ts_102_221 import CardProfileUICC
|
||||||
from pySim.ts_31_102 import CardApplicationUSIM
|
from pySim.ts_31_102 import CardApplicationUSIM
|
||||||
from pySim.ts_31_103 import CardApplicationISIM
|
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
|
import pySim.sysmocom_sja2
|
||||||
|
|
||||||
from pySim.card_key_provider import CardKeyProviderCsv, card_key_provider_register, card_key_provider_get_field
|
from pySim.card_key_provider import CardKeyProviderCsv, card_key_provider_register, card_key_provider_get_field
|
||||||
|
|
|
@ -1435,7 +1435,9 @@ class CardProfile(object):
|
||||||
|
|
||||||
|
|
||||||
class CardModel(abc.ABC):
|
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 = []
|
_atrs = []
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
@ -1456,6 +1458,9 @@ class CardModel(abc.ABC):
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def apply_matching_models(scc:SimCardCommands, rs:RuntimeState):
|
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__():
|
for m in CardModel.__subclasses__():
|
||||||
if m.match(scc):
|
if m.match(scc):
|
||||||
m.add_files(rs)
|
m.add_files(rs)
|
||||||
|
|
Loading…
Reference in New Issue